{"action":"created","issue":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/2395","repository_url":"https://api.github.com/repos/ldc-developers/ldc","labels_url":"https://api.github.com/repos/ldc-developers/ldc/issues/2395/labels{/name}","comments_url":"https://api.github.com/repos/ldc-developers/ldc/issues/2395/comments","events_url":"https://api.github.com/repos/ldc-developers/ldc/issues/2395/events","html_url":"https://github.com/ldc-developers/ldc/issues/2395","id":269321433,"number":2395,"title":"Crash when calling C exit() with in function holding object that wraps C code in array","user":{"login":"ximion","id":417468,"avatar_url":"https://avatars0.githubusercontent.com/u/417468?v=4","gravatar_id":"","url":"https://api.github.com/users/ximion","html_url":"https://github.com/ximion","followers_url":"https://api.github.com/users/ximion/followers","following_url":"https://api.github.com/users/ximion/following{/other_user}","gists_url":"https://api.github.com/users/ximion/gists{/gist_id}","starred_url":"https://api.github.com/users/ximion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ximion/subscriptions","organizations_url":"https://api.github.com/users/ximion/orgs","repos_url":"https://api.github.com/users/ximion/repos","events_url":"https://api.github.com/users/ximion/events{/privacy}","received_events_url":"https://api.github.com/users/ximion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-28T14:25:33Z","updated_at":"2017-10-28T15:29:26Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hey!\r\nSorry for the convoluted title ;-)\r\nI am observing a bug in LDC that leads to a crash when the program ends using the vibe-d-postgresql library.\r\nThe culprit appears to be calling `exit()` manually.\r\nBacktrace:\r\n```\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n0x00007ffff5aeff94 in ERR_clear_error () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1\r\n(gdb) bt full\r\n#0  0x00007ffff5aeff94 in ERR_clear_error () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1\r\nNo symbol table info available.\r\n#1  0x00007ffff7bb6c9f in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5\r\nNo symbol table info available.\r\n#2  0x00007ffff7ba86d7 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5\r\nNo symbol table info available.\r\n#3  0x00007ffff7b9e3e5 in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5\r\nNo symbol table info available.\r\n#4  0x00007ffff7b9e406 in PQfinish () from /usr/lib/x86_64-linux-gnu/libpq.so.5\r\nNo symbol table info available.\r\n#5  0x00005555555ce905 in dpq2.connection.Connection.~this() (this=0x7ffff7ea06c0)\r\n    at /srv/playground/dust/lkcrash/../../../.dub/packages/dpq2-0.6.24/dpq2/src/dpq2/connection.d:67\r\nNo locals.\r\n#6  0x00007ffff6c2252e in rt_finalize2 () from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#7  0x00007ffff6c06085 in gc.impl.conservative.gc.SmallObjectPool.runFinalizers(const(void[])) ()\r\n   from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#8  0x00007ffff6c04cdb in gc.impl.conservative.gc.Gcx.runFinalizers(const(void[])) ()\r\n   from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#9  0x00007ffff6c04d7f in gc.impl.conservative.gc.ConservativeGC.runLocked!(gc.impl.conservative.gc.ConservativeGC.runFinalizers(const(void[])).go(gc.impl.conservative.gc.Gcx*, const(void[])), gc.impl.conservative.gc.otherTime, gc.impl.conservative.gc.numOthers, gc.impl.conservative.gc.Gcx*, const(void[])).runLocked(ref gc.impl.conservative.gc.Gcx*, ref const(void[])) ()\r\n   from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#10 0x00007ffff6c05c13 in _DThn16_2gc4impl12conservative2gc14ConservativeGC13runFinalizersMFNbxAvZv ()\r\n   from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#11 0x00007ffff6c29e6c in _d_dso_registry () from /usr/lib/x86_64-linux-gnu/libdruntime-ldc.so.74\r\nNo symbol table info available.\r\n#12 0x00005555555a4882 in ldc.register_dso ()\r\nNo symbol table info available.\r\n#13 0x0000555555696205 in ldc.dso_dtor.4vibe8internal4meta6traits ()\r\nNo symbol table info available.\r\n#14 0x00007ffff7de8e6a in _dl_fini () at dl-fini.c:235\r\n        array = 0x5555558d3eb0\r\n        i = 35\r\n        l = 0x7ffff7ffe170\r\n        maps = 0x7fffffffdb00\r\n        i = <optimized out>\r\n        l = <optimized out>\r\n        nmaps = <optimized out>\r\n        nloaded = <optimized out>\r\n        ns = 0\r\n        do_audit = <optimized out>\r\n        __PRETTY_FUNCTION__ = \"_dl_fini\"\r\n#15 0x00007ffff60d3940 in __run_exit_handlers (status=0, listp=0x7ffff64355d8 <__exit_funcs>, \r\n    run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:83\r\n        atfct = <optimized out>\r\n        onfct = <optimized out>\r\n        cxafct = <optimized out>\r\n        f = <optimized out>\r\n#16 0x00007ffff60d399a in __GI_exit (status=<optimized out>) at exit.c:105\r\nNo locals.\r\n#17 0x00005555555df943 in D main () at /srv/playground/dust/lkcrash/source/app.d:77\r\n        tools = {0x7ffff7e9f3f0}\r\n```\r\nLDC version:\r\n```\r\nLDC - the LLVM D compiler (1.4.0):\r\n  based on DMD v2.074.1 and LLVM 5.0.0\r\n  built with LDC - the LLVM D compiler (0.17.5)\r\n  Default target: x86_64-pc-linux-gnu\r\n  Host CPU: haswell\r\n  http://dlang.org - http://wiki.dlang.org/LDC\r\n```\r\nReduced example code: [crash_mintest.tar.gz](https://github.com/ldc-developers/ldc/files/1424313/crash_mintest.tar.gz)\r\n\r\nI tried to reproduce this bug with DMD, and this crash doesn't seem to happen with the latest stable DMD compiler (DMD64 D Compiler v2.076.1)\r\n\r\nUnfortunately to test the minimal example, you'll have to create a dummy Postgres database with credentials, because this crash only appears if a connection has been created by vibe-d-postgresql.\r\n\r\nCheers,\r\n    Matthias\r\n"},"comment":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/comments/340199139","html_url":"https://github.com/ldc-developers/ldc/issues/2395#issuecomment-340199139","issue_url":"https://api.github.com/repos/ldc-developers/ldc/issues/2395","id":340199139,"user":{"login":"ximion","id":417468,"avatar_url":"https://avatars0.githubusercontent.com/u/417468?v=4","gravatar_id":"","url":"https://api.github.com/users/ximion","html_url":"https://github.com/ximion","followers_url":"https://api.github.com/users/ximion/followers","following_url":"https://api.github.com/users/ximion/following{/other_user}","gists_url":"https://api.github.com/users/ximion/gists{/gist_id}","starred_url":"https://api.github.com/users/ximion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ximion/subscriptions","organizations_url":"https://api.github.com/users/ximion/orgs","repos_url":"https://api.github.com/users/ximion/repos","events_url":"https://api.github.com/users/ximion/events{/privacy}","received_events_url":"https://api.github.com/users/ximion/received_events","type":"User","site_admin":false},"created_at":"2017-10-28T15:29:26Z","updated_at":"2017-10-28T15:29:26Z","author_association":"CONTRIBUTOR","body":"The place where it crashes is in the libcrypto library that is used by the postgres library. When I first encounterest this crash I thought it was my or vibe-d-postgresql's fault, but there is no way `PQfinish ` could be called on an invalid pointer or any of the usual stuff for segfaults happening (unless I overlooked something, but I really don't think so, especially since this works fine with DMD...)."}}
{"actor":{"display_login":"ximion"}}