Page 1 of 1

0.9.2 fails during debugging with run-time error

Posted: Wed Jun 03, 2015 4:30 pm
by paulclinger
@bartbes (or anyone else who can help),

I got two reports about Love2d throwing a run-time error during debugging from ZeroBrane Studio: "bad argument #1 to 'pairs' (table expected, got boolean)". The error comes from Mobdebug during initialization of Serpent serializer, which goes through several global tables to capture their entries. It seems like one of the tables occasionally get "boolean" value: {'coroutine', 'debug', 'io', 'math', 'string', 'table', 'os'}.

The reason I'm asking here instead of investigating myself is that I have not been able to reproduce it myself and can't follow-up on the first report and the error disappeared for the second user; see the discussion here: http://www.freelists.org/post/zerobrane ... art-fail,2 (the relevant code fragment is here: https://github.com/pkulchenko/ZeroBrane ... a#L139-140).

Does anyone have any idea what might have contributed to it? I patched the serializer by checking the type of the value first, but would still like to know if there is some issue I'm missing. Thanks. Paul.

Re: 0.9.2 fails during debugging with run-time error

Posted: Wed Jun 03, 2015 5:08 pm
by bartbes
In my experience, when one of your stdlib tables is acting up, it's usually debug, since people like calling stuff "debug". Now, in this particular case, the bug goes away when a variable "debug" is set to false, and exists if set to true (due to '_G[g] or {}'), so that could explain its weird behaviour? The easy fix here seems to replace '_G[g] or {}' with 'require(g)'.

Re: 0.9.2 fails during debugging with run-time error

Posted: Wed Jun 03, 2015 9:47 pm
by paulclinger
> it's usually debug, since people like calling stuff "debug"

@bartbes, that's a very good point. Basically, if you have a global variable "debug", you may run into the issue I see. I added a check for `type()`, which should eliminate the issue, as I didn't want to do "require", even though it could technically be better (as the user may set debug to its own table).

Re: 0.9.2 fails during debugging with run-time error

Posted: Wed Jun 03, 2015 10:33 pm
by slime
It's also a bit common to do that for 'table' (especially in example code), and 'type' – although that one's a function.

Re: 0.9.2 fails during debugging with run-time error

Posted: Fri Jun 05, 2015 9:41 pm
by paulclinger
@slime, true, although in this case it turned out to be "debug", exactly as @bartbes suspected.