<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>I'll mention that I just was debugging some stuff in Linux for dcollections, and the line numbers for the unit tests given by gdb were off by a couple of lines (I had the same feelings you are having, how is this possible). That was just inside the unit tests. In the actual code, the line numbers were correct. What's more, when I would step over lines in gdb, the program would jump *back* some lines when there was no loop in the code.</span></div><div><br><span></span></div><div><span>I wouldn't trust that GDB is giving you accurate info.<br></span></div><div><br><span></span></div><div><span>My recommendation -- try using writeln debugging if possible.</span></div><div><br><span></span></div><div><span>-Steve<br></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px;
padding-left: 5px;"><div style="font-family: arial,helvetica,sans-serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> David Simcha <dsimcha@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Discuss the phobos library for D <phobos@puremagic.com><br><b><span style="font-weight: bold;">Sent:</span></b> Friday, April 29, 2011 9:26 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [phobos] FreeBSD segfaults with std.parallelism<br></font><br>
I've spent some serious time looking into the FreeBSD std.parallelism segfaults. I'm at a complete loss as to what could be causing them or how to fix them. Here are some observations. Someone please offer any suggestions you have.<br><br>1. I'm able to reproduce these, though much more sporadically, on Windows and Linux, by executing the unit test in a loop.<br><br>2. On FreeBSD running GDB on the core dump shows stack traces that should be impossible. Every time the program crashes, the function at the top of the stack should be unreachable from the second function from the top. (It shouldn't even be indirectly reachable, i.e. inlining couldn't explain it.) On both Linux and FreeBSD, the program counter ends up at illegal places in between instructions. Even more weirdly, the address that the program counter ends up at when the segfault happens seems deterministic for any given platform and compiler
settings. Is there a good debugger for Windows that will give me stack traces and stuff like GDB?<br><br>3. The triggering test is:<br><br> auto lmchain = poolInstance.map!"a * a"(<br> poolInstance.map!sqrt(<br> poolInstance.asyncBuf(<br> iota(3_000_000)<br> )<br> )<br> );<br> foreach(i, elem; parallel(lmchain)) {<br> assert(approxEqual(elem, i));<br> }<br><br>In other words, it's the test that uses everything together (including Task and amap() under the hood), the hardest one to debug.<br><br>IIUC, the instruction stream can't be overwritten by a buggy program because the code pages are marked read-only. The only other explanation I can think of for how the program
counter could be corrupted is if some race condition corrupts either a function pointer or a return address on the stack. However, in this case the address that the program counter ends up at when the segfault happens should be less deterministic.<br><br>_______________________________________________<br>phobos mailing list<br><a ymailto="mailto:phobos@puremagic.com" href="mailto:phobos@puremagic.com">phobos@puremagic.com</a><br>http://lists.puremagic.com/mailman/listinfo/phobos<br><br><br></div></div></blockquote></div></div></body></html>