Subject: bug#25265: make-thread crashes in OS X 10.6

From: [email-masked] (Charles A. Roelli)
Date: Sat, 24 Dec 2016 12:06:45 +0100

Running Emacs -Q on the latest commit (e36a3882),

M-: (make-thread (lambda () "string"))

appears to hang Emacs immediately.

Here's the output of "bt" and "thread apply all bt":

(gdb) bt
#0  0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
#1  0x00000001000cd2b6 in handle_sigsegv (sig=1884515520, siginfo=0x70, arg=0x100621fe8) at sysdep.c:1800
#2  <signal handler called>
#3  0x000000010012d7dc in unbind_to (count=Cannot access memory at address 0x0
) at eval.c:3499
#4  0x00000001001af2c4 in ns_select (nfds=1606412240, readfds=0x7fff5fbfeb80, writefds=0x7fff5fbfeb00, exceptfds=0x7fff5fbfe7d0, timeout=0x7fff5fbfe7d0, sigmask=0x7fff5fbfe7d0) at nsterm.m:4210
#5  0x000000010018d210 in really_call_select (arg=0x7fff5fbfe840) at thread.c:520
#6  0x000000010010ca06 in flush_stack_call_func (func=0, arg=0x5fbfeae800000000) at alloc.c:5137
#7  0x000000010018d1a7 in thread_select (func=0x5fbfeae800000000, max_fds=0, rfds=0x7fff5fbfe828, wfds=0x0, efds=0x7fff5fbfeae8, timeout=0x0, sigmask=0x0) at thread.c:543
#8  0x00000001001752ad in wait_reading_process_output (time_limit=140734799801728, nsecs=0, read_kbd=1606413696, wait_for_cell=140734799801728, wait_proc=0x7fff5fbfed80, just_wait_proc=0, do_display=true) at process.c:5344
#9  0x000000010000471a in sit_for (timeout=30, display_option=0, reading=false) at dispnew.c:5763
#10 0x00000001000bf6f2 in read_char (commandflag=1606414816, map=140734799802848, prev_event=4294967295, used_mouse_menu=0x7fff5fbff1e0, end_time=0x7fff5fbff1e0) at keyboard.c:2725
#11 0x00000001000c26ee in read_key_sequence () at keyboard.c:2599
#12 0x00000001000c4afd in command_loop_1 () at keyboard.c:1373
#13 0x000000010012e2a4 in internal_condition_case (bfun=0x1000c3690 <command_loop_1>, handlers=499667000, hfun=0x7fff5fbff500) at eval.c:1334
#14 0x00000001000c4d50 in command_loop_2 (ignore=499667000) at keyboard.c:1115
#15 0x000000010012e32f in internal_catch (tag=499667000, func=0x1000c4d20 <command_loop_2>, arg=499667000) at eval.c:1100
#16 0x00000001000c4ec6 in command_loop [inlined] () at /Code/emacs-build-threads/src/keyboard.c:1094
#17 0x00000001000c4ec6 in recursive_edit_1 () at keyboard.c:1800
#18 0x00000001000b60df in Frecursive_edit () at keyboard.c:771
#19 0x00000001000b2993 in main (argc=4002, argv=0x7fff5fbff780) at emacs.c:1691

Program received signal SIGSTOP, Stopped (signal).
0x00007fff838f8430 in malloc_gdb_po_unsafe ()
Unsafe to run code: malloc zone lock is held for some zone..
Canceling call as the malloc lock is held so it isn't safe to call the runtime.
Issue the command:
    set objc-non-blocking-mode off
to override this check if you are sure your call doesn't use the malloc libraries or the ObjC runtime.
(gdb) set objc-non-blocking-mode off
(gdb) continue
Continuing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000040
0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
1767	  char *bot = stack_bottom;

(gdb) thread apply all bt

Thread 4 (process 17249):
#0  0x00007fff8385f932 in select$DARWIN_EXTSN ()
#1  0x000000010019fa79 in -[EmacsApp fd_handler:] (self=0x8, _cmd=0x102380ad0, unused=0x0) at nsterm.m:5512
#2  0x00007fff89967114 in __NSThread__main__ ()
#3  0x00007fff83854fd6 in _pthread_start ()
#4  0x00007fff83854e89 in thread_start ()

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000040
[Switching to process 17249 thread 0x903]
0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
1767	  char *bot = stack_bottom;
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (backtrace_top) will be abandoned.

