Re: bison segv under Cygwin 64 at fatal-signal.c:318
Brian Inglis <[email protected]> Mon, 13 Sep 2021 22:18:03 -0600
| Newsgroups | gmane.comp.parsers.bison.bugs |
|---|---|
| Organization | Systematic Software |
| Message-ID | <[email protected]> |
On 2021-09-13 17:19, Brian Inglis wrote:
> On 2021-09-13 14:54, Brian Inglis wrote:
>> On 2021-09-13 14:20, Akim Demaille wrote:
>>> Thanks for the very detailed bug report! Before trying to go
>>> further, could you please try this tarball, which includes an updated
>>> gnulib?
>>>
>>> https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.1.27-dd6e.tar.gz
>>> https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.1.27-dd6e.tar.lz
>>> https://www.lrde.epita.fr/~akim/private/bison/bison-3.8.1.27-dd6e.tar.xz
>> Thanks for the quick response Akim, will try that out ASAP!
>>
>> The only information I forgot to include was that I copied your patch
>> to revert the autoconf upgrade from 2.68 to 2.71 as Cygwin currently
>> only has up to 2.69.
>>> If it does not work any better, we'll probably have to dive into gnulib.
>> Spent part of yesterday there!
>>
>> Will later be trying to rebuild fatal-signal.c in the released version
>> with -E to see what the expansions of gl_lock_lock, pthread_in_use,
>> and the value of glthread_in use look like.
> Sorry to report still consistent failure mode, symptom, and location.
> Please see attached.
> Modified to run from below the non-standard SRC_DIR names, continue,
> step to get failure, bt, then quit.
Still building with mature gcc 10.2.0 x86_64-pc-cygwin-gcc-10:
$ shasum /usr/bin/{x86_64-pc-cygwin-,}gcc{,-10}
94da957d45d705e214bd3229f708c3e90fa92d00 */usr/bin/x86_64-pc-cygwin-gcc
94da957d45d705e214bd3229f708c3e90fa92d00 */usr/bin/x86_64-pc-cygwin-gcc-10
94da957d45d705e214bd3229f708c3e90fa92d00 */usr/bin/gcc
Rebuilt fatal-signal.c with gcc -E -o fatal-signal.i, and added some
diagnostic prints to gdb script, and added headers and comments to aid
memory.
Attached the relevant extract of fatal-signal.i(block_fata_signals) plus
the whole file, scripts, and log.
Please let me know what else would help us get to the bottom of this!
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
bison-segv-cygwin-64-fatal-signal-build.sh
(text/plain, 1.2 KB)
#!/bin/sh # bison-segv-cygwin-64-fatal-signal-build.sh - Cygwin 64 bison build gcc -E -o fatal-signal.i fatal-signal.c cd bison-3.8.1.27-dd6e.x86_64/build/ gcc -DEXEEXT=\".exe\" -I. -I./lib \ -I/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e \ -I/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib \ -DDEFAULT_TEXT_DOMAIN=\"bison-gnulib\" -ggdb -O2 -pipe -Wall \ -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong \ --param=ssp-buffer-size=4 \ -fdebug-prefix-map=.../bison/bison-3.8.1.27-dd6e.x86_64/build=/usr/src/debug/bison-3.8.1.27-dd6e \ -fdebug-prefix-map=.../bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e=/usr/src/debug/bison-3.8.1.27-dd6e \ -MT lib/libbison_a-fatal-signal.o -MD -MP -MF \ lib/.deps/libbison_a-fatal-signal.Tpo -E -o lib/fatal-signal.i \ `test -f 'lib/fatal-signal.c' || echo \ '/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/'`lib/fatal-signal.c # -c -o lib/libbison_a-fatal-signal.o `test -f 'lib/fatal-signal.c' || echo \ # '/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/'`lib/fatal-signal.c
bison-segv-cygwin-64-fatal-signal.i
(text/plain, 3.9 KB)
static sigset_t fatal_signal_set;
static void
do_init_fatal_signal_set (void)
{
size_t i;
init_fatal_signals ();
sigemptyset (&fatal_signal_set);
for (i = 0; i < ((sizeof(fatal_signals) / sizeof(fatal_signals[0])) - 1); i++)
if (fatal_signals[i] >= 0)
sigaddset (&fatal_signal_set, fatal_signals[i]);
}
static pthread_once_t fatal_signal_set_once =
# 299 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
{ (pthread_mutex_t)19, 0 }
# 299 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
;
static void
init_fatal_signal_set (void)
{
do { if (((pthread_mutexattr_gettype !=
# 304 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 304 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
|| (thrd_exit !=
# 304 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 304 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
)) ? pthread_once (&fatal_signal_set_once, do_init_fatal_signal_set) : (glthread_once_singlethreaded (&fatal_signal_set_once) ? (do_init_fatal_signal_set (), 0) : 0))) abort (); } while (0);
}
static pthread_mutex_t fatal_signals_block_lock =
# 309 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
(pthread_mutex_t)19
# 309 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
;
static unsigned int fatal_signals_block_counter = 0;
void
block_fatal_signals (void)
{
# 316 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
_Bool
# 316 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
mt = 1;
if (mt) do { if (((pthread_mutexattr_gettype !=
# 318 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 318 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
|| (thrd_exit !=
# 318 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 318 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
)) ? pthread_mutex_lock (&fatal_signals_block_lock) : 0)) abort (); } while (0);
if (fatal_signals_block_counter++ == 0)
{
init_fatal_signal_set ();
sigprocmask (
# 323 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
1
# 323 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
, &fatal_signal_set,
# 323 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 323 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
);
}
if (mt) do { if (((pthread_mutexattr_gettype !=
# 326 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 326 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
|| (thrd_exit !=
# 326 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c" 3 4
((void *)0)
# 326 "/home/BWI/src/cygwin/bison/bison-3.8.1.27-dd6e.x86_64/src/bison-3.8.1.27-dd6e/lib/fatal-signal.c"
)) ? pthread_mutex_unlock (&fatal_signals_block_lock) : 0)) abort (); } while (0);
}
bison-segv-cygwin-64-gdb.sh
(text/plain, 256 B)
#!/bin/sh
# bison-segv-cygwin-64-gdb.sh - Cygwin 64 bison segv gdb reproduction run
cd ${@:-bison-3.8.1-1}.x86_64/src/${@:-bison-3.8.1-1}/
gdb -d src -d lib -d lib/glthread -r \
-ex 'source -v ../../../bison-segv-cygwin-64.gdb' \
../../build/src/bison
bison-segv-cygwin-64.gdb
(text/plain, 1.2 KB)
#|/usr/bin/gdb -ex source -v # bison-segv-cygwin-64.gdb - Cygwin 64 bison segv reproduction # set up logging to product directory set pagination off set logging file ../../../bison-segv-cygwin-64-gdb.log set logging overwrite on set logging on # set up breaks on significant functions and lines within break main break lib/main.c:30 break output_skeleton break src/output.c:903 break src/output.c:785 break create_pipe_bidi break create_pipe break lib/spawn-pipe.c:475 break block_fatal_signals break lib/fatal-signal.c:316 break lib/fatal-signal.c:318 break lib/fatal-signal.c:320 # build bistromathic test run -o ../../build/examples/c/bistromathic/y.tab.c --defines -Werror -Wall,dangling-alias --report=all --no-lines examples/c/bistromathic/parse.y # add pthread lock break disabled break pthread_mutex_lock disable 13 # run until before segv continue continue continue continue continue continue continue continue continue # display function and variable addresses and values print &pthread_mutexattr_gettype print &thrd_exit print &pthread_mutex_lock print &fatal_signals_block_lock print fatal_signals_block_lock # enable pthread lock break enable 13 # segv step # demo smashed stack bt #bye q
bison-segv-cygwin-64-gdb.log
(text/plain, 5.2 KB)
+break main
Breakpoint 1 at 0x100464b60: file /usr/src/debug/bison-3.8.1.27-dd6e/src/main.c, line 65.
+break lib/main.c:30
Breakpoint 2 at 0x100464b78: file /usr/src/debug/bison-3.8.1.27-dd6e/src/main.c, line 67.
+break output_skeleton
Breakpoint 3 at 0x10041d140: file /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c, line 722.
+break src/output.c:903
Breakpoint 4 at 0x100422168: file /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c, line 903.
+break src/output.c:785
Breakpoint 5 at 0x10041d2a7: file /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c, line 785.
+break create_pipe_bidi
Breakpoint 6 at 0x100457960: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c, line 617.
+break create_pipe
Breakpoint 7 at 0x100457100: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c, line 147.
+break lib/spawn-pipe.c:475
Breakpoint 8 at 0x1004574ce: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c, line 475.
+break block_fatal_signals
Breakpoint 9 at 0x10044ea50: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c, line 315.
+break lib/fatal-signal.c:316
Breakpoint 10 at 0x10044ea54: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c, line 316.
+break lib/fatal-signal.c:318
Breakpoint 11 at 0x10044ea54: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c, line 318.
+break lib/fatal-signal.c:320
Breakpoint 12 at 0x10044ea74: file /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c, line 320.
+run -o ../../build/examples/c/bistromathic/y.tab.c --defines -Werror -Wall,dangling-alias --report=all --no-lines examples/c/bistromathic/parse.y
[New Thread 8184.0x1ee4]
[New Thread 8184.0x2a48]
[New Thread 8184.0x978]
[New Thread 8184.0x540]
Thread 1 "bison" hit Breakpoint 1, main (argc=9, argv=0xffffcb70) at /usr/src/debug/bison-3.8.1.27-dd6e/src/main.c:65
+break pthread_mutex_lock
Breakpoint 13 at 0x1801670f0: pthread_mutex_lock. (2 locations)
+disable 13
+continue
Thread 1 "bison" hit Breakpoint 2, main (argc=9, argv=0xffffcb70) at /usr/src/debug/bison-3.8.1.27-dd6e/src/main.c:67
+continue
Thread 1 "bison" hit Breakpoint 4, output () at /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c:903
903 output_skeleton ();
+continue
Thread 1 "bison" hit Breakpoint 3, output_skeleton () at /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c:722
722 {
+continue
Thread 1 "bison" hit Breakpoint 5, output_skeleton () at /usr/src/debug/bison-3.8.1.27-dd6e/src/output.c:785
785 pid = create_pipe_bidi ("m4", m4, argv,
+continue
Thread 1 "bison" hit Breakpoint 6, create_pipe_bidi (progname=progname@entry=0x10046c518 <__func__.2+600> "m4", prog_path=prog_path@entry=0x1004686b3 <argmatch_warning_docs+2291> "/usr/bin/m4", prog_argv=prog_argv@entry=0xffffc990, directory=directory@entry=0x0, null_stderr=null_stderr@entry=false, slave_process=slave_process@entry=true, exit_on_error=exit_on_error@entry=true, fd=fd@entry=0xffffc988) at /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c:617
617 {
+continue
Thread 1 "bison" hit Breakpoint 7, create_pipe (progname=progname@entry=0x10046c518 <__func__.2+600> "m4", prog_path=prog_path@entry=0x1004686b3 <argmatch_warning_docs+2291> "/usr/bin/m4", prog_argv=prog_argv@entry=0xffffc990, directory=directory@entry=0x0, pipe_stdin=pipe_stdin@entry=true, pipe_stdout=pipe_stdout@entry=true, prog_stdin=prog_stdin@entry=0x0, prog_stdout=prog_stdout@entry=0x0, null_stderr=null_stderr@entry=false, slave_process=slave_process@entry=true, exit_on_error=exit_on_error@entry=true, fd=fd@entry=0xffffc988) at /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c:147
147 {
+continue
Thread 1 "bison" hit Breakpoint 8, create_pipe (progname=progname@entry=0x10046c518 <__func__.2+600> "m4", prog_path=prog_path@entry=0x1004686b3 <argmatch_warning_docs+2291> "/usr/bin/m4", prog_argv=prog_argv@entry=0xffffc990, directory=directory@entry=0x0, pipe_stdin=pipe_stdin@entry=true, pipe_stdout=pipe_stdout@entry=true, prog_stdin=prog_stdin@entry=0x0, prog_stdout=prog_stdout@entry=0x0, null_stderr=null_stderr@entry=false, slave_process=slave_process@entry=true, exit_on_error=exit_on_error@entry=true, fd=fd@entry=0xffffc988) at /usr/src/debug/bison-3.8.1.27-dd6e/lib/spawn-pipe.c:475
475 block_fatal_signals ();
+continue
Thread 1 "bison" hit Breakpoint 9, block_fatal_signals () at /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c:315
315 {
+continue
Thread 1 "bison" hit Breakpoint 10, block_fatal_signals () at /usr/src/debug/bison-3.8.1.27-dd6e/lib/fatal-signal.c:318
318 if (mt) gl_lock_lock (fatal_signals_block_lock);
+print &pthread_mutexattr_gettype
$1 = (int (*)(const pthread_mutexattr_t *, int *)) 0x180167940 <pthread_mutexattr_gettype(pthread_mutexattr_t const*, int*)>
+print &thrd_exit
$2 = (void (*)(int)) 0x18018a3d0 <thrd_exit>
+print &pthread_mutex_lock
$3 = (int (*)(pthread_mutex_t *)) 0x1801670f0 <pthread_mutex_lock(pthread_mutex_t*)>
+print &fatal_signals_block_lock
$4 = (pthread_mutex_t *) 0x100466a50 <fatal_signals_block_lock>
+print fatal_signals_block_lock
$5 = (pthread_mutex_t) 0x13
+enable 13
+step
0x0000000100000000 in ?? ()
+bt
#0 0x0000000100000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
+q
A debugging session is active.
Inferior 1 [process 8184] will be killed.
Quit anyway? (y or n) [answered Y; input not from terminal]
fatal-signal.i
(text/plain, 101.3 KB) - not displayed