Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2014-12-18
14:38
[af08e89777] Rework finalization to stop encoding-24.2 segfault. check-in: 60215f1e7a user: dgp tags: trunk
14:37 • Closed ticket [af08e89777]: encoding-24.2 segfault plus 7 other changes artifact: 8e7bac20cd user: dgp
2014-12-17
20:48 • Ticket [af08e89777]: 4 changes artifact: 837f3ebb07 user: dgp
20:47 • Ticket [af08e89777]: 3 changes artifact: d71fd4daa6 user: dgp
20:00 • Ticket [af08e89777]: 3 changes artifact: 62015b2ee5 user: dgp
18:32 • Ticket [af08e89777]: 3 changes artifact: e736733009 user: dgp
2014-12-16
16:47 • Ticket [af08e89777]: 3 changes artifact: 05a24b2418 user: dgp
16:11 • New ticket [af08e89777]. artifact: 0ede1f2870 user: dgp

encoding-24.2 segfault

Closed / Fixedaf08e897775f807b294ac5c72d7a8a196530c0ddCreated 12 years agoUpdated 12 years ago
Descriptionplain2014-12-16 16:11:43
Test encoding-24.2 fails due to segfault in a
child process:

==== encoding-24.2 EscapeFreeProc on open channels FAILED
==== Contents of test case:

    # Bug #524674 output
    viewable [runInSubprocess {
        encoding system cp1252; # Bug #2891556 crash revelator
        fconfigure stdout -encoding iso2022-jp
        puts ab\u4e4e\u68d9g
        set env(TCL_FINALIZE_ON_EXIT) 1
        exit
    }]

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: abB8C(DD%g
child killed: segmentation violation
    while executing
"exec [interpreter] $theFile"
    (procedure "runInSubprocess" line 4)
    invoked from within
"runInSubprocess {
        encoding system cp1252; # Bug #2891556 crash revelator
        fconfigure stdout -encoding iso2022-jp
        puts ab\u4e4e\u68d9g
        set env(TCL_F..."
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $script"
---- errorCode: CHILDKILLED 16076 SIGSEGV {segmentation violation}
==== encoding-24.2 FAILED

Bisection says this failure was introduced in checkin

http://core.tcl.tk/tcl/info/c16bc1a7db
Referenced by1
dgpplain2014-12-16 16:47:13
Program received signal SIGSEGV, Segmentation fault.
0x00000000004da7e5 in TableToUtfProc (clientData=0x67cde0, 
    src=0x7fffffffe648 "p3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:", 
    srcLen=123, flags=2, statePtr=0x7fffffffcae0, dst=0x6a16ac "", 
    dstLen=1602, srcReadPtr=0x7fffffffcadc, dstWrotePtr=0x7fffffffcad8, 
    dstCharsPtr=0x7fffffffcad4)
    at /home/dgp/fossil/tcl-only/generic/tclEncoding.c:2594
2594                ch = pageZero[byte];
Missing separate debuginfos, use: debuginfo-install glibc-2.17-55.el7_0.1.x86_64 libgcc-4.8.2-16.2.el7_0.x86_64 zlib-1.2.7-13.el7.x86_64
(gdb) bt
#0  0x00000000004da7e5 in TableToUtfProc (clientData=0x67cde0, 
    src=0x7fffffffe648 "p3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:", 
    srcLen=123, flags=2, statePtr=0x7fffffffcae0, dst=0x6a16ac "", 
    dstLen=1602, srcReadPtr=0x7fffffffcadc, dstWrotePtr=0x7fffffffcad8, 
    dstCharsPtr=0x7fffffffcad4)
    at /home/dgp/fossil/tcl-only/generic/tclEncoding.c:2594
#1  0x00000000004d87dc in Tcl_ExternalToUtfDString (encoding=0x6744c0, 
    src=0x7fffffffe648 "p3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:", 
    srcLen=123, dstPtr=0x7fffffffcb30)
    at /home/dgp/fossil/tcl-only/generic/tclEncoding.c:1136
#2  0x000000000058d45b in TclpFindVariable (
    name=0x5d258d "TCL_FINALIZE_ON_EXIT", lengthPtr=0x7fffffffcd20)
    at /home/dgp/fossil/tcl-only/unix/tclUnixInit.c:1013
#3  0x00000000004e3cdd in TclGetEnv (name=0x5d258d "TCL_FINALIZE_ON_EXIT", 
    valuePtr=0x7fffffffcd60) at /home/dgp/fossil/tcl-only/generic/tclEnv.c:528
#4  0x0000000000534a37 in TclFullFinalizationRequested ()
    at /home/dgp/fossil/tcl-only/generic/tclMain.c:733
#5  0x0000000000563aaf in TclFinalizeThreadData ()
    at /home/dgp/fossil/tcl-only/generic/tclThread.c:360
#6  0x00000000004e59e1 in Tcl_Finalize ()
    at /home/dgp/fossil/tcl-only/generic/tclEvent.c:1186
#7  0x00000000004e585e in Tcl_Exit (status=0)
    at /home/dgp/fossil/tcl-only/generic/tclEvent.c:963
dgpplain2014-12-17 18:32:32
The essential problem here is that the helper
routine TclFullFinalizationRequested() makes use
of the encoding subsystem as part of reading an
environment variable, but the finalization sequence
is calling that routine after the encoding subsystem
has been finalized.
dgpplain2014-12-17 20:00:04
Branch bug-af08e89777 created to work on this.

Step 1: Improve encoding finalization so that it more completely
restores to the pre-initialized state.  This makes finalization
errors happen repeatably and reliably across platforms rather
than being a consequence of platform-specific happenstance about
how freed memory is reused.

With this revision both tests exit-1.2 and encoding-24.2 should
reliably fail.
dgpplain2014-12-17 20:47:58
Step 2: Rework the (transitive) callers of TclFinalizeThreadData()
so that we control whether or not TclFinalizeThreadAllocThread()
is called in the desired way for supporting default quick exit.
Tests now pass.  Revised signatures are all in the fully internal
routines only.  Nothing even in the private stubs table is changed.
dgpplain2014-12-17 20:48:44
Step 3:  Ask ferrieux to take an independent look, and
then merge to trunk if he approves.  Thanks!
dgpplain2014-12-18 14:37:44
Received provisional approval, so merging to trunk
for all the industrial strength testing.  Thanks!
Log in (anonymous is fine) to add a comment.