Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-03-31
04:18 • Closed ticket [2978773fff]: Segfault when using a reflected channel plus 8 o... artifact: dde84f913a user: andreas_kupries
03:00 • Ticket [2978773fff]: 4 changes artifact: 775ece20dc user: andreas_kupries
02:59 • Add attachment patch-86 to ticket [2978773fff] artifact: 96a7df14dd user: andreas_kupries
02:59 • Ticket [2978773fff] Segfault when using a reflected channel status still Ope... artifact: 85acefd2b3 user: andreas_kupries
02:59 • Ticket [2978773fff]: 4 changes artifact: 42263743b3 user: andreas_kupries
02:59 • Add attachment patch-85 to ticket [2978773fff] artifact: f7c7b4971b user: andreas_kupries
01:47 • Ticket [2978773fff] Segfault when using a reflected channel status still Ope... artifact: ed8e31d56a user: andreas_kupries
01:41 • Ticket [2978773fff]: 4 changes artifact: 38922fbe37 user: andreas_kupries
01:41 • Add attachment segfault-log.txt to ticket [2978773fff] artifact: b409587508 user: andreas_kupries
01:41 • Ticket [2978773fff] Segfault when using a reflected channel status still Ope... artifact: e3afecca77 user: andreas_kupries
01:41 • Add attachment segfault.tcl to ticket [2978773fff] artifact: cb7cd81b6d user: andreas_kupries
2010-03-30
03:01 • Add attachment valgrind.out to ticket [2978773fff] artifact: 7c7d05d707 user: sbron
03:01 • Ticket [2978773fff] Segfault when using a reflected channel status still Ope... artifact: c30b5fafb1 user: sbron
02:27 • Ticket [2978773fff]: 4 changes artifact: 7b682290a6 user: sbron
02:25 • Ticket [2978773fff]: 4 changes artifact: ee0dad522f user: sbron
02:25 • Add attachment segfault.tcl to ticket [2978773fff] artifact: e8d1eefaad user: sbron
2010-03-29
19:25 • New ticket [2978773fff] Segfault when using a reflected channel. artifact: d09b29856c user: sbron

Segfault when using a reflected channel

Closed / Fixed2978773fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2010-03-29 19:25:31
The attached script causes a segfault, as discussed on the chat with aku and kbk.
sbronplain2010-03-30 02:25:31
File Added - 368654: segfault.tcl
sbronplain2010-03-30 02:27:22
File Added - 368655: valgrind.out
sbronplain2010-03-30 03:01:03
File Deleted - 368655: 



File Added - 368657: valgrind.out
andreas_kupriesplain2010-03-31 01:41:14
File Added - 368847: segfault.tcl
andreas_kupriesplain2010-03-31 01:41:56
File Added - 368848: segfault-log.txt
andreas_kupriesplain2010-03-31 01:47:38
The problem is equivalent to 2921116, except for reflected channel instead of reflected transform.

The crashing script deeply nests through the script handler of the channel, then destroys the channel very deeply in the stack, and during the unwinding process it tries to invoke the script handler at a point where the structure is already destroyed, with bogus interp and other pointers.

This can be seen very nicely in the modified segfault.tcl script where I changed the logging to show the nesting structure of Tcl procedures. The nesting does occur because of the immediate posting of events in some places, calling immediately back into the Tcl layer. This is why defering this action via 'after' is a workaround. It prevents the nesting and thus each callback into the channel handler can be sure to have the C structure whole and complete for the lifetime of its operation.

Now working on the fix (Tcl_Preserve/Release the C level ReflectedChannel structure to keep it alive while there are references to it in C and Tcl stacks).
andreas_kupriesplain2010-03-31 02:59:31
File Added - 368853: patch-85
andreas_kupriesplain2010-03-31 02:59:53
File Added - 368854: patch-86
andreas_kupriesplain2010-03-31 03:00:54
The attached fixes (represented by unidiff patches) pass the segfault.tcl.
This example does not crash any longer.
andreas_kupriesplain2010-03-31 04:18:16
allow_comments - 1

Fixes committed to head and 8.5 branch.
Log in (anonymous is fine) to add a comment.

Attachments: