Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement panic call handling for all modules #3163

Merged
merged 3 commits into from
Jun 16, 2020

Conversation

TerryE
Copy link
Collaborator

@TerryE TerryE commented Jun 13, 2020

Fixes #3078. (Also #3141 and @KT819GM Gitter comment at Jun 12 15:04)

Make sure all boxes are checked (add x inside the brackets) when you submit your contribution, remove this sentence before doing so.

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

This is a fairly large patch to the modules plus the addition of a node.setonerror() function so that CBs throwing an error give a proper traceback. Apps can also override the default action of rebooting after such an error.

Note that this PR is submitted for review at this stage. I still have some documentation to add and any changes in the light of feedback.

@TerryE
Copy link
Collaborator Author

TerryE commented Jun 13, 2020

@dnc40085 can you please review 6cfbad4. Lua 5.3 does not support LUA_GLOBALSINDEX so I had to change your code to remove this.
@galjonsfigur ditto with the platform.c GPIO code.

@TerryE
Copy link
Collaborator Author

TerryE commented Jun 13, 2020

This PR has 53 files changed so there's no way that I can sensibly cover them all. Mode of these are the same edit pattern to module code to replaces a lua_call(L, n, 0) lines by luaL_pcallx(L, n, 0) calls. However these are only in the case where the call is in a SDK CB. There are cases such as where you can pass helper routines to sjson and these should be allowed to throw.

Also not that the last Travis build has failed on the MS Windows build of luac.cross. I'll examine the logs an fix this on my next push.

Copy link
Member

@nwf nwf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

app/lua/lnodemcu.h Show resolved Hide resolved
app/lua53/lauxlib.c Show resolved Hide resolved
app/lua53/lnodemcu.c Show resolved Hide resolved
/* One first time through set automatic restart after 2s delay */
if (!restart_timer.timer_func) {
os_timer_setfn(&restart_timer, restart_callback, NULL);
os_timer_arm(&restart_timer, DELAY2SEC, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Will fix

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nwf,
I've just done a git diff 06aa248f bd9b4253 | gedit - (the patch for this PR) and did a global highlight for \t. This whole tab issue is a PITA. The Lua style uses an indent depth of 2 chars and always uses two spaces to per indent. It does use tabs (with a default of 8 chars per stop)

However modules are all over the place. Some use tab indents (and some assume a tab stop of 4) so it is extremely easy to get the visual alignment screwed. My vote is that we should address this as a module-wide cleanup rather piecemeal one-offs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some use tab indents (and some assume a tab stop of 4) so it is extremely easy to get the visual alignment screwed.

#1168, created over 4y ago.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Golden oldies that still bite.

Copy link
Member

@galjonsfigur galjonsfigur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TerryE I tested the PR with softuart module with fixes from #3104 and it seems to work the same as the old version with the fix, so 👍 . platform_gpio_register_intr_hook code is now readable and easier to understand as the old one was almost obfuscated in my opinion.

@TerryE
Copy link
Collaborator Author

TerryE commented Jun 14, 2020

OK, the issue with the Windows build was that I updated SPIFFS and the latest version removed an MSC compatibility fix which I've put back in, and it now compiles clean.

@marcelstoer @nwf I would prefer to merge this sooner rather later as it contains a really useful enhancement and I've got other stuff backed up. Unless anyone objects, I will do this tomorrow.

@nodemcu nodemcu deleted a comment from TerryE Jun 14, 2020
@marcelstoer marcelstoer added this to the Next release milestone Jun 14, 2020
@TerryE
Copy link
Collaborator Author

TerryE commented Jun 16, 2020

@marcelstoer @nwf I would prefer to merge this sooner rather later as it contains a really useful enhancement and I've got other stuff backed up. Unless anyone objects, I will do this tomorrow.

I will now merge.

@TerryE TerryE merged commit 1f2e5bb into nodemcu:dev Jun 16, 2020
@TerryE TerryE deleted the dev-errorhandling branch June 16, 2020 07:20
@danjohn
Copy link

danjohn commented Jun 27, 2020

tmr.softwd() seems to be unstopable now by no more allowing a negative argument.
Glitch or intented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants