How to troubleshoot an assertion failure #6716
Replies: 1 comment
-
Posted at 2016-07-09 by @gfwilliams That's a good idea - I guess you could add a new macro - jsvGetRef is really what you need. Then you can look it up in the memory trace that should be printed after the assertion... Trying to work out the variable name is possible by scanning all variables, but a huge faff and I don't think there is any built-in function for it. Otherwise the easiest way is if you have a debugger, or can reproduce it on the PC. (Just going to move this to ESP8266 - I don't think it's really JS related... not in the way most folks will be expecting :) ) Posted at 2016-07-09 by tve I added a call to
Not sure what to make of this... Posted at 2016-07-09 by tve I added a stack backtrace. It's not a real interpretation of the stack, it really just looks for addresses in the stack that are within code and then looks up the symbols, so there are spurious entries. The result is:
The fact that this happens in an event callback makes sense to me. Dunno where to go from here though. Posted at 2016-07-09 by @gfwilliams Usually when there's an assertion it does a full trace, starting from I'm not sure why the trace you have isn't giving any names though - it seems pretty messed up. Since it's called from jspeFactor it's presumably in JS code, so you could find out where you are by typing By guess is that somewhere, some code is locking a variable and then not unlocking it. The assertion could be anywhere that the variable is used (not the code actually causing the problem), because obviously the number of locks just ticks up over time, and then it just gets to the point where any subsequent lock of that var will fail. Still, tracking down which variable it was will mean you can start to look through the bits of code that access that variable, and hopefully at some point you'll find out what isn't unlocking. How did you get the stack trace? Is that something you did in code on the ESP8266 itself? Seems like it'd be a really handy debug tool Posted at 2016-07-09 by tve So I tried v1.85 at 66fde09 and that doesn't crash. I will try the official v1.86 next. The exception stack dump is esp8266 specific. The commit is espruino/Espruino@30aae54 (probably some follow-up changes too). Posted at 2016-07-09 by tve Well, looks like 1v86.3 works fine. So either it's something on master since then or something I messed with that causes the issue. All this is using the exact identical JS code. Posted at 2016-07-09 by tve The latest commit built by travis on my fork works too, so must be one of the small local changes I have or my local build env. Grrrr. I'll try the Posted at 2016-07-23 by tve I'm continuing to have issues with assertions. I now isolated it to a small fragment of code. It doesn't fail on pico. Any thoughts what may be causing it? The code is:
The assertion failure is: ASSERT FAILED AT src/jsvar.c:624 The stack trace is:
"Help"... Posted at 2016-07-23 by tve Tweaking the code some more, the
Posted at 2016-07-23 by @gfwilliams Wow, thanks for narrowing that down... And this works on the Pico with latest firmwares? It doesn't seem to have anything platform specific in there at all. It's definitely something to do with the function parameters based on where it crashed... Are you using <1024 variables? If so, it would go to 12 byte mode and I guess there could be some kind of bug in that. Posted at 2016-07-23 by tve This uses 1600 jsvars. It crashes with a version pretty close to master as well as an older v1.85. I'll try pico again now that I have less code. I'm wondering whether jsCopy & native code & flash somehow interact differently on the esp8266. Posted at 2016-07-23 by tve The latest build off your v1.86 works on esp8266, so it must be something in my workspace that is messing things up. Go figure... Sorry for wasting your time. Posted at 2016-07-23 by tve Aha, if I build locally with RELEASE=1 it works, if I build without it if crashes. Gonna try a pico build without RELEASE=1 next... Update: the pico build I had travis make doesn't boot on pico. Ugh. I'll have to pursue this later. Posted at 2016-07-23 by tve I remembered I could try linux. Works there with and without RELEASE=1. On esp8266 it doesn't really work with RELEASE=1, that just removes the asserts so it doesn't crash on assert. I just doesn't work in a different way. Sigh. Posted at 2016-07-25 by tve I'm continuing to have assertion failures. A different JS program now hits Update: I added a decrement of the lock before calling jsvGetPathTo so it doesn't hit the assertion failure. Now it prints: Posted at 2016-07-25 by tve Well, a bunch of hours of tracing the call chain and determining where the lock on the connection/socket gets incremented this is what I've found out:
I can see clearly that every time I receive an MQTT message my on("data") event handler gets called and when socketClientConnectionsIdle is abouit to return the lock count on the socket is bumped up by one. So after about 15 messages that's it, the assertion fires. Posted at 2016-07-25 by tve I can repro on Linux: espruino/Espruino#885 Posted at 2016-07-25 by @gfwilliams Wow, thanks - that's a huge help... I'll try and take a look at this. The Pico non-release build doesn't fit into available flash - but you can disable some of the extra features like AES to get it to fit in... Posted at 2016-07-25 by @gfwilliams Also, jsvGetPathTo could probably just use jsvGetAddressOf and not lock at all? Posted at 2016-07-25 by @gfwilliams Fixed! espruino/Espruino@4fba95e If it helps, when debugging I did:
But none of that would have happened without a reproducible test that ran on Linux and the hints about which variable had too many locks - so thanks! The hard part was definitely already done :) Posted at 2016-07-25 by tve Awesome. Yeah the hard part was to find out whereabouts it was it was failing so I could construct a test case to reproduce it in linux. Thanks for the prompt fix!! Posted at 2016-07-25 by tve Fix is looking good, thanks again for the promptness! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-07-09 by tve
I'm getting an assertion failure after running some MQTT stuff for a while on an esp8266. The failure is:
ASSERT FAILED AT src/jsvar.c:556
, which isassert(jsvGetLocks(var) < JSV_LOCK_MAX);
in jsvLock. Is there a simple way I can add a line of code to print the name of the variable?Beta Was this translation helpful? Give feedback.
All reactions