You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cause is that cpptcl.h is defining USE_TCL_STUBS before including tcl.h
This is inappropriate for the case where cpptcl is being used from a program that's just embedding tcl, rather than an extension to be embedded in an existing interpreter.
Whether it actually breaks things is very dependent on the order of includes; if tcl.h is included before cpptcl.h, then cpptcl.h's USE_TCL_STUBS has no effect and everything is fine.
example2.cc in the cpptcl tree is an example of case 3. Swapping the order of the includes produces case 1, which then crashes.
The text was updated successfully, but these errors were encountered:
We failed to get a function added to Tcl which could create an interpreter regardless of the compiler macros implemented by USE_TCL_STUBS. Currently you have to create the TCL interpreter from a compilation unit without USE_TCL_STUBS defined. When USE_TCL_STUBS is defined Tcl_CreateInterp is a macro which guarantees a crash.
The spirit of the TIP 531 code is that one should be able to use USE_TCL_STUBS all the time. The only time you need to avoid the C macros USE_TCL_STUBS creates is when creating the first Tcl interpreter instance. That's why we are trying to get the function included with Tcl.
If you are not creating a Tcl extension, then you can avoid the use of USE_TCL_STUBS by defining CPPTCL_NO_TCL_STUBS. Note that the Tcl TEA framework for extensions always sets USE_TCL_STUBS in those build configurations. Therefore, the default is for an extension author not an embedded Tcl author.
This program crashes with a segfault; it tries to call Tcl_CreateInterp via the tcl stubs pointer, but the stubs pointer is null. (case 1)
This program does not crash (case 2)
This program also does not crash (case 3)
The cause is that cpptcl.h is defining USE_TCL_STUBS before including tcl.h
This is inappropriate for the case where cpptcl is being used from a program that's just embedding tcl, rather than an extension to be embedded in an existing interpreter.
Whether it actually breaks things is very dependent on the order of includes; if tcl.h is included before cpptcl.h, then cpptcl.h's USE_TCL_STUBS has no effect and everything is fine.
example2.cc
in the cpptcl tree is an example of case 3. Swapping the order of the includes produces case 1, which then crashes.The text was updated successfully, but these errors were encountered: