Overview
| Artifact ID: | 4e5ae46a95eb1caaff09f8cad1ee5e276cd84e30 |
|---|---|
| Ticket: | 2918110fffffffffffffffffffffffffffffffff
Segfault from chan postevent |
| User & Date: | andreas_kupries on 2010-01-19 04:58:34 |
Changes
- icomment:
The diagnosis is basically ok ... Tcl_CreateChannelHandler registers the new handler we want, this tells the IO system that we are willing to accept write events, this causes 'UpdateInterest' to be called, which calls the "watch" command of your reflected channel, which decides that we should send the event NOW, via 'postevent', which calls Tcl_NotifyChannel, and through that the designated callback, i.e. TclChannelEventScriptInvoker, which now operates on the allocated, but otherwise uninitialized EventScript structure. BOOM. The C-level channels do not have this problem because none of them calls Tcl_NotifyChannel immediately in their watch proc, but only when an event is actually signed by the notifier (FileHandler callbacks). For the reflected channel the problem is that the 'chan postevent' command has no reliable way of detecting that it is called directly from the 'watchProc' ... If we had that we could throw an error message telling the user that the postevent should be defered. Without that your patch is in essence the way to go. Initialize everything in the structure before we create and register the channel handler with the IO core. Regarding "without replicating so many commands", that is possible, but will require a boolean variable to remember if we have to call Tcl_CreateChannelHandler or not, i.e. something which holds the result of 'esPtr == NULL' even after we have allocated the structure and assigned to esPtr.
- login: "andreas_kupries"
- mimetype: "text/plain"
- username: "andreas_kupries"