-
Notifications
You must be signed in to change notification settings - Fork 7.6k
assertion "pbuf_free: p->ref > 0" failed: file #2685
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
Comments
Hi! I have the same problem than Chriserke but with different hardware. Hardware:Board: WEMOS LOLIN32 Description:As soon as the udp packet is received, the mcu resets with following serial message:
I also tried to comment out everything inside the udp.onPacket(AsyncUDPPacket packet) {} to make sure that this has nothing to do with string problems. Sketch:#include "WiFi.h"
#include "AsyncUDP.h"
const char * ssid = "SSID";
const char * password = "1234";
String client_address = "C01";
int udpPort = 7001; // Make sure this port matches the 'Server' port!
int Control_pin = 22; // The device pin on the client to control e.g. an LED or Relay On/Off
String received_message;
AsyncUDP udp;
void setup()
{
delay(5000);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
while (1) {
delay(1000);
}
}
Serial.println("Listening on Port: " + String(udpPort));
if (udp.listen(udpPort)) {
Serial.print("UDP Listening on IP: ");
Serial.println(WiFi.localIP());
udp.onPacket([](AsyncUDPPacket packet) {
//received_message = packet.readStringUntil('\n');
//Serial.println(received_message);
//received_message.trim(); // Remove unwanted characters
// Test for a valid message structure
// if (received_message.startsWith(client_address) || received_message.startsWith("HAC") || received_message.startsWith("LAC"))
// { // e.g. C01H or C)1L or ACH or ACL
// if (received_message.endsWith("H")) {
// Serial.println("Turning ON Device for " + client_address);
// Device_Control("ON");
// }
// if (received_message.endsWith("L")) {
// Serial.println("Turning OFF Device for " + client_address);
// Device_Control("OFF");
// }
// if (received_message == "HAC") {
// Serial.println("Turning ON Device for " + client_address + " - global ON");
// Device_Control("ON");
// }
// if (received_message == "LAC") {
// Serial.println("Turning OFF Device for " + client_address + " - global OFF");
// Device_Control("OFF");
// }
// }
});
}
//udp.broadcast("Device operated correctly");
}
void loop()
{
Serial.println("mainloop running");
delay(1000);
Device_Control("ON");
delay(1000);
Device_Control("OFF");
}
void Device_Control(String Device_mode) {
if (Device_mode == "ON") {
pinMode(Control_pin, OUTPUT);
digitalWrite(Control_pin, HIGH);
}
else {
pinMode(Control_pin, OUTPUT);
digitalWrite(Control_pin, LOW);
}
} Debug Messages:
|
revert this change and give it a go: a87b2ec#diff-3b5c94ff125c7d1f27ea52a9139410ec |
Reverting works for me. I don't see any memory leaking between receives. |
Now i can run the UDPAsync example, works fine thanks. |
I had the same problem today....May 2019 |
#MeToo using AsyncUDP just after updating to ESP boards v1.0.2 and got this error upon receiving UDP packets. assertion "pbuf_free: p->ref > 0" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/lwip/lwip/src/core/pbuf.c", line 765, function: pbuf_free Backtrace: 0x4008c88c:0x3ffc9fc0 0x4008cabd:0x3ffc9fe0 0x400dfc0f:0x3ffca000 0x400fa29f:0x3ffca030 0x400d9e7f:0x3ffca050 0x400d9ecf:0x3ffca0e0 0x40088829:0x3ffca110 Rebooting... Reverting to v1.0.1 fixed things |
change is reverted. will be released soon. |
So if I understand this correctly, this relies on the callback accepting the packet by value and not by reference (as specified in AsyncUDP.h). This will call the destructor twice but use the copy constructor for cloning the object. Accepting the packet by reference will therefore leak memory (and eventually crash) as the destructor is only called once. This is immediately noticed as the ESP stops receiving packets. Doing anything in the callback function that would call the copy constructor will also crash as pbuf_unref() is now called without a prior call to pbuf_ref(). If this is intended behaviour it would be nice to note this somewhere. Without looking through the source files I find this to be rather counter-intuitive. :-) It should be possible to fix this by either adding another call to pbuf_ref() to the copy constuctor or removing the ref'ing from the packet class alltogether. |
@me-no-dev I downloaded the latest code to AsyncUDP but I still have the same issue.
If I comment the line 329 in AsyncUDP.cpp the crash isn't happen, but the packets works 1 time and I need wait between five and ten minutes to send the packets again. Line 329:
Board: Espressif ESP32 Dev Module |
Newer plattform has support for saving configuration, older need older async-tcp.
* GPS and Motordriver working. Really ugly hacks, needs cleanup * Cleanup, removing bno, preparing for generic imu correction * generic correction (https://appelsiini.net/2018/calibrate-magnetometer/) * LSM9DS1 implemented * Implemented calibrationone bug: lsm9ds1 filter are way to slow * Better IMU Reset, some cleanups, fixed save/restore * only write on I2C if something changed * changed to 50hz to reduce cpu util * Implemented Ackermann * removed a line by mistake * fix typo * Workaround for espressif/arduino-esp32#2685 Newer plattform has support for saving configuration, older need older async-tcp. * Put some dependencys in the plattformio.ini Removed (nearly) all code to set up the new config/setup. Features should be copied back later. * Start wifiAp and nothing else if HW not initialized * cleanup * Added new submodule * Copy files for the espui in the data directory * changed partition * core webui start * no change in memory, easier a single firmware instead spiffs-dedendencys * removed mdns, no real benefit in test-setup * working idleStats * Only one namespace for configuration. Implemented HW chooser * rename example to make it consistent (all hardware that is not on I2C in the init) * Begin of the "IO-Abtraction-Layer" * Start of IO abstraction, fixed preferences * start LED-Task earlier * less global data, added logik for pwm * allow the ads1115 differential measureings compared to A3 (e.g. VCC) instead to gnd (normal single ended mode). Should result in better results with ratiometric sensors and a not 100% stable 5V source * some addition to the init process (still WI) * switched ads1115 library. Removed soe (currently) unsused dependencys * IO abstraction now contains the ads1115 * completed features for IO abstraction * Network Setup * allowed SSID selektion in AP mode (hostname in emergency/config mode * First webinterface for the network setup * Added Label-Field for PGNs, correction of intendation * introduced a variable with the local IP (accessing can be different ETH/WiFi) => abtraction needed * Created the UDP PGN handler (sending/receiving) - untested ATM * undo the revert to broken idlestats * start threads * Working PGN exchange * implemented (not yet tested) the different rtcm sources * preperations to seperate the common rtcm and nmea tasks, since file gets too long * disbaled fixed uload port * network for nodemcu * Move nmea structures in new files * some adjustments on the network webinterface * prepared for UI via SPIFFs * removed upstream ESPUI module, own fork until bug s00500/ESPUI#63 is fixed * added fork from ESPUI * Nmea implementation * moved all status updates on the Network core, try to avoid heap coruption (some used libraries seems not to bee thread safe) * removed own fork, upstream fixed the issue * added ESPUI * Added json document size * Better Wifihandling * avoid multithread updated of the webUI * minor fixes * put all status updates in one task to avoid crashes of the webui, removed bluetooth (arduino seems to have problems enabling wifi and BT at the same time, since the radio is shared and the options for the different "coexistence"-parameters are not accessible. * small fixes for gps setup and output * some backgroundtasks only if not in setup-mode/hw * Moved disabling of updated * added debug messages. Fixed reading digital inputs from the fxl6408 and address offsets * small fixes (udp intervall, more info/error messages * after talking to the espui dev the spiffs-variant has only a minor performance benefit, so remove the data directry for simplification (so spiffs setup planed anymore) * moved networking code from hwSetup to network to make files smaller/better to understand. Names of functions/variables not yet refactored * created functionpointer for analogIn; added two special values (true/false or zero / one) * implemented work- and steerswitch * moved inputs from hw specific to general init * moved gps-init (esp. the async udp part) after network init * fixed missing i2c locks * added wheel angle reading * Added digital out selectors and utun-relay control * fixed GUI for uturn * changed PWM to 10 bit (finer control => good 8 bit usable after minpwm * added motor to ioAccess and init f9p board * Added a modofied AutoPID (symmetrical) * fixed datatype in the header * added steering actuator * small fix in the GUI (control in the wron tab) * save in the right label * distribute the time a bit more, to reduce further the risk of a rce condition in the not threadsafe webserver * show when PWm-Test is active * use dutyCycle ... * bugfixes to enable steering (steering enabled = false; preferences in the main thread => datastructures
Why am i getting this error and how would i go about fixing it?
EDIT: commenting line 329 pbuf_free(_pb); in AsyncUDP.cpp removes the problem but doesnt clear the buffer. So im not able to recieve anything anymore after about 7-8 times
The text was updated successfully, but these errors were encountered: