digitalmars.D.learn - Weird behaviour when using -release in dmd
- Mikko Aarnos (30/30) Jun 06 2014 Hello all, I have a program which works perfectly when compiled
- Jonathan M Davis via Digitalmars-d-learn (22/51) Jun 06 2014 On Fri, 06 Jun 2014 10:10:24 +0000
- Rene Zwanenburg (4/34) Jun 06 2014 Please try compiling with -g (generate debug info). The magic
- Mikko Aarnos (10/13) Jun 07 2014 This helped quite a bit. The program was hitting an assert(0)
Hello all, I have a program which works perfectly when compiled without -release: parser "a implies b equivalent not b implies not a" Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (((((not a) or b) or (not b)) and (((not a) or b) or a)) and (((b or (not a )) or a) and ((b or (not a)) or (not b)))) Time(in ms) = 0 However, when I add -release, this happens: parser "a implies b equivalent not b implies not a" object.Error: assert(0) or HLT instruction ---------------- 0x0040220C 0x0040208F 0x0040206B 0x00403AAF 0x004084C8 0x0040849B 0x004083B4 0x0040454B 0x74F0338A in BaseThreadInitThunk 0x774A9F72 in RtlInitializeExceptionChain 0x774A9F45 in RtlInitializeExceptionChain Does anybody here have any idea what could cause this? The error seems to happen in a completely innocent part of code without any reason so I haven't the faintest idea what could cause it. I can post the source code if necessary, it's not long (under 1000 lines including unit tests) but it's probably pretty hard to read on some parts, mainly the parser. -Mikko Aarnos
Jun 06 2014
On Fri, 06 Jun 2014 10:10:24 +0000 Mikko Aarnos via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Hello all, I have a program which works perfectly when compiled without -release: parser "a implies b equivalent not b implies not a" Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (((((not a) or b) or (not b)) and (((not a) or b) or a)) and (((b or (not a )) or a) and ((b or (not a)) or (not b)))) Time(in ms) = 0 However, when I add -release, this happens: parser "a implies b equivalent not b implies not a" object.Error: assert(0) or HLT instruction ---------------- 0x0040220C 0x0040208F 0x0040206B 0x00403AAF 0x004084C8 0x0040849B 0x004083B4 0x0040454B 0x74F0338A in BaseThreadInitThunk 0x774A9F72 in RtlInitializeExceptionChain 0x774A9F45 in RtlInitializeExceptionChain Does anybody here have any idea what could cause this? The error seems to happen in a completely innocent part of code without any reason so I haven't the faintest idea what could cause it. I can post the source code if necessary, it's not long (under 1000 lines including unit tests) but it's probably pretty hard to read on some parts, mainly the parser.I don't think that we can help you much without more code. If you hit an assert(0), then it's usually because of one of two reasons. 1. You have an assert(0) in your code (or an assertion where the condition is statically known to be equivalent to 0). 2. You hit the end of a function without hitting a proper return statement. There are probably a few others, but those are the two main ones that come to mind at the moment. Now, normally, I'd expect to see an AssertError throw without -release rather than your program working fine, so that makes me wonder whether you have any variables which aren't being initialized properly - though usually, that can only happen if you initialiaze a variable to void, so I wouldn't have thought that that would the problem, since most people don't do that. And of course it's always possible that you found a compile bug, but without code that we can compile ourselves, I don't think that we can help much. You could use https://github.com/CyberShadow/DustMite to reduce the code to something much smaller which still exhibits the problem (and is what you really should do if you need to report a compiler bug anyway, which you might in this case). - Jonathan M Davis
Jun 06 2014
On Friday, 6 June 2014 at 10:10:25 UTC, Mikko Aarnos wrote:Hello all, I have a program which works perfectly when compiled without -release: parser "a implies b equivalent not b implies not a" Input: ((a implies b) equivalent ((not b) implies (not a))) CNF: (((((not a) or b) or (not b)) and (((not a) or b) or a)) and (((b or (not a )) or a) and ((b or (not a)) or (not b)))) Time(in ms) = 0 However, when I add -release, this happens: parser "a implies b equivalent not b implies not a" object.Error: assert(0) or HLT instruction ---------------- 0x0040220C 0x0040208F 0x0040206B 0x00403AAF 0x004084C8 0x0040849B 0x004083B4 0x0040454B 0x74F0338A in BaseThreadInitThunk 0x774A9F72 in RtlInitializeExceptionChain 0x774A9F45 in RtlInitializeExceptionChain Does anybody here have any idea what could cause this? The error seems to happen in a completely innocent part of code without any reason so I haven't the faintest idea what could cause it. I can post the source code if necessary, it's not long (under 1000 lines including unit tests) but it's probably pretty hard to read on some parts, mainly the parser. -Mikko AarnosPlease try compiling with -g (generate debug info). The magic numbers should turn into a stack trace, so you know where the assert is triggered.
Jun 06 2014
On Friday, 6 June 2014 at 14:21:38 UTC, Rene Zwanenburg wrote:Please try compiling with -g (generate debug info). The magic numbers should turn into a stack trace, so you know where the assert is triggered.This helped quite a bit. The program was hitting an assert(0) which I had ruled out since it would be impossible due to the structure of the program. After about one hour of searching I found out that a small part of the program logic was INSIDE AN ASSERT. So when I compiled with -release that part - which happened to be critical - was thrown out and this was caused. A pretty stupid mistake, if you ask me. Thanks for the help, both of you. -Mikko Aarnos
Jun 07 2014