Skip to content

ping too frequently results in resource exhaustion, exception #7940

@jepler

Description

@jepler

CircuitPython version

Adafruit CircuitPython 8.1.0-beta.2-24-gd2aca7eba0-dirty on 2023-05-05; ESP32-S3-DevKitC-1-N8R2 with ESP32S3
Board ID:espressif_esp32s3_devkitc_1_n8r2
UID:866B3BD27A8F

Code/REPL

import time
import wifi
from secrets import secrets

DELAY = 0.5  # this is fine, but lower values lead to exceptions after a few pings

wifi.radio.connect(secrets['ssid'], secrets['password'])
while True:
    print(f"LAN ping: {wifi.radio.ping(wifi.radio.ipv4_gateway)}s")
    time.sleep(DELAY)

Behavior

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
espidf.IDFError: Generic Failure

Description

The esp-idf implementation of ping creates a task which actually sends and receives the ping packets.

When esp_ping_delete_session is called, the underlying resources are not immediately freed. Instead, this waits until a (hard coded) 1 second delay expires in the ping task, which then checks a flag, frees resources, and terminates itself.

Additional information

Before #7938 this led to a hard crash and entry into safe mode(#5980), as the return value of esp_ping_new_session wasn't checked. Now that the return value is checked, there's a (recoverable, potentially) exception. That's an improvement on the status quo ante but it'd be nice if ping did not have this resource exhaustion problem. This likely means creating our own ping implementation, rather than using esp-idf's.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugespressifapplies to multiple Espressif chips

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions