When throwing an exception within a delegate, the app crashed. My OS is macOS Big Sur 11.4. It's OK in Linux. Tested compilers: DMD 2.088.1 - 2.097.0 Here is the sample: ``` void main() { int factor = 2; auto ex2a = new Promise!int(); auto ex2b = ex2a.then!(async!((int x) { if(x == 30) { // It's a bug in macOS Big Sur 11.4 throw new Exception("throw an exception!"); } return x * factor; })); ex2a.resolve(30); // throw an exception! } ``` The steps are here for reproducing this bug: ``` $ git clone https://github.com/Heromyth/future.git $ cd future $ dub run ```
Reproduced. ``` (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x1003c7c00) * frame #0: 0x00007fff2032f50c libsystem_pthread.dylib`___chkstk_darwin + 96 frame #1: 0x00007fff2032f4ac libsystem_pthread.dylib`thread_start + 20 frame #2: 0x00007fff2a4adb2d libunwind.dylib`libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getInfoFromDwarfSection(unsigned long, libunwind::UnwindInfoSections const&, unsigned int) + 191 frame #3: 0x00007fff2a4ada01 libunwind.dylib`libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::setInfoBasedOnIPRegister(bool) + 999 frame #4: 0x00007fff2a4afec9 libunwind.dylib`libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step() + 461 frame #5: 0x00007fff2a4b1a18 libunwind.dylib`_Unwind_RaiseException + 189 frame #6: 0x000000010005c0fd future`_d_throwdwarf + 185 frame #7: 0x0000000100001e9d future`_D4mainQfFZ9__lambda3MFNaNfiZi(__capture=0x0000000100600000, x=30) at object.d:2478 frame #8: 0x0000000100025aea future`_D7toolkit7promise__T9asyncImplTDFNaNfiZiTiZQxFQpiZ9__lambda6MFZv(__capture=0x0000000100604030) at promise.d:446 frame #9: 0x0000000100058d79 future`_D4core6thread7context8Callable6opCallMFZv + 41 frame #10: 0x0000000100055227 future`fiber_entryPoint + 99 ``` I've been seeing this issue for a while: https://github.com/dlang/dub/issues/2120
Note that this is yet another DMD-specific bug, compiling with LDC works.
Probably a duplicate of issue 21919
PR submitted, please check this again. https://github.com/dlang/druntime/pull/3612
Library issue, not compiler. Tested on 11.6, and output of result is the same as Linux, so this is a indeed a duplicate. *** This issue has been marked as a duplicate of issue 21919 ***