Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of assert in destructor can lead to InvalidMemoryOperationError #248

Open
Geod24 opened this issue Jan 18, 2021 · 1 comment
Open

Comments

@Geod24
Copy link
Contributor

Geod24 commented Jan 18, 2021

Just got this backtrace:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x00000001002cc464 2521`onInvalidMemoryOperationError
    frame #1: 0x00000001002e997d 2521`_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl + 73
    frame #2: 0x00000001002e0d7e 2521`_D2gc4impl12conservativeQw14ConservativeGC6mallocMFNbmkxC8TypeInfoZPv + 62
    frame #3: 0x00000001002ec95f 2521`gc_malloc + 51
    frame #4: 0x00000001002f34fb 2521`_d_newclass + 147
    frame #5: 0x00000001002cc62f 2521`_d_assert_msg + 107
    frame #6: 0x00000001000b0d52 2521`_D4vibe4core14connectionpool__T16LockedConnectionTCQBx4http6client10HTTPClientZQBw6__dtorMFNfZv + 178
    frame #7: 0x00000001000b0138 2521`_D4vibe4http6client18HTTPClientResponse11__fieldDtorMFNeZv + 108
    frame #8: 0x00000001000b015a 2521`_D4vibe4http6client18HTTPClientResponse10__aggrDtorMFNeZv + 30
    frame #9: 0x00000001002f5164 2521`rt_finalize2 + 112
    frame #10: 0x00000001002f529f 2521`rt_finalizeFromGC + 39
    frame #11: 0x00000001002e4de8 2521`_D2gc4impl12conservativeQw3Gcx5sweepMFNbZm + 1816
    frame #12: 0x00000001002e56a1 2521`_D2gc4impl12conservativeQw3Gcx11fullcollectMFNbbZm + 921
    frame #13: 0x00000001002ea2ee 2521`_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs18fullCollectNoStackMFNbZ2goFNbPSQEaQEaQDyQEj3GcxZmTQvZQDfMFNbKQBgZm + 78
    frame #14: 0x00000001002e22f4 2521`_D2gc4impl12conservativeQw14ConservativeGC18fullCollectNoStackMFNbZv + 28
    frame #15: 0x00000001002e228a 2521`_D2gc4impl12conservativeQw14ConservativeGC14collectNoStackMFNbZv + 26
    frame #16: 0x00000001002ec7f9 2521`gc_term + 133
    frame #17: 0x00000001002f177f 2521`rt_term + 83
    frame #18: 0x00000001002f1eff 2521`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 207
    frame #19: 0x00000001002f1ddc 2521`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ7tryExecMFMDFZvZv + 36
    frame #20: 0x00000001002f1d38 2521`_d_run_main2 + 656
    frame #21: 0x00000001002f1a92 2521`_d_run_main + 190
    frame #22: 0x0000000100002b06 2521`main at entrypoint.d:29
    frame #23: 0x00007fff2039b621 libdyld.dylib`start + 1

Hindsight is 20/20, but don't use assert in dtors:
https://github.com/dlang/druntime/blob/f94e816c1dd229cbb133085a6fc41d1bd6d45594/src/core/exception.d#L447

Turns out it's already filled: https://issues.dlang.org/show_bug.cgi?id=7349

@Geod24
Copy link
Contributor Author

Geod24 commented Jun 1, 2021

v2.097.0 will come with a fix for this, leaving open for now as it's not yet released (and until it's the oldest supported release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant