Subject: bug#15765: Crash in directory_files_internal

From: David Reitter <[email-masked]>
Date: Wed, 30 Oct 2013 18:06:39 -0400

This crash occurred after eval'ing the expression

(directory-files "~/Library/Logs/DiagnosticReports" t "Aquamacs.*.crash")

This directory exists, contains a few files, and I had eval'ed that just  a few second earlier without problems.

The bug does not reproduce.

Relevant lines in my dired.c:

> 267	      Lisp_Object fullname;
> 268	      ptrdiff_t nbytes = len + directory_nbytes + needsep;
> 269	      ptrdiff_t nchars;
> 
> 271	      fullname = make_uninit_multibyte_string (nbytes, nbytes);
> 272	      memcpy (SDATA (fullname), SDATA (directory),
> 		      directory_nbytes);
> 

Full crash log below.  The running binary was built based on Emacs head as per Oct 24, git refid 7c5015698c3, with some patches, but none to dired.c.

GNU Emacs 24.3.50.42 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)
 of 2013-10-27 on momo - Aquamacs Distribution 3.xdev
Copyright (C) 2013 Free Software Foundation, Inc.

Process:         Aquamacs [1704]
Path:            /Users/USER/*/Aquamacs.app/Contents/MacOS/Aquamacs
Identifier:      org.gnu.Aquamacs
Version:         3.xdev (3.x.1380382278)
Code Type:       X86-64 (Native)
Parent Process:  launchd [299]
Responsible:     Aquamacs [1704]
User ID:         505

Date/Time:       2013-10-30 17:50:04.080 -0400
OS Version:      Mac OS X 10.9 (13A598)
Report Version:  11
Anonymous UUID:  162C5D4F-C33C-0247-A290-60860F5062B3

Sleep/Wake UUID: 4558D8CE-D6E0-464A-A563-18E46864CB62

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000

VM Regions Near 0:
--> 
    __TEXT                 0000000100000000-0000000100200000 [ 2048K] r-x/rwx SM=COW  /Users/USER/*/Aquamacs.app/Contents/MacOS/Aquamacs

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff8ce46292 __kill + 10
1   org.gnu.Aquamacs              	0x00000001000b0fc1 terminate_due_to_signal + 145 (emacs.c:377)
2   org.gnu.Aquamacs              	0x00000001000ccb73 emacs_abort + 19
3   org.gnu.Aquamacs              	0x0000000100193fbb ns_term_shutdown + 123
4   org.gnu.Aquamacs              	0x00000001000b11c0 shut_down_emacs + 288 (emacs.c:1990)
5   org.gnu.Aquamacs              	0x00000001000b0f87 terminate_due_to_signal + 87 (emacs.c:362)
6   org.gnu.Aquamacs              	0x00000001000cf0ce handle_fatal_signal + 14
7   org.gnu.Aquamacs              	0x00000001000ce3b1 deliver_fatal_thread_signal + 129
8   libsystem_platform.dylib      	0x00007fff881ac5aa _sigtramp + 26
9   ???                           	0x000000010280303a 0 + 4336922682
10  org.gnu.Aquamacs              	0x00000001000ece5b directory_files_internal + 907 (dired.c:272)
11  org.gnu.Aquamacs              	0x000000010012643f eval_sub + 1839 (eval.c:2169)
12  org.gnu.Aquamacs              	0x00000001001291ca Feval + 106 (eval.c:1977)
13  org.gnu.Aquamacs              	0x0000000100129b09 Ffuncall + 761 (eval.c:2770)
14  org.gnu.Aquamacs              	0x000000010015fab9 exec_byte_code + 2169 (bytecode.c:919)
15  org.gnu.Aquamacs              	0x0000000100129a87 Ffuncall + 631 (eval.c:2728)
16  org.gnu.Aquamacs              	0x000000010015fab9 exec_byte_code + 2169 (bytecode.c:919)
17  org.gnu.Aquamacs              	0x0000000100129a87 Ffuncall + 631 (eval.c:2728)
18  org.gnu.Aquamacs              	0x0000000100124e2b Fcall_interactively + 5259 (callint.c:838)
19  org.gnu.Aquamacs              	0x0000000100129c10 Ffuncall + 1024 (eval.c:2796)
20  org.gnu.Aquamacs              	0x000000010015fab9 exec_byte_code + 2169 (bytecode.c:919)
21  org.gnu.Aquamacs              	0x0000000100129a87 Ffuncall + 631 (eval.c:2728)
22  org.gnu.Aquamacs              	0x000000010012a0ad call1 + 45 (eval.c:2588)
23  org.gnu.Aquamacs              	0x00000001000b4728 command_loop_1 + 1352 (keyboard.c:1565)
24  org.gnu.Aquamacs              	0x00000001001283c1 internal_condition_case + 257 (eval.c:1333)
25  org.gnu.Aquamacs              	0x00000001000c4dfe command_loop_2 + 62 (.lisp.h:2224)
26  org.gnu.Aquamacs              	0x0000000100127d6a internal_catch + 250 (eval.c:1099)
27  org.gnu.Aquamacs              	0x00000001000b386e recursive_edit_1 + 334 (keyboard.c:1138)
28  org.gnu.Aquamacs              	0x00000001000b39ba Frecursive_edit + 250 (keyboard.c:841)
29  org.gnu.Aquamacs              	0x00000001000b277b main + 5451 (emacs.c:1581)
30  libdyld.dylib                 	0x00007fff851e35fd start + 1