Skip to content

HWCDC::end() does not set tx_lock to NULL, causing crashes #8224

Closed
@TD-er

Description

@TD-er

Board

ESP32-C3 / ESP32-S3

Device Description

Any ESP32-C3 or -S3 using HWCDC

Hardware Configuration

Any ESP32-C3 or -S3 board using HWCDC

Version

v2.0.9

IDE Name

PlatformIO

Operating System

Windows 11

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

HWCDC::end() does not reset the semaphore.
So after a call to end() and a new call to begin() the tx_lock semaphore is invalid.
Thus trying to write something to that port again will cause a crash.

void HWCDC::end()
{
//Disable tx/rx interrupt.
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
esp_intr_free(intr_handle);
intr_handle = NULL;
if(tx_lock != NULL) {
vSemaphoreDelete(tx_lock);
}
setRxBufferSize(0);
setTxBufferSize(0);
if (arduino_hw_cdc_event_loop_handle) {
esp_event_loop_delete(arduino_hw_cdc_event_loop_handle);
arduino_hw_cdc_event_loop_handle = NULL;
}
}

Sketch

-

Debug Message

-

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Chip: ESP32-C3Issue is related to support of ESP32-C3 ChipChip: ESP32-S3Issue is related to support of ESP32-S3 ChipStatus: Needs investigationWe need to do some research before taking next steps on this issueType: Bug 🐛All bugs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions