Bug 16580 – [REG 2.072.0-b1] spawnShell segfaults on macOS

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2016-10-03T11:21:00Z
Last change time
2016-10-09T15:38:11Z
Keywords
pull
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2016-10-03T11:21:45Z
The following code: import std.process; void main() { spawnShell("ls"); } Compiling and running that with DMD 2.072.0-b1 results in a segmentation fault. I suspect it's std.process.environ that returns null, due to environPtr not being initialized due to std_process_shared_static_this not being called [1]. Running inside a debugger: (lldb) target create "main" Current executable set to 'main' (x86_64). (lldb) r Process 6457 launched: '/Users/jacob/development/d/dlang/dmd/src/main' (x86_64) Process 6457 stopped * thread #1: tid = 0x293696, 0x0000000100046a8a main`D3std7process7environFNbNdNeZxPPa + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100046a8a main`D3std7process7environFNbNdNeZxPPa + 14 main`D3std7process7environFNbNdNeZxPPa: -> 0x100046a8a <+14>: movq (%rcx), %rax 0x100046a8d <+17>: popq %rbp 0x100046a8e <+18>: retq 0x100046a8f <+19>: nop (lldb) bt * thread #1: tid = 0x293696, 0x0000000100046a8a main`D3std7process7environFNbNdNeZxPPa + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x0000000100046a8a main`D3std7process7environFNbNdNeZxPPa + 14 frame #1: 0x0000000100047423 main`D3std7process9createEnvFxHAyaAyabZPxPa + 63 frame #2: 0x0000000100046d35 main`D3std7process16spawnProcessImplFNexAAaS3std5stdio4FileS3std5stdio4FileS3std5stdio4FilexHAyaAyaE3std7process6ConfigxAaZC3std7process3Pid + 677 frame #3: 0x00000001000479a8 main`D3std7process10spawnShellFNexAaS3std5stdio4FileS3std5stdio4FileS3std5stdio4FilexHAyaAyaE3std7process6ConfigxAaAyaZC3std7process3Pid + 320 frame #4: 0x00000001000018c3 main`_Dmain + 195 at process.d:1021 frame #5: 0x000000010001e45c main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40 frame #6: 0x000000010001e388 main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36 frame #7: 0x000000010001e401 main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45 frame #8: 0x000000010001e388 main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36 frame #9: 0x000000010001e2ee main`_d_run_main + 498 frame #10: 0x0000000100001982 main`main + 34 frame #11: 0x00007fff8a3d25ad libdyld.dylib`start + 1 frame #12: 0x00007fff8a3d25ad libdyld.dylib`start + 1 [1] https://github.com/dlang/phobos/blob/master/std/process.d#L135-L138
Comment #1 by doob — 2016-10-03T11:22:46Z
I should add that this will most likely affect any function inside std.process that calls "environ".
Comment #2 by code — 2016-10-04T23:52:27Z
Comment #3 by github-bugzilla — 2016-10-05T16:49:24Z
Commit pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ebbdf21a7ebc6730a3d5f170b934143bdb18a414 fix Issue 16580 - spawnShell segfaults on macOS - partially Revert "Merge pull request #4493 from schveiguy/fixcycles2" - recreate processinit (and import it from std.process) to call std.process shared ctor w/o creating a cycle - keep it separate from phobosinit to not drag std.encoding into any binary using std.process
Comment #4 by github-bugzilla — 2016-10-09T15:38:11Z
Commit pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/ebbdf21a7ebc6730a3d5f170b934143bdb18a414 fix Issue 16580 - spawnShell segfaults on macOS