Bug 22025 – Exception within a delegate can't be thrown.

Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2021-06-15T09:53:03Z
Last change time
2021-11-22T14:14:15Z
Keywords
backend
Assigned to
No Owner
Creator
Heromyth

Comments

Comment #0 by bitworld — 2021-06-15T09:53:03Z
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 ```
Comment #1 by pro.mathias.lang — 2021-06-16T05:23:20Z
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
Comment #2 by pro.mathias.lang — 2021-06-16T05:24:39Z
Note that this is yet another DMD-specific bug, compiling with LDC works.
Comment #3 by ibuclaw — 2021-07-23T19:54:10Z
Probably a duplicate of issue 21919
Comment #4 by ibuclaw — 2021-11-07T23:40:07Z
PR submitted, please check this again. https://github.com/dlang/druntime/pull/3612
Comment #5 by ibuclaw — 2021-11-22T14:14:15Z
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 ***