hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

Telemetry crashed with null pointer exception

Open nulld opened this issue 7 years ago • 3 comments

got a null pointer exception in this line while trying to profile with hxScout https://github.com/HaxeFoundation/hxcpp/blob/master/src/hx/Telemetry.cpp#L207

Exception thrown: read access violation.
this->_last_obj-> was nullptr.

this is callstack image

nulld avatar Aug 27 '17 14:08 nulld

I've been able to prevent this error by changing #L205 to the following.

if (exist != alloc_map.end() && _last_obj!=(NULL) && *(int**)_last_obj != 0) {

I have no idea what's going on here so I wouldn't try pushing that change myself (maybe it's just hiding a deeper issue?), but it seems to make everything work okay for me.

justin-espedal avatar Oct 11 '17 15:10 justin-espedal

I have the same problem. I think the problem starts in file Telemetry.cpp , at function Telemetry.HXTAllocation. When casting, it is assumed that the transmitted variable is a pointer to the hx::Object. Either this assumption is violated (and something else is transmitted). Either (which is worse), somewhere the object is incorrectly cleared. I still use the fix from the post above. However, in fact, an indefinite behavior is obtained, since no one guarantees the presence of a pointer to a table of virtual functions at the beginning of the object.

imcasper avatar May 07 '19 13:05 imcasper

if (exist != alloc_map.end() && _last_obj!=(NULL) && (int*)_last_obj != 0) {

I was having the same issues, this fixed it, thanks!

Geokureli avatar Oct 06 '23 16:10 Geokureli