Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dkorpel@live.nl --- Comment #1 from Dennis <dkorpel@live.nl> --- Is the segfault the result of compiling the code or running the resulting program? I can't reproduce this with dmd master on Linux, but it could be Windows only. -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #2 from ryuukk_ <ryuukk.dev@gmail.com> --- I should have been more precise in the report, i appologies The issue is when compiling with a custom `object.d` --- app.d enum Test {A, B, C} Test test = Test.A; extern(C) void main() { switch(test) { default: break; } } --- object.d module object; The following code compiles fine, but when you run the executable, it segfault dmd app.d object.d app.exe -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #3 from ryuukk_ <ryuukk.dev@gmail.com> --- It should provide an error: ``` `switch` runtime hook not found Have you created a custom `object` module and forgot to implement the hook? ``` -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #4 from Dennis <dkorpel@live.nl> --- (In reply to ryuukk_ from comment #3) > It should provide an error: > > ``` > `switch` runtime hook not found > Have you created a custom `object` module and forgot to implement the hook? > ``` I still cannot reproduce (on linux), and I don't get why you would expect a runtime hook for a switch statement over an integer. If I adapt your example to use final switch: ``` enum Test {A, B, C} Test test = Test.A; extern(C) void main() { final switch(test) { case Test.A: case Test.B: case Test.C: } } ``` I get: test_.d(7): Error: `object.__switch_error` not found. The current runtime does not support generating assert messages, or the runtime is corrupt. Which looks like what you want. Are you sure the segfault is because of the switch, or could it have to do with thread local storage not being initialized on Windows without druntime? -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #5 from ryuukk_ <ryuukk.dev@gmail.com> --- I don't know, i'm not knowledgeable enough on the matter Hence the need of a proper error message -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|regression |normal --- Comment #6 from Dennis <dkorpel@live.nl> --- (In reply to ryuukk_ from comment #5) > I don't know, i'm not knowledgeable enough on the matter Can you test if it still segfaults when you make it `__gshared Test test = Test.A;`? Otherwise I'll look into it on Windows later. > Hence the need of a proper error message Using a custom druntime is quite an advanced use case. This particular segfault could be fixed, but in general, don't expect the quality of error messages to be very good under these circumstances. -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #7 from ryuukk_ <ryuukk.dev@gmail.com> --- ``` enum Test {A, B, C} Test test = Test.A; extern(C) void main() { switch(test) { default: break; } } ``` without object.d, compiles fine, runs fine it doesn't initialize the runtime, so the issue must be something else? The moment i add `object.d` in the folder, the same code segfaults -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #8 from ryuukk_ <ryuukk.dev@gmail.com> --- And following your suggestion ``` enum Test {A, B, C} __gshared Test test = Test.A; extern(C) void main() { switch(test) { default: break; } } ``` Compiles fine, and run fines even with `object.d` I'll try to figure out how druntime initializes the tls on windows and copy the code -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #9 from ryuukk_ <ryuukk.dev@gmail.com> --- I struggle to understand druntime code If anyone can help me get rid of the segfault, that would be nice LDC doesn't complain, so that must be something specific to DMD -- |
August 29, 2022 [Issue 23310] Segfault on switch with global enum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23310 --- Comment #10 from ryuukk_ <ryuukk.dev@gmail.com> --- Progress, compiling with `dmd -g -m64 app.d && ./app.exe` (basically adding -g), now works and get rid of the segfault: ``` import core.stdc.stdio; enum Test {A, B, C} Test test = Test.A; extern(C) void main() { switch(test) { default: break; } printf("the end"); } ``` So there is a problem somewhere with DMD not doing something important.. -- |
Copyright © 1999-2021 by the D Language Foundation