Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7e6860137003f93d7d66fdfab4e370153a9449b4524bb51c122a0c33d7a68636
Ticket: b1b2d135818b64c11817013ea8828b298b08a079
Tcl_Eval causes SIGSEGV, Segmentation fault
User & Date: sebres on 2018-01-09 21:37:29
Changes

  1. icomment:
    So I see tk here. 
    
    1. If you cannot reproduce it without tk, then you should rather open the ticket by the tk-repository. This one is tcl-repository.
    
    2. As I already wrote Tk is not thread-safe (resp. not completely).
    So if you've 2 threads, you should organize the work as following:
    
      - main-thread (using Tk) sends "event" to 2nd-thread;
      - 2nd-thread (DON'T USE Tk) do something and answer (e. g. also with event)
        back to main-thread; Note you can use Tcl there, but not Tk.
      - main-thread "draws" the result with Tk.
    
    Note, that only this (main) thread may use tk, but not the 2nd-thread.
    Then segfaults are the best what will happen here (sometimes it is an retarded aftereffect, so exception occurs much later, thus no chance to find the wrong piece).
    
    3. You said it's a C++ (and you call your C++ code somewhere from tcl-code) and the C++ exception handling used, you should necessarily catch the exception still in the same C++ call (before you returns to tcl-scope), I mean you should not traverse with the exception over some tcl-scope (it would be wrong).
    
    c++_code_1 {
      ...
      c++_try {
        ...
        tcl_code { // Eval, NRE, Expr, Coroutine, etc...
          ...
          c++_code_2 {
            c++_try {
              ...
              c++_throw_except; // A allowed, B would be wrong!!!
              ...
            } c++_catch A {};
          }
        }
      } c++_catch B {};
    }
    
    Note: c++_code_2 (inside tcl-eval) CAN'T throw C++ exception of type "B".
    
  2. login: "sebres"
  3. mimetype: "text/plain"