Tcl Source Code

View Ticket
Login
Ticket UUID: 6b3a427c25bcf0c1eeec3fe9965e1238156bf87b
Title: Crash with fconfigure
Type: Bug Created on: 2017-08-11 16:19:07
Submitter: gcramer Assigned to: nobody
Subsystem: 24. Channel Commands Severity: Important
Priority: 5 Medium Last modified: 2026-10-12 19:45:06
Status: Pending Closed by: nobody
Resolution: Works For Me Closed on:
Version: 8.7
Description:

That's what I'm doing:

    set chan [open $filename.tmp w]
    fconfigure $chan -encoding utf-8

The result is a segmentation fault [unix/tclEpollNotfy.c:254]. If I test with valgrind then I get the following messages:

==3837== Syscall param epoll_ctl(event) points to uninitialised byte(s)
==3837==    at 0x4829EEE: epoll_ctl (syscall-template.S:81)
==3837==    by 0x449C3AF: PlatformEventsControl (tclEpollNotfy.c:258)
==3837==    by 0x449C931: Tcl_CreateFileHandler (tclEpollNotfy.c:547)
==3837==    by 0x4498B97: TcpWatchProc (tclUnixSock.c:1079)
==3837==    by 0x4498F21: TcpConnect (tclUnixSock.c:1304)
==3837==    by 0x4498BE6: TcpAsyncCallback (tclUnixSock.c:1136)
==3837==    by 0x449BF20: FileHandlerEventProc (tclUnixNotfy.c:275)
==3837==    by 0x444B2EF: Tcl_ServiceEvent (tclNotify.c:670)
==3837==    by 0x444B5CA: Tcl_DoOneEvent (tclNotify.c:903)
==3837==    by 0x4062876: Tk_MainLoop (in /usr/local/lib/libtk8.7.so)
==3837==    by 0x4072049: Tk_MainEx (in /usr/local/lib/libtk8.7.so)
==3837==    by 0x80538CE: main (tkscidb.cpp:110)
==3837==  Address 0xbed54b24 is on thread 1's stack
==3837== 
==3837== Use of uninitialised value of size 4
==3837==    at 0x449C386: PlatformEventsControl (tclEpollNotfy.c:254)
==3837==    by 0x449C9C6: Tcl_DeleteFileHandler (tclEpollNotfy.c:602)
==3837==    by 0x448FE24: FileWatchProc (tclUnixChan.c:485)
==3837==    by 0x441FFF2: ChanWatch (tclIO.c:512)
==3837==    by 0x44289E7: UpdateInterest (tclIO.c:8490)
==3837==    by 0x4427F8F: Tcl_SetChannelOption (tclIO.c:8026)
==3837==    by 0x442D379: Tcl_FconfigureObjCmd (tclIOCmd.c:820)
==3837==    by 0x43435EB: Dispatch (tclBasic.c:4376)
==3837==    by 0x434366B: TclNRRunCallbacks (tclBasic.c:4409)
==3837==    by 0x4342F80: Tcl_EvalObjv (tclBasic.c:4139)
==3837==    by 0x43451A6: TclEvalEx (tclBasic.c:5278)
==3837==    by 0x434476C: Tcl_EvalEx (tclBasic.c:4943)
==3837== 
==3837== Invalid write of size 4
==3837==    at 0x449C386: PlatformEventsControl (tclEpollNotfy.c:254)
==3837==    by 0x449C9C6: Tcl_DeleteFileHandler (tclEpollNotfy.c:602)
==3837==    by 0x448FE24: FileWatchProc (tclUnixChan.c:485)
==3837==    by 0x441FFF2: ChanWatch (tclIO.c:512)
==3837==    by 0x44289E7: UpdateInterest (tclIO.c:8490)
==3837==    by 0x4427F8F: Tcl_SetChannelOption (tclIO.c:8026)
==3837==    by 0x442D379: Tcl_FconfigureObjCmd (tclIOCmd.c:820)
==3837==    by 0x43435EB: Dispatch (tclBasic.c:4376)
==3837==    by 0x434366B: TclNRRunCallbacks (tclBasic.c:4409)
==3837==    by 0x4342F80: Tcl_EvalObjv (tclBasic.c:4139)
==3837==    by 0x43451A6: TclEvalEx (tclBasic.c:5278)
==3837==    by 0x434476C: Tcl_EvalEx (tclBasic.c:4943)
==3837==  Address 0x6d6a706b is not stack'd, malloc'd or (recently) free'd

User Comments:
serhiy.storchaka added on 2026-10-12 19:45:06:

I cannot reproduce it, even with 8.7a1 (epoll notifier): opening and reconfiguring regular files and sockets with and without file events, including asynchronous connects that retry another address, runs clean under valgrind with 8.7a1, 8.7a5, 8.7b1 and 9.1. Can you provide a script that reproduces it?