Artifacts Associated With Ticket 46dda6fc29
Ticket change [40b2eb0a5d] (rid 208686) by xdelaruelle on 2023-02-12 12:25:28:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-markdown"
- comment initialized to:
Hello, I was testing how my software [1] is coping with Tcl 9 and I think I have spotted an issue on the "trace" feature. I observe that tclsh segfaults when an execution leave trace is triggered and procedure result contains a "\<newline>" sequence. I would expect the script to continue until its end. I have made a small code example to reproduce this issue. 3 different files are needed: * myfile_ok * myfile_bad * test.tcl This example works fine on Tcl 8.5, 8.6, 8.7. Issue is observed on 9.0, I have tested it against 9.0a3 and 9.0b1 (current core-9-0-b1 git branch). Regards, Xavier [1] https://github.com/cea-hpc/modules ### myfile_ok ``` set myvar foo switch -- $myvar { foo - bar - baz - foobar { set res pass } other { set res fail } } ``` ### myfile_bad ``` set myvar foo switch -- $myvar { foo - bar -\ baz - foobar { set res pass } other { set res fail } } ``` ### test.tcl ``` proc myproc {what} { set fname myfile_${what} set fid [open $fname] set res [read $fid] close $fid return $res } proc traceEnter {cmdstring op} { puts "trace enter $cmdstring" } proc traceLeave {cmdstring code result op} { puts "trace leave $cmdstring" } puts "before myproc ok" set content [myproc ok] puts "after myproc ok" puts "before myproc bad" set content [myproc bad] puts "after myproc bad" puts {} trace add execution myproc enter traceEnter trace add execution myproc leave traceLeave puts "with trace before myproc ok" set content [myproc ok] puts "with trace after myproc ok" puts "with trace before myproc bad" set content [myproc bad] puts "with trace after myproc bad" puts {} interp create foo interp alias foo myproc {} myproc interp eval foo { puts "interp with trace before myproc ok" set content [myproc ok] puts "interp with trace after myproc ok" puts "interp with trace before myproc bad" set content [myproc bad] puts "interp with trace after myproc bad" } ``` ### Test execution ``` $ /usr/local/tcl8.7/bin/tclsh8.7 test.tcl before myproc ok after myproc ok before myproc bad after myproc bad with trace before myproc ok trace enter myproc ok trace leave myproc ok with trace after myproc ok with trace before myproc bad trace enter myproc bad trace leave myproc bad with trace after myproc bad interp with trace before myproc ok trace enter myproc ok trace leave myproc ok interp with trace after myproc ok interp with trace before myproc bad trace enter myproc bad trace leave myproc bad interp with trace after myproc bad $ /usr/local/tcl9.0b1/bin/tclsh9.0 test.tcl before myproc ok after myproc ok before myproc bad after myproc bad with trace before myproc ok trace enter myproc ok trace leave myproc ok with trace after myproc ok with trace before myproc bad trace enter myproc bad Segmentation fault (core dumped) $ echo $? 139 ``` # Crash information ``` Process 386290 (tclsh9.0) of user 1000 dumped core. Module /usr/local/tcl9.0b1/lib/libtcl9.0.so with build-id 254e417b3c6ef47f536226ded9b324e619f1d399 Module linux-vdso.so.1 with build-id e09c2d859d0bcca3cc4ad2a1f473b243838cf213 Module ld-linux-x86-64.so.2 with build-id 321b87738a8ee7220b3c045c0d4d93150be54470 Module libc.so.6 with build-id 8257ee907646e9b057197533d1e4ac8ede7a9c5c Module libm.so.6 with build-id 7c51a65c054f2ddc34c8325d82a1150f580f0d91 Module libz.so.1 with build-id aec7e77c3a6ce5dd195a8c86a8fb1178715cf45f Metadata for module libz.so.1 owned by FDO found: { "type" : "rpm", "name" : "zlib", "version" : "1.2.11-33.fc36", "architecture" : "x86_64", "osCpe" : "cpe:/o:fedoraproject:fedora:36" } Module libtcl9.0.so with build-id 254e417b3c6ef47f536226ded9b324e619f1d399 Module tclsh9.0 with build-id decbc80d055a6d0934d199146c0757bd7da1d020 Stack trace of thread 386290: #0 0x00007fcfd06c3635 TclScanElement (libtcl9.0.so + 0x149635) #1 0x00007fcfd06c52c4 Tcl_DStringAppendElement (libtcl9.0.so + 0x14b2c4) #2 0x00007fcfd06be33a TraceExecutionProc (libtcl9.0.so + 0x14433a) #3 0x00007fcfd06be5b2 TclCheckExecutionTraces (libtcl9.0.so + 0x1445b2) #4 0x00007fcfd05c0b07 TEOV_RunLeaveTraces (libtcl9.0.so + 0x46b07) #5 0x00007fcfd05bfe82 TclNRRunCallbacks (libtcl9.0.so + 0x45e82) #6 0x00007fcfd05c1cf3 TclEvalEx (libtcl9.0.so + 0x47cf3) #7 0x00007fcfd069c581 TclSubstTokens (libtcl9.0.so + 0x122581) #8 0x00007fcfd05c1bb5 TclEvalEx (libtcl9.0.so + 0x47bb5) #9 0x00007fcfd068580a Tcl_FSEvalFileEx (libtcl9.0.so + 0x10b80a) #10 0x00007fcfd06903c8 Tcl_MainEx (libtcl9.0.so + 0x1163c8) #11 0x00000000004010dd main (tclsh9.0 + 0x10dd) #12 0x00007fcfd0229510 __libc_start_call_main (libc.so.6 + 0x29510) #13 0x00007fcfd02295c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x295c9) #14 0x0000000000401105 _start (tclsh9.0 + 0x1105) ELF object binary architecture: AMD x86-64 ``` - foundin initialized to: "9.0b1"
- is_private initialized to: "0"
- login: "xdelaruelle"
- priority initialized to: "5 Medium"
- private_contact initialized to: "231d7ecff918d0384f1ee469cf171339e824104a"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "xdelaruelle"
- subsystem initialized to: "46. Traces"
- title initialized to:
Tcl 9: segfault with execution leave trace when proc result contains \<newline>
- type initialized to: "Bug"
Ticket change [419b93c083] (rid 209198) by apnadkarni on 2023-02-25 08:34:12:
- assignee changed to: "apnadkarni"
- icomment: "Thanks for the report. Testing a fix..."
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [d1c6ccac48] (rid 209205) by apnadkarni on 2023-02-25 09:35:02:
- icomment:
Please check if branch [bug-46dda6fc29] fixes your problem. I tested your script and it WOMM. Thank you very much for bothering to boil down a test case and report this. The bug was actually not in the trace implementation but in TclScanElement which is a much more fundamental, and therefore very important, routine. /Ashok
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [947240f340] (rid 209228) by xdelaruelle on 2023-02-26 08:48:15:
- icomment:
I have tested branch [bug-46dda6fc29] against the software I work on and I confirm that the fix solves the encountered issue. Many thanks for your work. /Xavier
- login: "xdelaruelle"
- mimetype: "text/plain"
- icomment:
Ticket change [2eb5f2bf29] (rid 209232) by jan.nijtmans on 2023-02-26 12:47:45:
- icomment: "+1"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [2912e744f3] (rid 209277) by jan.nijtmans on 2023-02-26 21:45:46:
- closedate changed to: "2460002.40678498"
- closer changed to: "jan.nijtmans"
- icomment: "Fix committed [32c5b5172b|here]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"