Discussion:
nullptr exception TreeBin.cxx
(too old to reply)
Richard Harrison
2017-06-30 19:17:15 UTC
Permalink
I've just had a nullptr in line 224 of TreeBin.cxx

224: tnormalArray->insert(tnormalArray->end(),4,ter);

because the cast in line 210 or 219[1] failed because the secondary
array couldn't be cast to Vec3Array.

210: {tnormalArray =
static_cast<Vec3Array*>(geom->getSecondaryColorArray());}

It happened a couple of times to me, flying around LOWI - once on a
replay whilst paused and moving the view, the second time in the cockpit
probably whilst moving the view (but I can't be sure).

There is an easy fix by checking the pointer is cast ok; which I'll
probably add. Unfortunately I didn't manage to capture the type of the
secondaryColour array, but it was valid, just not a Vec3Array.

Loading Image...

---------------

[1] Not exactly sure why it is cast twice; and I can't be sure which one
was called because I didn't check.
James Turner
2017-07-01 19:12:09 UTC
Permalink
There is an easy fix by checking the pointer is cast ok; which I'll probably add. Unfortunately I didn't manage to capture the type of the secondaryColour array, but it was valid, just not a Vec3Array.
To b honest I don’t think the check is helpful, this implies memory corruption I think, so all bets are off.

(Unless there is a non-corruption way we could end up in this scenario, but it feels 
. unlikely)

Kind regards,
James
Richard Harrison
2017-07-10 09:05:01 UTC
Permalink
Post by Richard Harrison
There is an easy fix by checking the pointer is cast ok; which I'll
probably add. Unfortunately I didn't manage to capture the type of
the secondaryColour array, but it was valid, just not a Vec3Array.
To be honest I don’t think the check is helpful, this implies memory
corruption I think, so all bets are off.
(Unless there is a non-corruption way we could end up in this
scenario, but it feels …. unlikely)
I think it may be related to the order of operation of the processing;
e.g. when I move the view or change the LOD I've had another couple of
crashes in this area - and in these cases the secondary color array was
null.

I've added check to the pointer operations prior to dereference [1] and
will push shortly

-------------------------
[1] it's good practice to do this especially with a non determinate set
of operations occurring potentially concurrently.

Loading...