Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] Segfault if zcompile followed by source, on large file



On 2 Jan 2018 at 15:49:22, Sebastian Gniazdowski (psprint@xxxxxxxxxxx) wrote:
> I exponentially enlarged the file starting from 1 line, and first segfault occurred  
> at 292k lines, 146k was fine.

Ran valgrind, expecting that something will came up in zcompile, some heap corruption. However it's sourcing that yields something, and it's the thing known from backtrace:

==49954== Memcheck, a memory error detector
==49954== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==49954== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==49954== Command: zsh-5.4.2-dev-0 ./test2.src.script
==49954==
==49954== Invalid read of size 4
==49954==    at 0x100019C3A: addvars (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015784: execsimple (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001506D: execlist (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100014CF3: execode (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x1000351FE: source (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10000EB09: bin_dot (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100001D25: execbuiltin (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001F0E2: execcmd_exec (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001A9EE: execpline2 (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015B80: execpline (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015307: execlist (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100014CF3: execode (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==  Address 0x1016c4000 is not stack'd, malloc'd or (recently) free'd

==49954== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==49954==  Access not within mapped region at address 0x1016C4000
==49954==    at 0x100019C3A: addvars (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015784: execsimple (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001506D: execlist (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100014CF3: execode (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x1000351FE: source (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10000EB09: bin_dot (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100001D25: execbuiltin (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001F0E2: execcmd_exec (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x10001A9EE: execpline2 (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015B80: execpline (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==    by 0x100015307: execlist (in /usr/local/bin/zsh-5.4.2-dev-0)
#zcompile test2.src
==49954==    by 0x100014CF3: execode (in /usr/local/bin/zsh-5.4.2-dev-0)
==49954==  If you believe this happened as a result of a stack
==49954==  overflow in your program's main thread (unlikely but
==49954==  possible), you can try to increase the size of the
==49954==  main thread stack using the --main-stacksize= flag.
==49954==  The main thread stack size used in this run was 8388608.

Valgrind hints that this might be a stack overflow:

==52921==  If you believe this happened as a result of a stack
==52921==  overflow in your program's main thread (unlikely but
==52921==  possible), you can try to increase the size of the
==52921==  main thread stack using the --main-stacksize= flag.
==52921==  The main thread stack size used in this run was 8388608.

However I ran it again with --main-stacksize=9388608 and 19388608, and the issue repeated.

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org



Messages sorted by: Reverse Date, Date, Thread, Author