adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
Other
4.04k stars 1.19k forks source link

FunHouse Crash into the HardFault_Handler. #6849

Closed slootsky closed 10 months ago

slootsky commented 2 years ago

CircuitPython version

Adafruit CircuitPython 7.3.2 on 2022-07-20; Adafruit FunHouse with ESP32S2
Board ID:adafruit_funhouse

Code/REPL

import adafruit_logging as logging
from config import config

logger=logging.getLogger('logger')
# logger.setLevel(config.get('loglevel',logging.WARNING))

import another

Behavior

Sometimes a soft reboot or the reboot button doesn't cause the problem, but using the power switch will.

Running in safe mode! Not running saved code.

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Crash into the HardFault_Handler.
Please file an issue with the contents of your CIRCUITPY drive at
https://github.com/adafruit/circuitpython/issues

Press any key to enter the REPL. Use CTRL-D to reload.

### Description

okay.  I get that there's a lot going on here, and a lot of it isn't perfect.  Some of it maybe even should generate a runtime error.  But getting it to crash into the HardFault_Handler seems unexpected :-)

I've attached all the files involved in this  (renamed from .py to .txt because that's what the uploader would accept).  [don't worry, secrets.py doesn't really have any secrets in it anymore]

This is the output of circup freeze
```adafruit_ahtx0==1.0.16
adafruit_bme680==3.4.10
adafruit_ccs811==1.3.12
adafruit_debouncer==2.0.5
adafruit_dotstar==2.2.5
adafruit_fakerequests==1.0.11
adafruit_logging==4.1.6
adafruit_miniqr==1.3.14
adafruit_pixelbuf==1.1.8
adafruit_requests==1.12.8
adafruit_scd4x==1.3.6
adafruit_ticks==1.0.7
adafruit_tmp117==1.1.6
neopixel==6.3.6
simpleio==3.0.8
adafruit_bitmap_font==1.5.11
adafruit_bus_device==5.2.3
adafruit_display_text==2.22.10
adafruit_dps310==2.1.8
adafruit_funhouse==2.1.18
adafruit_io==5.6.12
adafruit_minimqtt==5.4.2
adafruit_portalbase==1.14.3
adafruit_register==1.9.13

config.txt secrets.txt another.txt code.txt

Additional information

This is just about as minimal as I could get the code and still have the problem.

Any of the following will make it work again

slootsky commented 2 years ago

I just tested with 7.3.3 and I get the same result there.

Adafruit CircuitPython 7.3.3 on 2022-08-29; Adafruit FunHouse with ESP32S2 Board ID:adafruit_funhouse

It does NOT occur with 8.0.0-beta0

Adafruit CircuitPython 8.0.0-beta.0 on 2022-08-18; Adafruit FunHouse with ESP32S2 Board ID:adafruit_funhouse

dhalbert commented 2 years ago

If you put the from adafruit_funhouse import FunHouse into code.py instead of in another.py, does it work fine in 7.3.x?

If so, this might be a manifestation of #2687, but usually that doesn't cause a crash. The fact that 8.0.0-beta.0 doesn't crash may or may not reflect an 8.0.0-whatever fix.

slootsky commented 2 years ago

@dhalbert Yes. Moving from adafruit_funhouse import FunHouse to code.py makes it go away.

This of course means that I can't use FunHouse in another.py though.

What I've started doing is putting my main code in a secondary file that has the name of the project (eg co2monitor.py) and then importing that into code.py after doing some common setup and initialization.

dhalbert commented 10 months ago

Given that this seems to be another manifestation of #2687, this is fixed in 9.0.0-alpha.2 because long-lived heap was removed.