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

Self re-trigger crashes with stack canary or double exception (ESP32) #581

Closed
scaprile opened this issue Sep 7, 2021 · 2 comments
Closed

Comments

@scaprile
Copy link

scaprile commented Sep 7, 2021

A callback for an event triggering the very same event in order to simulate a main loop causes canary watchpoint resets or core panics (Double exception); minimum app attached: crash.zip

static void rundemo(int ev, void *ev_data, void *userdata) {
  mgos_event_trigger(MY_EVENT, NULL);
}
enum mgos_app_init_result mgos_app_init(void) {
  if(!mgos_event_register_base(MY_EVENT, "Ping-pong demo")) return false;
  if(!mgos_event_add_handler(MY_EVENT, rundemo, NULL))  return false;
  mgos_event_trigger(MY_EVENT, NULL);
  return MGOS_APP_INIT_SUCCESS;
}
@scaprile
Copy link
Author

scaprile commented Sep 9, 2021

Observing the source code for the mgos_event_trigger() function I see it just calls the handler, no event queuing, so it is clear to me why this is not proper usage of the function and that mOS does not support an event handler re-triggering itself other than for recursive-function-like purposes (and given enough stack space available)

@scaprile scaprile closed this as completed Sep 9, 2021
@rojer
Copy link
Collaborator

rojer commented Sep 9, 2021

indeed, event handlers are executed in-line so you can't re-trigger event from its handler.

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

No branches or pull requests

2 participants