{"action":"created","issue":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/801","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/801/labels{/name}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/801/comments","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/801/events","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/801","id":119491908,"number":801,"title":"PANIC messages should not cause hardware fatal exceptions","user":{"login":"pjsg","id":1508813,"avatar_url":"https://avatars.githubusercontent.com/u/1508813?v=3","gravatar_id":"","url":"https://api.github.com/users/pjsg","html_url":"https://github.com/pjsg","followers_url":"https://api.github.com/users/pjsg/followers","following_url":"https://api.github.com/users/pjsg/following{/other_user}","gists_url":"https://api.github.com/users/pjsg/gists{/gist_id}","starred_url":"https://api.github.com/users/pjsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjsg/subscriptions","organizations_url":"https://api.github.com/users/pjsg/orgs","repos_url":"https://api.github.com/users/pjsg/repos","events_url":"https://api.github.com/users/pjsg/events{/privacy}","received_events_url":"https://api.github.com/users/pjsg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-30T13:31:03Z","updated_at":"2015-12-01T01:08:50Z","closed_at":null,"body":"The following test case triggers assertion failures in lvm.c reliably:\r\n\r\n```\r\nfunction badfont()\r\n   local x = u8g.ssd1306_128x64_i2c(0x40)\r\n   \r\n   x:setFont(0)\r\nend\r\n\r\ntmr.alarm(0, 100, 0, badfont)\r\n```\r\n\r\nwith this error:\r\n```\r\nPANIC: unprotected error in call to Lua API (stdin:3: bad argument #1 to 'setFont' (font data expected))\r\nlvm.c:470: base <= L->top && L->top <= L->stack + L->stacksize\r\nFatal exception 29(StoreProhibitedCause):\r\nepc1=0x4024adc5, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000004, depc=0x00000000\r\n```\r\n\r\nNow, this should generate a PANIC as I did pass in a bad argument to setFont, but it isn't actually clear what should happen next. However, I would argue that an assertion error followed by a hardware trap is incorrect.\r\n\r\nI'll try and fix this (once I understand what _ought_ to happen as a result of a PANIC)"},"comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments/160814144","html_url":"https://github.com/nodemcu/nodemcu-firmware/issues/801#issuecomment-160814144","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/801","id":160814144,"user":{"login":"pjsg","id":1508813,"avatar_url":"https://avatars.githubusercontent.com/u/1508813?v=3","gravatar_id":"","url":"https://api.github.com/users/pjsg","html_url":"https://github.com/pjsg","followers_url":"https://api.github.com/users/pjsg/followers","following_url":"https://api.github.com/users/pjsg/following{/other_user}","gists_url":"https://api.github.com/users/pjsg/gists{/gist_id}","starred_url":"https://api.github.com/users/pjsg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjsg/subscriptions","organizations_url":"https://api.github.com/users/pjsg/orgs","repos_url":"https://api.github.com/users/pjsg/repos","events_url":"https://api.github.com/users/pjsg/events{/privacy}","received_events_url":"https://api.github.com/users/pjsg/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T01:08:50Z","updated_at":"2015-12-01T01:08:50Z","body":"The panic is appropriate and the lua manual indicates that the app should exit. I don't know what that means in an embedded environment. It could cleanly restart the firmware (reboot), or it could just abort that particular call stack -- essentially leaving the app running.\r\n\r\nI think that the requirements for embedded systems are different to that of a standalone program. In a system which mixes C and has a bit of lua where there is significant work done by the C code (e.g. a firewall that supports LUA for customization), it would be very unfriendly to reboot the firewall because somebody has a typo in their lua code. \r\n\r\nI also agree that a stack trace would be nice as well."}}