Thread 3 (process 17249):
#0  0x00007fff8385f932 in select$DARWIN_EXTSN ()
#1  0x0000000100ad3983 in g_poll (fds=0x101a37ce0, nfds=28839360, timeout=0) at gpoll.c:385
#2  0x0000000100ac6dfd in g_main_context_iterate () at gmain.c:3198
#3  0x0000000100ac6ee2 in g_main_context_iteration (context=0x6, may_block=1) at gmain.c:3869
#4  0x0000000100ac5e71 in glib_worker_main (data=0x6) at gmain.c:5622
#5  0x0000000100aeb75a in g_thread_proxy (data=0x6) at gthread.c:764
#6  0x00007fff83854fd6 in _pthread_start ()
#7  0x00007fff83854e89 in thread_start ()

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000040
[Switching to process 17249 thread 0x903]
0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
1767	  char *bot = stack_bottom;
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (backtrace_top) will be abandoned.

Thread 2 (process 17249):
#0  0x00007fff8383544b in pthread_workqueue_additem_np ()
#1  0x00007fff83834d0a in _dispatch_queue_wakeup_global ()
#2  0x00007fff83834c28 in _dispatch_wakeup ()
#3  0x00007fff8394fd3f in _dispatch_queue_push_list_slow ()
#4  0x00007fff83834c9c in _dispatch_wakeup ()
#5  0x00007fff8394fd3f in _dispatch_queue_push_list_slow ()
#6  0x00007fff83834c9c in _dispatch_wakeup ()
#7  0x00007fff83836ebe in _dispatch_run_timers ()
#8  0x00007fff83836aa2 in _dispatch_mgr_invoke ()
#9  0x00007fff838367b4 in _dispatch_queue_invoke ()
#10 0x00007fff838362de in _dispatch_worker_thread2 ()
#11 0x00007fff83835c08 in _pthread_wqthread ()
#12 0x00007fff83835aa5 in start_wqthread ()

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000070
backtrace_top () at eval.c:202
202	  while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE)
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (backtrace_top) will be abandoned.

Thread 1 (process 17249):
#0  0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
#1  0x00000001000cd2b6 in handle_sigsegv (sig=1884515520, siginfo=0x70, arg=0x100621fe8) at sysdep.c:1800
#2  <signal handler called>
#3  0x000000010012d7dc in unbind_to (count=Cannot access memory at address 0x0
) at eval.c:3499
#4  0x00000001001af2c4 in ns_select (nfds=1606412240, readfds=0x7fff5fbfeb80, writefds=0x7fff5fbfeb00, exceptfds=0x7fff5fbfe7d0, timeout=0x7fff5fbfe7d0, sigmask=0x7fff5fbfe7d0) at nsterm.m:4210
#5  0x000000010018d210 in really_call_select (arg=0x7fff5fbfe840) at thread.c:520
#6  0x000000010010ca06 in flush_stack_call_func (func=0, arg=0x5fbfeae800000000) at alloc.c:5137
#7  0x000000010018d1a7 in thread_select (func=0x5fbfeae800000000, max_fds=0, rfds=0x7fff5fbfe828, wfds=0x0, efds=0x7fff5fbfeae8, timeout=0x0, sigmask=0x0) at thread.c:543
#8  0x00000001001752ad in wait_reading_process_output (time_limit=140734799801728, nsecs=0, read_kbd=1606413696, wait_for_cell=140734799801728, wait_proc=0x7fff5fbfed80, just_wait_proc=0, do_display=true) at process.c:5344
#9  0x000000010000471a in sit_for (timeout=30, display_option=0, reading=false) at dispnew.c:5763
#10 0x00000001000bf6f2 in read_char (commandflag=1606414816, map=140734799802848, prev_event=4294967295, used_mouse_menu=0x7fff5fbff1e0, end_time=0x7fff5fbff1e0) at keyboard.c:2725
#11 0x00000001000c26ee in read_key_sequence () at keyboard.c:2599
#12 0x00000001000c4afd in command_loop_1 () at keyboard.c:1373
#13 0x000000010012e2a4 in internal_condition_case (bfun=0x1000c3690 <command_loop_1>, handlers=499667000, hfun=0x7fff5fbff500) at eval.c:1334
#14 0x00000001000c4d50 in command_loop_2 (ignore=499667000) at keyboard.c:1115
#15 0x000000010012e32f in internal_catch (tag=499667000, func=0x1000c4d20 <command_loop_2>, arg=499667000) at eval.c:1100
#16 0x00000001000c4ec6 in command_loop [inlined] () at /Code/emacs-build-threads/src/keyboard.c:1094
#17 0x00000001000c4ec6 in recursive_edit_1 () at keyboard.c:1800
#18 0x00000001000b60df in Frecursive_edit () at keyboard.c:771
#19 0x00000001000b2993 in main (argc=4002, argv=0x7fff5fbff780) at emacs.c:1691

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000070
backtrace_top () at eval.c:202
202	  while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE)
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (backtrace_top) will be abandoned.
(gdb) bt
#0  backtrace_top () at eval.c:202
#1  <function called from gdb>
#2  0x00000001000cd2b6 in stack_overflow [inlined] () at /Code/emacs-build-threads/src/sysdep.c:1767
#3  0x00000001000cd2b6 in handle_sigsegv (sig=1884515520, siginfo=0x70, arg=0x100621fe8) at sysdep.c:202
#4  <signal handler called>
#5  0x000000010012d7dc in unbind_to (count=Cannot access memory at address 0x0
) at eval.c:3499
#6  0x00000001001af2c4 in ns_select (nfds=1606412240, readfds=0x7fff5fbfeb80, writefds=0x7fff5fbfeb00, exceptfds=0x7fff5fbfe7d0, timeout=0x7fff5fbfe7d0, sigmask=0x7fff5fbfe7d0) at nsterm.m:4210
#7  0x000000010018d210 in really_call_select (arg=0x7fff5fbfe840) at thread.c:520
#8  0x000000010010ca06 in flush_stack_call_func (func=0, arg=0x5fbfeae800000000) at alloc.c:5137
#9  0x000000010018d1a7 in thread_select (func=0x5fbfeae800000000, max_fds=0, rfds=0x7fff5fbfe828, wfds=0x0, efds=0x7fff5fbfeae8, timeout=0x0, sigmask=0x0) at thread.c:543
#10 0x00000001001752ad in wait_reading_process_output (time_limit=140734799801728, nsecs=0, read_kbd=1606413696, wait_for_cell=140734799801728, wait_proc=0x7fff5fbfed80, just_wait_proc=0, do_display=true) at process.c:5344
#11 0x000000010000471a in sit_for (timeout=30, display_option=0, reading=false) at dispnew.c:5763
#12 0x00000001000bf6f2 in read_char (commandflag=1606414816, map=140734799802848, prev_event=4294967295, used_mouse_menu=0x7fff5fbff1e0, end_time=0x7fff5fbff1e0) at keyboard.c:2725
#13 0x00000001000c26ee in read_key_sequence () at keyboard.c:2599
#14 0x00000001000c4afd in command_loop_1 () at keyboard.c:1373
#15 0x000000010012e2a4 in internal_condition_case (bfun=0x1000c3690 <command_loop_1>, handlers=499667000, hfun=0x7fff5fbff500) at eval.c:1334
#16 0x00000001000c4d50 in command_loop_2 (ignore=499667000) at keyboard.c:1115
#17 0x000000010012e32f in internal_catch (tag=499667000, func=0x1000c4d20 <command_loop_2>, arg=499667000) at eval.c:1100
#18 0x00000001000c4ec6 in command_loop [inlined] () at /Code/emacs-build-threads/src/keyboard.c:1094
#19 0x00000001000c4ec6 in recursive_edit_1 () at keyboard.c:202
#20 0x00000001000b60df in Frecursive_edit () at keyboard.c:771
#21 0x00000001000b2993 in main (argc=4002, argv=0x7fff5fbff780) at emacs.c:1691

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000070
[Switching to process 17249 thread 0x1703]
backtrace_top () at eval.c:202
202	  while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE)
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (backtrace_top) will be abandoned.

=========
===END===
=========

Thanks,
Charles