Bug 22897 – importC: segfault calling forward-declared static function through pointer

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2022-03-18T05:02:20Z
Last change time
2022-03-20T07:26:15Z
Keywords
ImportC, pull, wrong-code
Assigned to
No Owner
Creator
duser

Attachments

IDFilenameSummaryContent-TypeSize
1843dmd_verbose.logdmd verbose logtext/plain3802

Comments

Comment #0 by duser — 2022-03-18T05:02:20Z
static void other(void); int main() { void (*fn)(void) = other; fn(); return 0; } static void other(void) { } happens on linux but not windows - direct calls work but taking the address gives an invalid pointer - only functions that come before the body of other() are affected
Comment #1 by bugzilla — 2022-03-20T03:46:10Z
I have not been able to replicate this issue on Linux.
Comment #2 by dlang-bot — 2022-03-20T03:50:44Z
@WalterBright created dlang/dmd pull request #13846 "fix Issue 22897 - importC: segfault calling forward-declared static f…" fixing this issue: - fix Issue 22897 - importC: segfault calling forward-declared static function through pointer https://github.com/dlang/dmd/pull/13846
Comment #3 by duser — 2022-03-20T04:10:32Z
Created attachment 1843 dmd verbose log are you compiling with -fPIC? it's in the default dmd.conf but i noticed removing it makes the crash go away i've attached the log from compiling the test snippet with "dmd -v test.c" in case there are any differences with yours
Comment #4 by dlang-bot — 2022-03-20T07:26:15Z
dlang/dmd pull request #13846 "fix Issue 22897 - importC: segfault calling forward-declared static f…" was merged into master: - d61f2f8460fec09b9a0e4a112404fbe42a701195 by Walter Bright: fix Issue 22897 - importC: segfault calling forward-declared static function through pointer https://github.com/dlang/dmd/pull/13846