You are not logged in.
The gdb backtraces for the -O2 version reveal that the issue is in "0x0000000000402a16 in new_qt(int) ()";
http://pastebin.com/m54edcd2e
If I get rid of __attribute__((__packed__)), I get an even more exotic crash;
#5 0x00007ffff7103690 in malloc () from /lib/libc.so.6
#6 0x00007ffff793a51d in operator new(unsigned long) () from /usr/local/lib64/libstdc++.so.6
#7 0x00000000004022a9 in qt_memstore::replenish() ()
I never actually use the 'new' operator in 'qt_memstore::replenish', but I do call the same 'new_qt' function which is where everything broke in the packed-struct version.
The unoptimized version (tested with both the packed attribute and without it) are working pretty well;
[vk@vk hashlife]$ ./hlife grids/test1.hlg
Generation: 0
X
XXXX
X
XXXX
I'm using g++ 4.5.0 from svn, but I can replicate the exact same results with the current Arch g++. So I'm guessing this whole thing is my fault. Besides just turning optimization off, is there a fix for this? If you need more of the source to look at, I'd be happy to post it somewhere. Thanks in advance.
edit:
I've got a diff of the assembler output of the un/optimized versions. If you'd like to take a look at it, let me know where to post it.. (it's a little over 6000 lines long)
Last edited by vkumar (2010-02-07 21:25:49)
div curl F = 0
Offline
Just out of curiosity and because I had to read up on it because I've never seen
something like this before:
Have you tried omitting this stuff:
__attribute__((__packed__))
The guy here says
that gcc's automatic memory alignment is *good* and you should only disable it
if you exactly know what you're doing (not implicating you don't!).
Offline
Nothing to do with the attribute, really:
> g++ -Wall -O2 -ggdb m54edcd2e.cpp
m54edcd2e.cpp: In function 'qtree* init_qtree(int, bool)':
m54edcd2e.cpp:21: warning: no return statement in function returning non-void
Offline
Yeah, as sr kinda hints at with his output, your init_qtree method might want to return something.
Offline
Well this is embarrassing! Thank you.
I thought if I compiled with -Wextra, g++ would catch all of my silly mistakes. I spent a long time wondering about this... and am now adding '-Wall' to my CXXFLAGS .
the_jsz:
Have you tried omitting this stuff:
__attribute__((__packed__))
Yep, and I posted the results in my original post. I'd like to pack the struct because, though more memory accesses are required, I save 7 bytes for every tree node. And with a quadtree with a height of 10, that's a savings of 9786707 bytes, or roughly 9.3 megabytes.
div curl F = 0
Offline
Yep, and I posted the results in my original post. I'd like to pack the struct because, though more memory accesses are required, I save 7 bytes for every tree node. And with a quadtree with a height of 10, that's a savings of 9786707 bytes, or roughly 9.3 megabytes.
Sorry about that, I'm ashamed I didn't read your post well enough and I had
hoped it might go unnoticed^^ Well, thanks for having me learn something new
Offline