question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ESP32 exception BREAK instr when running with async v3

See original GitHub issue

Hi,

I’ve faced issue with async code. I’ve tested 2 cases: loop with synchronous code, and loop with async code V3 as follow on ESP32 without PSRAM. I use the latest MicroPython version 1.15.

1. Synchronous code:

When running this function, it could run well 24/7 without any exceptions. Sleep in 1ms.

def _ctask_fn(arg):
   try:
      while True:
         _ccall(arg['_cfn'], arg)
         time.sleep_ms(arg['sleep'])
   except Exception as e:
      print('[_ctask_fn] %s' % str(e))
   finally:
      return

2. Async code

Also sleep in 1ms. But run in tens of seconds, or some minutes (2, 3), it occurs exceptions. It’s rather random. Most of them were Guru Meditation Error: Core 1 panic’ed (Unhandled debug exception) Debug exception reason: BREAK instr

arg[‘_cfn’] is just a callback function, do nothing for test.

If sleep in 50 or 100ms, it’s running rather long without exceptions. I’ve not tested with several hours/days.

async def _ctask_afn(arg):
   try:
      while True:
         _ccall(arg['_cfn'], arg)

         if 'sleep' in arg:
            await asyncio.sleep_ms(arg['sleep'])
         elif 'event' in arg:
           await arg['event'].wait()
           arg['event'].clear()
         elif 'tsf' in arg:
            await arg['tsf'].wait()

   except Exception as e:
      print('[_ctask_afn] %s' % str(e))
   finally:
      return

I really dont know why. It’s just a normal/minimal async code. Pls guide me how to debug it. I think that problem is at async scheduler side.

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:52 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dpgeorgecommented, May 24, 2021

by the way could u suggest me what tests to be run

Run all the tests/basics/*.py and tests/stress/*.py tests (ones that aren’t supported by your implementation will be skipped automatically). If you have a REPL try this:

$ ./run-tests.py --device /dev/<usb-serial-device> -d basics stress
1reaction
peterhinchcommented, May 19, 2021

I’ve tested on a Raspberry Pi Pico and your code sample runs perfectly. I’ll hook out an ESP32 and try that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My ESP crashes running some code. How to troubleshoot it?
Exception. Start with looking up exception code in the Exception Causes (EXCCAUSE) table to understand what kind of issue it is. If you...
Read more >
Fatal Errors - ESP32 - — ESP-IDF Programming Guide latest ...
This CPU exception indicates that the CPU could not read an instruction because the address of the instruction does not belong to a...
Read more >
panic unhandled break instruction - ESP32 Forum
Re: panic unhandled break instruction​​ In the stacktrace, usually vprintf() shows up when this is the case. The solution is to use ESP_LOGx(), ......
Read more >
How can I make VS break on exceptions in an async Task ...
A) Wrap your calls and throw a custom Exception in your Task code. Break on only throw of your custom exception.
Read more >
ESP32 Web Server - Arduino IDE - Random Nerd Tutorials
Windows instructions – Installing the ESP32 Board in Arduino IDE ... Break out of the while loop break; } else { // if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found