corona icon indicating copy to clipboard operation
corona copied to clipboard

This causes a SIGEGV

Open marksolar2d opened this issue 2 years ago • 2 comments

I always store a refence to a graphic in a table. If the graphic is removed (but not nil) then solar handles it

local g = display.newGroup()
  local t = {}
  t.graphic = display.newRect(0,0,1,1)
  g:insert(t.graphic)
  
  //some time later
  display.remove(t.graphic)
  g:insert(t.graphic)

however, if you nil the graphic you will get a crash on device.

 local t = {}
 t.graphic = display.newRect(0,0,1,1)
 g:insert(t.graphic)
 
 //some time later
 display.remove(t.graphic)
 t.graphic = nil
 g:insert(t.graphic)

Sim shows a trappable error which I would expect

image

But device simply crashes (even with a catch all error handler)

marksolar2d avatar Feb 19 '23 16:02 marksolar2d

This is a normal crash check before if its nil

t.graphic = nil

if( t.graphic ~= nil) then
     g:insert(t.graphic)
end

Or add in your Code:

local unhandledErrorListener = function( event )    
   print( "We have a problem: " .. event.errorMessage )
  return true
end 

Runtime:addEventListener( "unhandledError", unhandledErrorListener )

https://docs.coronalabs.com/api/event/unhandledError/index.html

KoiKoi2000 avatar Feb 23 '23 23:02 KoiKoi2000

This a a bug report for vlad. Inserting a nil graphic should NOT crash (framework is missing a nil check).

The crash is happening in the framework so uhandledError will not help.

marksolar2d avatar Feb 23 '23 23:02 marksolar2d