Tcl Source Code

View Ticket
Login
Ticket UUID: 0e3f777ed566b80ba44886212cfd9882819ee06c
Title: Segfault upon sequence of execution traces
Type: Bug Created on: 2026-07-25 15:22:03
Submitter: erikleunissen Assigned to: nobody
Subsystem: 46. Traces Severity: Severe
Priority: 5 Medium Last modified: 2026-11-11 09:45:12
Status: Closed Closed by: oehhar
Resolution: Fixed Closed on: 2026-11-11 09:45:12
Version: 8.6.18, 9.0.5, 9.1.0
Description:
Attached reproducible script "exercise.tcl" and full stack trace in
"stack_trace.txt".

To reproduce do:

> cat exercise.tcl
proc p {} {
    # This proc needs to hold at least one (arbitrary) command
    # for enterstep traces to work.
    puts "p invoked"
}
proc handleTrace1 {args} {
    trace remove execution p enterstep handleTrace1
}
proc handleTrace0 {args} {
    trace add execution p enterstep handleTrace1
}
trace add execution p leave handleTrace0
trace add execution p leave handleTrace0
p
p

> tclsh9.1 exercise.tcl
p invoked
Segmentation fault (core dumped)
User Comments:
serhiy.storchaka added on 2026-10-14 18:11:23:

Reproduced with 8.6.18, 9.0.5 and 9.1. When an enterstep trace removes itself while another enterstep trace is set, TclCheckInterpTraces() continues the reverse scan of the interpreter traces from the deleted trace and runs off the end of the list.

Proposed fix in branch interp-trace-delete-self. Test trace-34.7.


oehhar added on 2026-11-10 16:54:05:

Fix and test are effective. Will merge tomorrow if CI is clean.

Thanks Serhiy, Harald


oehhar added on 2026-11-11 09:45:12:

Merged to:

  • main [245d2b1c]
  • core-9-0-branch [ff4839e9]
  • core-8-6-branch [a583dec2]

Thanks for all. Bug closed.

Harald


Attachments: