Skip to content

Instantly share code, notes, and snippets.

@saitoha
Last active August 29, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saitoha/64cd72320a09b9d299ae1d4e059f49f4 to your computer and use it in GitHub Desktop.
Save saitoha/64cd72320a09b9d299ae1d4e059f49f4 to your computer and use it in GitHub Desktop.
workaround for bash 4.3 segfault problem on i686-pc-cygwin
diff --git a/jobs.c b/jobs.c
index b6e59eb..9ccf232 100644
--- a/jobs.c
+++ b/jobs.c
@@ -2548,6 +2548,9 @@ itrace("wait_for: blocking wait for %d returns %d child = %p", (int)pid, r, chil
/* Restore the original SIGINT signal handler before we return. */
restore_sigint_handler ();
+ if (!child)
+ goto wait_for_return;
+
/* The exit state of the command is either the termination state of the
child, or the termination state of the job. If a job, the status
of the last child in the pipeline is the significant one. If the command
$ uname -a
CYGWIN_NT-6.1 HSAITO848E 2.5.2(0.297/5/3) 2016-06-23 14:27 i686 Cygwin
$ /bin/bash --version
GNU bash, version 4.3.46(6)-release (i686-pc-cygwin)
$ /bin/bash
$ while true; do echo | read -n 1; done
^C^C^C^C^C <--- quit with Ctrl+C
$ echo <-- bash died!!
*** starting debugger for pid 1952, tid 5292
$ gdb bash bash.exe.core
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bash...done.
warning: core file may not match specified executable file.
[New Thread 0x1]
[New process 1]
[New process 1]
[New process 1]
[New process 1]
#0 add_process (pid=-1, name=0xffffffff <error: Cannot access memory at address 0xffffffff>) at jobs.c:1129
1129 t->running = PS_RUNNING;
[Current thread is 1 (Thread 0x1)]
(gdb) bt
#0 add_process (pid=-1, name=0xffffffff <error: Cannot access memory at address 0xffffffff>) at jobs.c:1129
#1 make_child (command=0xffffffff <error: Cannot access memory at address 0xffffffff>, async_p=0) at jobs.c:1896
#2 0x00415d59 in execute_connection (fds_to_close=0x20076200, pipe_out=4288714, pipe_in=2280584, asynchronous=0, command=0x1)
at execute_cmd.c:2451
#3 execute_command_internal (command=0x1, asynchronous=0, pipe_in=2280584, pipe_out=4288714, fds_to_close=0x20076200)
at execute_cmd.c:945
#4 0x20070e10 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment