-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CORRUPT HEAP: Bad tail on clearQueue() when freeing buffer (vector of bytes) #120
Comments
You have a corrupted heap. It happens when something is accessing a pointer to an object that has been dereferenced by another task. You need to check your code and work on minimal reproductible case that is not involving your app code if you think there is a bug in this library. There has been so many perf and memory improvements that running faster might also highlight some issues you never saw with the ESPhome fork. Also, this fork is using shared pointers: the queue is a list of websocket messages, a websocket message holds a buffer, which is a shared pointers on a vector of bytes. It helps solve a bunch of memory problems happening with the original fork when optimizing websocket buffer sending / cleanup. I will keep this issue opened for now but I am pretty sure, looking at your stack trace and error that you have a concurrent access to a pointer that is going out of scope. When the message from the queue goes out of scope it is freed, then destructor is called, the shared PTR sees that there is no more owners so it allows the destruction of the vector, with fails. So maybe you had a vector that was created without a shared PTR which has been added to the WS queue, then it went out of scope ? Also, you can have a look at the recommended settings to tweak AsyncTCP and ESPAsyncWebServer (flags) in the readme, and you can also post a link to your GitHub project so that we can check your code. |
About what you saw: this fork: void AsyncWebSocketClient::_clearQueue() {
while (!_messageQueue.empty() && _messageQueue.front().finished())
_messageQueue.pop_front();
} esphone: void AsyncWebSocket::_cleanBuffers()
{
AsyncWebLockGuard l(_lock);
for(AsyncWebSocketMessageBuffer * c: _buffers){
if(c && c->canDelete()){
_buffers.remove(c);
}
}
}++ They do the same thing, except on different data structures. |
Thank you very much for your fast response. I will work on a minimal reproducible code sample to see where I went wrong.
|
Problem has been solved thank you. Turns out to have indeed been a corrupted pointer. |
Hi there, thank you for your wonderful library that allows one to upgrade to use ArduinoJson7...
Description
platform = [email protected]
framework = espidf, arduino
My issue is as follows:
When changing from
https://github.com/esphome/ESPAsyncWebServer
to https://github.com/mathieucarbou/ESPAsyncWebServer
And opening a websocket connection, there is instantly a crash which occurs once the websocket is open.
This did not happen before on the esphome version.
When comparing libraries, it appears the issue is in the _onAck function where your library runs _clearQueue(). The esphome library runs _cleanBuffers() instead which checks if a buffer is available to delete before doing so. I suspect the issue is upon freeing the memory for a websocket event in the queue.
Board: esp32s3
Ethernet adapter used: W5500
Stack trace
The text was updated successfully, but these errors were encountered: