Ray/Bounding Box Intersect back
(L) [2006/08/28] [Michael77] [Ray/Bounding Box Intersect] Wayback!Hi,
I just tried to implement the SSE Version of the bounding box test tbp posted on flipcode and for some reason, in one scene (and only in that scene!!!) it crashes, saying it canĀ“t read memory address 0xffffffff (why would he want to???) and I have no idea why. This is my code
(L) [2006/08/28] [Phantom] [Ray/Bounding Box Intersect] Wayback!Just out of curiosity and pure lazyness: What does mm_comige_ss do?
_________________
--------------------------------------------------------------
Whatever
(L) [2006/08/28] [Michael77] [Ray/Bounding Box Intersect] Wayback!Directly from the MSDN: Compares the lower single-precision, floating-point value of a and b for a greater than or equal to b.
The result is 0x1 or 0x0.
Funny thing by the way: When I use __forceinline it crashes somewhat later...
(L) [2006/08/28] [Phantom] [Ray/Bounding Box Intersect] Wayback!Told you as was lazy. Thanks anyway. [SMILEY Smile]
_________________
--------------------------------------------------------------
Whatever
(L) [2006/08/28] [tbp] [Ray/Bounding Box Intersect] Wayback!I have a better version somewhere.
Anyway, that crash isn't related to that function it's just that something smashes your stack, or something like that and it coincidentally crashes here.
I mean i suppose that's a member function (const declaration), so m_extends[0] is accessed thru 'this' which is corrupted, which makes that aligned load go boom.
Thusly i plead non guilty [SMILEY Wink]
EDIT: Those +/- inf are there to tweak NaNs that may appear into something more manageable, but that relies on precise ordering of the min/max operands: min[ss/ps](a,b) != min[ss/ps](b,a) if there's a NaN. So you have to be careful and teach the compiler not to fool around.
_________________
May you live in interesting times.
[LINK https://gna.org/projects/radius/ radius] | [LINK http://ompf.org/ ompf] | [LINK http://ompf.org/wiki/ WompfKi]
(L) [2006/08/29] [tbp] [Ray/Bounding Box Intersect] Wayback!Latent bug being exposed. There's not enough details to decide, so putting the blame on the compiler at this stage is just as legit as anything else. And convenient [SMILEY Wink]
Really, the function just does some computations, there's no allocation - beside a bunch of bytes on the stack - and it crashes even before writing back. There's a high probability that the root of the problem is higher up in the food chain.
If it's dependant on the way functions around get inlined, it prolly has to do with alignment issues.
_________________
May you live in interesting times.
[LINK https://gna.org/projects/radius/ radius] | [LINK http://ompf.org/ ompf] | [LINK http://ompf.org/wiki/ WompfKi]
(L) [2006/08/30] [Lynx] [Ray/Bounding Box Intersect] Wayback!Stack corruption is really nasty...backtraces often lead you anywhere not even remotely related to the actual reason. Often enough the code messing up the stack isn't affected by it, and maybe a couple of functions in the call stack below aren't either, so you can imagine how far off it can crash...
although, even with my limited coding experience, i have already seen compiler go wrong (MSVC7.1 on my triangle clipping code for example, dead simple code, yet calcs crap with /Ox), but if it happens without optimizations too, the chances for a compiler bug drop dramatically IMHO [SMILEY Smile]
(L) [2006/08/30] [tbp] [Ray/Bounding Box Intersect] Wayback!That's where using multiple compilers on various platforms/ABI helps. I find MSVC & ICC quite lenient on alignment issues, because they do so much silent fixing behind your back; GCC is much less forgiving, notably on an ELF platform.
Anyway you could probably use a mem/bound checking tool of some sort to get some clues.
_________________
May you live in interesting times.
[LINK https://gna.org/projects/radius/ radius] | [LINK http://ompf.org/ ompf] | [LINK http://ompf.org/wiki/ WompfKi]
back