Heap corruption on socket write or send

beckmx
Posts: 9
Joined: Tue Aug 27, 2019 3:55 am

Heap corruption on socket write or send

Postby beckmx » Tue Aug 27, 2019 4:05 am

I have noticed that sometimes, socket has problems allocating memory and creates an overflow, sometimes it happens randomly and then it works other times, it happens in two different random scenarios when I try to write to a socket or send to a socket.

This is the code I use:
I defined two tasks in the app_main.c

Code: Select all

xTaskCreate(&beat_task, "one_task", 2048, NULL, 4, NULL);
ESP_ERROR_CHECK( heap_trace_init_standalone(trace_record, NUM_RECORDS) );
xTaskCreate(&suitch_task, "two_task", 2048, NULL, 5, NULL);
The first task runs perfectly however the second one sometimes in this line cannot continue:
s is a socket var, req is a pointer with dynamic value (this value is correctly filled)

Code: Select all

ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
if (write(s, req, strlen(req)) < 0) {<<<<<problem here
ESP_LOGE(TAG, "... socket send failed");
close(s);
vTaskDelay(4000 / portTICK_PERIOD_MS);
continue;
}

Who is online

Users browsing this forum: No registered users and 58 guests