Skip to content

Hard Fault after successful mDNS Query and program exit #10197

Closed

Description

@aaron97neu

CircuitPython version and board name

Adafruit CircuitPython 9.2.6 on 2025-03-23; Adafruit Feather ESP32S2 with ESP32S2

Code/REPL

#!/usr/bin/env python3
import wifi
import mdns

import alarm

import time
import os

ssid = os.getenv("WIFI_SSID")
password = os.getenv("WIFI_PASSWORD")

wifi.radio.connect(ssid, password)

mdns_svr = mdns.Server(wifi.radio)
services = mdns_svr.find(service_type="_mqtt", protocol="_tcp", timeout=5)

wake_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 300)
alarm.exit_and_deep_sleep_until_alarms(wake_alarm)

Behavior

0;🐍Wi-Fi: No IP | main.py | 9.2.60;🐍192.168.50.199 | Done | 9.2.6
Code done running.
Auto-reload is off.
Running in safe mode! Not running saved code.

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.                                                                
Please file an issue with your program at github.com/adafruit/circuitpython/issues.                            
Press reset to exit safe mode.                                                                                 
                                                                                                               
Press any key to enter the REPL. Use CTRL-D to reload.  

Confirmed after storage.erase_filesystem() reset with no libraries loaded

Description

Running without services = mdns_svr.find(service_type="_mqtt", protocol="_tcp", timeout=5) results in expected behavior, have not tested with alternate sleep modes

Additional information

Specifically ESP32S2 w/ BME280 sensor and 2.13" HD Tri-Color eInk display attached. However, these devices are not interacted with when triggering the fault

No response

Activity

  1. added this to the 10.0.0 milestone on Mar 31, 2025
  2. self-assigned this
    on May 19, 2025
  3. modified the milestones: 10.0.0, 10.x.x on Jul 24, 2025
  4. modified the milestones: 10.x.x, 10.3.0 on May 19, 2026
  5. changed the title [-]Hard Fault after mDNS Query and Deep Sleep[/-] [+]Hard Fault after successful mDNS Query and program exit[/+] on Jul 24, 2026
  6. dhalbert commented on Jul 24, 2026

    @dhalbert
    Collaborator

    I got a simpler version to crash with CircuitPython 10.3.0-alpha.4 on Metro ESP32-S2 and S3. No deep sleep is necessary.

    Note that mdns_svr.find() must find something to cause a crash. If no matching service_type is found, it will not crash. _companion-link is advertised by various Apple devices, so it's easy to find.

    import mdns
    import time
    import wifi
    
    # settings.toml has autoconnect settings
    
    time.sleep(2) # wait long enough to see prints
    
    mdns_svr = mdns.Server(wifi.radio)
    services = mdns_svr.find(service_type="_companion-link", protocol="_tcp", timeout=5)
    time.sleep(2)
    print("done")

    Note that the program finishes, and then there is a crash. So it's probably something about cleaning up when the VM exits. Maybe a gc'd object is referenced or similar.

    Output

    done
    
    Code done running.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions