digitalmars.D - Compiling with -profile=gc makes program crash - why?
- Ivan Kazmenko (43/43) Apr 20 2016 I'm trying to use DMD option "-profile=gc". With this option,
- Ivan Kazmenko (3/8) Apr 20 2016 Ouch, meant to post to D.learn. Sorry!
- tcak (4/13) Apr 21 2016 You are using "spawn". So it is a multithreaded program.
- Ivan Kazmenko (6/10) Apr 21 2016 Humm, when I searched whether it should work, I only found a
- Ivan Kazmenko (3/8) Apr 21 2016 Issue created:
- Walter Bright (2/4) Apr 21 2016 Thank you.
- jmh530 (4/7) Apr 21 2016 Then it would probably help if that is mentioned on this page
I'm trying to use DMD option "-profile=gc". With this option, the following simple program crashes with 2.071.0 down to 2.069.0 but still works on 2.068.2. The command line is "dmd -g -profile=gc prfail1.d" on Windows (compiled to 32-bit by default). -----prfail1.d----- import std.concurrency; void someWork () {auto x = [1];} void main () {spawn (&someWork);} ----- The crash happens almost always, >90% of runs of the compiled program. Here's the error output: ----- object.Error (0): Access Violation ---------------- 0x00409651 in nothrow int rt.profilegc._staticDtor407().__foreachbody2(ref immutable(char)[], ref rt.profilegc.Entry) 0x00409986 in void rt.profilegc.__moddtor() 0x00427444 in __threadstartex 0x77869ED2 in RtlInitializeExceptionChain 0x77869EA5 in RtlInitializeExceptionChain ----- With added "-m64", it just crashes and does not print anything. Am I doing something wrong, or is it a 2.069 regression? Interestingly, a modified version does not crash: -----prfail2.d----- import std.concurrency; void someWork () {auto x = [1];} void main () {spawn (&someWork); someWork ();} ----- I was curious if this guarantees that the spawned thread finishes before the main thread, but the third example, also crashing, seems to contradict that: -----prfail3.d----- import std.concurrency; void someWork () {auto x = [1];} void main () { spawnLinked (&someWork); try {receive ((int) {});} catch (LinkTerminated o) {} } ----- Ivan Kazmenko.
Apr 20 2016
On Wednesday, 20 April 2016 at 22:27:36 UTC, Ivan Kazmenko wrote:I'm trying to use DMD option "-profile=gc". With this option, the following simple program crashes with 2.071.0 down to 2.069.0 but still works on 2.068.2. The command line is "dmd -g -profile=gc prfail1.d" on Windows (compiled to 32-bit by default).Ouch, meant to post to D.learn. Sorry! Well, perhaps no point in reposting now.
Apr 20 2016
On Wednesday, 20 April 2016 at 22:31:31 UTC, Ivan Kazmenko wrote:On Wednesday, 20 April 2016 at 22:27:36 UTC, Ivan Kazmenko wrote:You are using "spawn". So it is a multithreaded program. -profile=gc doesn't work with multithreadd programs. Always creates problems.I'm trying to use DMD option "-profile=gc". With this option, the following simple program crashes with 2.071.0 down to 2.069.0 but still works on 2.068.2. The command line is "dmd -g -profile=gc prfail1.d" on Windows (compiled to 32-bit by default).Ouch, meant to post to D.learn. Sorry! Well, perhaps no point in reposting now.
Apr 21 2016
On Thursday, 21 April 2016 at 09:23:26 UTC, tcak wrote:I'm trying to use DMD option "-profile=gc".You are using "spawn". So it is a multithreaded program. -profile=gc doesn't work with multithreadd programs. Always creates problems.Humm, when I searched whether it should work, I only found a reassuring post by Walter[1] almost a year ago. The issue tracker does not seem to contain an entry either. Perhaps I should create one, then. [1] http://forum.dlang.org/post/mia2kf$djb$1 digitalmars.com
Apr 21 2016
On Thursday, 21 April 2016 at 10:57:12 UTC, Ivan Kazmenko wrote:Humm, when I searched whether it should work, I only found a reassuring post by Walter[1] almost a year ago. The issue tracker does not seem to contain an entry either. Perhaps I should create one, then. [1] http://forum.dlang.org/post/mia2kf$djb$1 digitalmars.comIssue created: https://issues.dlang.org/show_bug.cgi?id=15947
Apr 21 2016
On 4/21/2016 8:47 AM, Ivan Kazmenko wrote:Issue created: https://issues.dlang.org/show_bug.cgi?id=15947Thank you.
Apr 21 2016
On Thursday, 21 April 2016 at 09:23:26 UTC, tcak wrote:You are using "spawn". So it is a multithreaded program. -profile=gc doesn't work with multithreadd programs. Always creates problems.Then it would probably help if that is mentioned on this page somewhere. https://dlang.org/dmd-windows.html
Apr 21 2016