esp_http_client_cleanup crashes with LoadProhibited (reproducable)

bassie127
Posts: 8
Joined: Mon Jan 04, 2021 8:19 pm

esp_http_client_cleanup crashes with LoadProhibited (reproducable)

Postby bassie127 » Mon Jan 04, 2021 8:39 pm

In my code the only thing I do is HTTP Post to telelgram.org every 10 seconds.
After 6 or 7 succesful POST messages, the program crashes (easily reproducable).

My code is based on the official http_post example. And wifi connection is based on the wifi connection example.
I am using esp idf v4.2.

Output log is below:

Code: Select all


rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:7060
load:0x40078000,len:13664
load:0x40080400,len:4632
0x40080400: _init at ??:?

entry 0x400806f4
I (29) boot: ESP-IDF v4.2-47-g2532ddd9f 2nd stage bootloader
I (29) boot: compile time 20:56:59
I (29) boot: chip revision: 1
I (33) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (49) boot.esp32: SPI Speed      : 40MHz
I (49) boot.esp32: SPI Mode       : DIO
I (49) boot.esp32: SPI Flash Size : 16MB
I (54) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (63) boot: ## Label            Usage          Type ST Offset   Length
I (70) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (78) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (85) boot:  2 factory          factory app      00 00 00010000 00100000
I (93) boot:  3 coredump         Unknown data     01 03 00110000 00010000
I (100) boot: End of partition table
I (104) boot_comm: chip revision: 1, min. application chip revision: 0
I (111) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x23428 (144424) map
I (181) esp_image: segment 1: paddr=0x00033450 vaddr=0x3ffb0000 size=0x04fd4 ( 20436) load
I (190) esp_image: segment 2: paddr=0x0003842c vaddr=0x40080000 size=0x00404 (  1028) load
0x40080000: _WindowOverflow4 at /home/baswi/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730

I (191) esp_image: segment 3: paddr=0x00038838 vaddr=0x40080404 size=0x077e0 ( 30688) load
I (213) esp_image: segment 4: paddr=0x00040020 vaddr=0x400d0020 size=0x97f1c (622364) map
0x400d0020: _stext at ??:?

I (473) esp_image: segment 5: paddr=0x000d7f44 vaddr=0x40087be4 size=0x11ce8 ( 72936) load
0x40087be4: bb_wdt_int_enable at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7.c:2784

I (523) boot: Loaded app from partition at offset 0x10000
I (523) boot: Disabling RNG early entropy source...
I (524) psram: This chip is ESP32-D0WD
I (529) spiram: Found 64MBit SPI RAM device
I (533) spiram: SPI RAM mode: flash 40m sram 40m
I (538) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (545) cpu_start: Pro cpu up.
I (549) cpu_start: Application information:
I (554) cpu_start: Project name:     template-app
I (559) cpu_start: App version:      1
I (564) cpu_start: Compile time:     Jan  4 2021 20:56:43
I (570) cpu_start: ELF file SHA256:  9dcdd42ee545372d...
I (576) cpu_start: ESP-IDF:          v4.2-47-g2532ddd9f
I (582) cpu_start: Starting app cpu, entry point is 0x40081b74
0x40081b74: call_start_cpu1 at /home/baswi/esp-idf/components/esp32/cpu_start.c:287

I (0) cpu_start: App cpu up.
I (1473) spiram: SPI SRAM memory test OK
I (1474) heap_init: Initializing. RAM available for dynamic allocation:
I (1474) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1480) heap_init: At 3FFBA718 len 000258E8 (150 KiB): DRAM
I (1487) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1493) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1500) heap_init: At 400998CC len 00006734 (25 KiB): IRAM
I (1506) cpu_start: Pro cpu start user code
I (1511) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (1533) spi_flash: detected chip: generic
I (1533) spi_flash: flash io: dio
I (1533) esp_core_dump_flash: Init core dump to flash
I (1546) esp_core_dump_flash: Found partition 'coredump' @ 110000 65536 bytes
I (1570) esp_core_dump_flash: Found core dump 19916 bytes in flash @ 0x110000
I (1570) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1577) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1637) wifi:wifi driver task: 3ffd1c1c, prio:23, stack:6656, core=0
I (1637) system_api: Base MAC address is not set
I (1637) system_api: read default base MAC address from EFUSE
I (1667) wifi:wifi firmware version: 1865b55
I (1667) wifi:wifi certification version: v7.0
I (1667) wifi:config NVS flash: enabled
I (1667) wifi:config nano formating: disabled
I (1667) wifi:Init data frame dynamic rx buffer num: 32
I (1677) wifi:Init management frame dynamic rx buffer num: 32
I (1677) wifi:Init management short buffer num: 32
I (1687) wifi:Init static tx buffer num: 16
I (1687) wifi:Init tx cache buffer num: 32
I (1687) wifi:Init static rx buffer size: 1600
I (1697) wifi:Init static rx buffer num: 10
I (1697) wifi:Init dynamic rx buffer num: 32
I (1707) wifi_init: rx ba win: 6
I (1707) wifi_init: tcpip mbox: 32
I (1707) wifi_init: udp mbox: 6
I (1717) wifi_init: tcp mbox: 6
I (1717) wifi_init: tcp tx win: 5744
I (1727) wifi_init: tcp rx win: 5744
I (1727) wifi_init: tcp mss: 1440
I (1727) wifi_init: WiFi IRAM OP enabled
I (1737) wifi_init: WiFi RX IRAM OP enabled
I (1737) example_connect: Connecting to netwerk2...
I (1847) phy: phy_version: 4500, 0cd6843, Sep 17 2020, 15:37:07, 0, 0
I (1847) wifi:mode : sta (10:52:1c:66:e2:fc)
I (1857) example_connect: Waiting for IP(s)
I (1977) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1977) wifi:state: init -> auth (b0)
I (1997) wifi:state: auth -> assoc (0)
I (2027) wifi:state: assoc -> run (10)
I (2137) wifi:connected with netwerk2, aid = 4, channel 1, BW20, bssid = 18:82:8c:68:a7:33
I (2137) wifi:security: WPA2-PSK, phy: bgn, rssi: -56
I (2137) wifi:pm start, type: 1

I (2197) wifi:AP's beacon interval = 102400 us, DTIM period = 3
I (3127) esp_netif_handlers: example_connect: sta ip: 192.168.1.164, mask: 255.255.255.0, gw: 192.168.1.1
I (3127) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.1.164
I (3627) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:1252:1cff:fe66:e2fc, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (3627) example_connect: Connected to example_connect: sta
I (3637) example_connect: - IPv4 address: 192.168.1.164
I (3637) example_connect: - IPv6 address: fe80:0000:0000:0000:1252:1cff:fe66:e2fc, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (3657) ***: Connected to AP, begin http example
I (3657) ***:   End of setup()


I (3657) ***: HTTP_EVENT_DISCONNECTED
I (3667) ***: Last esp error code: 0x103
I (3667) ***: Last mbedtls failure: 0x0
I (4577) ***: HTTP_EVENT_DISCONNECTED
I (14577) ***: HTTP_EVENT_DISCONNECTED
I (14577) ***: Last esp error code: 0x103
I (14577) ***: Last mbedtls failure: 0x0
I (15487) ***: HTTP_EVENT_DISCONNECTED
I (25487) ***: HTTP_EVENT_DISCONNECTED
I (25487) ***: Last esp error code: 0x103
I (25487) ***: Last mbedtls failure: 0x0
I (26577) ***: HTTP_EVENT_DISCONNECTED
I (36577) ***: HTTP_EVENT_DISCONNECTED
I (36577) ***: Last esp error code: 0x103
I (36577) ***: Last mbedtls failure: 0x0
I (37637) ***: HTTP_EVENT_DISCONNECTED
I (47637) ***: HTTP_EVENT_DISCONNECTED
I (47637) ***: Last esp error code: 0x103
I (47637) ***: Last mbedtls failure: 0x0
I (48657) ***: HTTP_EVENT_DISCONNECTED
I (58667) ***: HTTP_EVENT_DISCONNECTED
I (58667) ***: Last esp error code: 0x103
I (58667) ***: Last mbedtls failure: 0x0
I (59607) ***: HTTP_EVENT_DISCONNECTED
I (69607) ***: HTTP_EVENT_DISCONNECTED
I (69607) ***: Last esp error code: 0x103
I (69607) ***: Last mbedtls failure: 0x0
I (70707) ***: HTTP_EVENT_DISCONNECTED
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4008e29a  PS      : 0x00060730  A0      : 0x800f799f  A1      : 0x3ffc96c0  
0x4008e29a: xQueueGenericSend at /home/baswi/esp-idf/components/freertos/queue.c:728 (discriminator 4)

A2      : 0xe331c000  A3      : 0x3ffc9700  A4      : 0xffffffff  A5      : 0x00000000  
A6      : 0x00000000  A7      : 0x00000001  A8      : 0x8008e27f  A9      : 0x3ffc96a0  
A10     : 0x00000002  A11     : 0x00000000  A12     : 0x00000000  A13     : 0x3ffbbab0  
A14     : 0x000000fe  A15     : 0x00000001  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xe331c000  LBEG    : 0x40089a7a  LEND    : 0x40089a85  LCOUNT  : 0x00000000  
0x40089a7a: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:150

0x40089a85: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:160


Backtrace:0x4008e297:0x3ffc96c0 0x400f799c:0x3ffc9700 0x400e5320:0x3ffc9730 0x400fab1a:0x3ffc9760 0x400fab8e:0x3ffc9780 0x400fb166:0x3ffc97d0 0x400fa656:0x3ffc97f0 0x40104050:0x3ffc9810 0x400fe9a1:0x3ffc9830 0x400fe36f:0x3ffc9850 0x401521e1:0x3ffc9870 0x401669ff:0x3ffc9890 0x400ff603:0x3ffc98b0 0x400ff619:0x3ffc98d0 0x400d94b3:0x3ffc98f0 0x4008b531:0x3ffc9910
0x4008e297: xQueueGenericSend at /home/baswi/esp-idf/components/freertos/queue.c:723 (discriminator 3)

0x400f799c: sys_mbox_post at /home/baswi/esp-idf/components/lwip/port/esp32/freertos/sys_arch.c:248

0x400e5320: tcpip_send_msg_wait_sem at /home/baswi/esp-idf/components/lwip/lwip/src/api/tcpip.c:461 (discriminator 2)

0x400fab1a: netconn_apimsg at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:136

0x400fab8e: netconn_close_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:1124 (discriminator 2)

0x400fb166: netconn_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:1178 (discriminator 8)

0x400fa656: lwip_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/sockets.c:2781

0x40104050: shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/include/lwip/sockets.h:628
 (inlined by) mbedtls_net_free at /home/baswi/esp-idf/components/mbedtls/port/net_sockets.c:437

0x400fe9a1: esp_mbedtls_conn_delete at /home/baswi/esp-idf/components/esp-tls/esp_tls_mbedtls.c:198

0x400fe36f: esp_tls_conn_destroy at /home/baswi/esp-idf/components/esp-tls/esp_tls.c:107

0x401521e1: ssl_close at /home/baswi/esp-idf/components/tcp_transport/transport_ssl.c:173

0x401669ff: esp_transport_close at /home/baswi/esp-idf/components/tcp_transport/transport.c:214

0x400ff603: esp_http_client_close at /home/baswi/esp-idf/components/esp_http_client/esp_http_client.c:1228

0x400ff619: esp_http_client_cleanup at /home/baswi/esp-idf/components/esp_http_client/esp_http_client.c:622

0x400d94b3: task_sendAlert2Telegram(void*) at /home/baswi/Documents/PlatformIO/Projects/idf-ext/telegram2/build/../main/main.cpp:121

0x4008b531: vPortTaskWrapper at /home/baswi/esp-idf/components/freertos/xtensa/port.c:143



ELF file SHA256: 9dcdd42ee545372d

I (17107) esp_core_dump_flash: Save core dump to flash...
I (17113) esp_core_dump_elf: Found tasks: 10
I (17119) esp_core_dump_flash: Erase flash 16384 bytes @ 0x110000
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x40085c8d  PS      : 0x00060233  A0      : 0x800d4189  A1      : 0x3ffc9450  
0x40085c8d: esp_flash_erase_region at /home/baswi/esp-idf/components/spi_flash/esp_flash_api.c:301 (discriminator 7)

A2      : 0x227b3a22  A3      : 0xc000e67f  A4      : 0x00004000  A5      : 0xffffffff  
A6      : 0x00004000  A7      : 0xfffffff9  A8      : 0x80085c87  A9      : 0x3ffc9430  
A10     : 0x00000001  A11     : 0x3ffc9406  A12     : 0x3ffc93af  A13     : 0x00000030  
A14     : 0x00000000  A15     : 0x3ffc93b7  SAR     : 0x00000005  EXCCAUSE: 0x0000001c  
EXCVADDR: 0xc000e693  LBEG    : 0x40089a7a  LEND    : 0x40089a85  LCOUNT  : 0x00000000  
0x40089a7a: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:150

0x40089a85: memset at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/machine/xtensa/memset.S:160


Backtrace:0x40085c8a:0x3ffc9450 0x400d4186:0x3ffc9490 0x400d5478:0x3ffc94b0 0x400d499e:0x3ffc94f0 0x400d42bc:0x3ffc9510 0x4008af9c:0x3ffc9530 0x4008b215:0x3ffc95a0 0x4008b50d:0x3ffc95e0 0x400847a2:0x3ffc9600 0x4008e297:0x3ffc96c0 0x400f799c:0x3ffc9700 0x400e5320:0x3ffc9730 0x400fab1a:0x3ffc9760 0x400fab8e:0x3ffc9780 0x400fb166:0x3ffc97d0 0x40085c8a: esp_flash_erase_region at /home/baswi/esp-idf/components/spi_flash/esp_flash_api.c:301 (discriminator 7)

0x400d4186: esp_core_dump_flash_write_prepare at /home/baswi/esp-idf/components/espcoredump/src/core_dump_flash.c:161

0x400d5478: esp_core_dump_write_elf at /home/baswi/esp-idf/components/espcoredump/src/core_dump_elf.c:604

0x400d499e: esp_core_dump_write at /home/baswi/esp-idf/components/espcoredump/src/core_dump_common.c:248 (discriminator 3)

0x400d42bc: esp_core_dump_to_flash at /home/baswi/esp-idf/components/espcoredump/src/core_dump_flash.c:257

0x4008af9c: esp_panic_handler at /home/baswi/esp-idf/components/esp_system/panic.c:286

0x4008b215: panic_handler at /home/baswi/esp-idf/components/esp_system/port/panic_handler.c:537

0x4008b50d: xt_unhandled_exception at /home/baswi/esp-idf/components/esp_system/port/panic_handler.c:551

0x400847a2: _xt_user_exc at /home/baswi/esp-idf/components/freertos/xtensa/xtensa_vectors.S:697

0x4008e297: xQueueGenericSend at /home/baswi/esp-idf/components/freertos/queue.c:723 (discriminator 3)

0x400f799c: sys_mbox_post at /home/baswi/esp-idf/components/lwip/port/esp32/freertos/sys_arch.c:248

0x400e5320: tcpip_send_msg_wait_sem at /home/baswi/esp-idf/components/lwip/lwip/src/api/tcpip.c:461 (discriminator 2)

0x400fab1a: netconn_apimsg at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:136

0x400fab8e: netconn_close_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:1124 (discriminator 2)

0x400fb166: netconn_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/api_lib.c:1178 (discriminator 8)

0x400fa656:0x3ffc97f0 0x40104050:0x3ffc9810 0x400fe9a1:0x3ffc9830 0x400fe36f:0x3ffc9850 0x401521e1:0x3ffc9870 0x401669ff:0x3ffc9890 0x400ff603:0x3ffc98b0 0x400ff619:0x3ffc98d0 0x400d94b3:0x3ffc98f0 0x4008b531:0x3ffc9910
0x400fa656: lwip_shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/api/sockets.c:2781

0x40104050: shutdown at /home/baswi/esp-idf/components/lwip/lwip/src/include/lwip/sockets.h:628
 (inlined by) mbedtls_net_free at /home/baswi/esp-idf/components/mbedtls/port/net_sockets.c:437

0x400fe9a1: esp_mbedtls_conn_delete at /home/baswi/esp-idf/components/esp-tls/esp_tls_mbedtls.c:198

0x400fe36f: esp_tls_conn_destroy at /home/baswi/esp-idf/components/esp-tls/esp_tls.c:107

0x401521e1: ssl_close at /home/baswi/esp-idf/components/tcp_transport/transport_ssl.c:173

0x401669ff: esp_transport_close at /home/baswi/esp-idf/components/tcp_transport/transport.c:214

0x400ff603: esp_http_client_close at /home/baswi/esp-idf/components/esp_http_client/esp_http_client.c:1228

0x400ff619: esp_http_client_cleanup at /home/baswi/esp-idf/components/esp_http_client/esp_http_client.c:622

0x400d94b3: task_sendAlert2Telegram(void*) at /home/baswi/Documents/PlatformIO/Projects/idf-ext/telegram2/build/../main/main.cpp:121

0x4008b531: vPortTaskWrapper at /home/baswi/esp-idf/components/freertos/xtensa/port.c:143



ELF file SHA256: 9dcdd42ee545372d

Re-entered core dump! Exception happened during core dump!
Rebooting...
ets Jun  8 2016 00:22:57
And my program code:

Code: Select all

#include <esp_event_loop.h>
#include <esp_log.h>
#include <esp_system.h>
#include <nvs_flash.h>
#include <sys/param.h>

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include <stdio.h>
#include <cstring>

#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "freertos/event_groups.h"


#include "esp_http_client.h"
#include "protocol_examples_common.h"
#include "esp_tls.h"
#include "esp_http_server.h"
#include "time.h"

#define TLG_TOKEN "mytoken"
              
static const char *TAG = "***";

bool wifi_has_ip = false;

esp_err_t _http_event_handler(esp_http_client_event_t *evt); //forward declaration
esp_http_client_handle_t http_client; 

#define MAX_HTTP_OUTPUT_BUFFER 2048 
char http_response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};

esp_http_client_config_t http_config = { 
    .host = "api.telegram.org",
    .path = "/bot",
    .query = "esp",
    .event_handler = _http_event_handler,
    .user_data = http_response_buffer,        // Pass address of global buffer to get response; made buffer global to avoid stack overflow
  };
  

esp_err_t _http_event_handler(esp_http_client_event_t *evt)
{
    static char *output_buffer;  // Buffer to store response of http request from event handler
    static int output_len;       // Stores number of bytes read
    switch(evt->event_id) {
        case HTTP_EVENT_ERROR:
            ESP_LOGD(TAG, "HTTP_EVENT_ERROR");
            break;
        case HTTP_EVENT_ON_CONNECTED:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_CONNECTED");
            break;
        case HTTP_EVENT_HEADER_SENT:
            ESP_LOGD(TAG, "HTTP_EVENT_HEADER_SENT");
            break;
        case HTTP_EVENT_ON_HEADER:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", evt->header_key, evt->header_value);
            break;
        case HTTP_EVENT_ON_DATA:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
            /*
             *  Check for chunked encoding is added as the URL for chunked encoding used in this example returns binary data.
             *  However, event handler can also be used in case chunked encoding is used.
             */
            if (!esp_http_client_is_chunked_response(evt->client)) {
                // If user_data buffer is configured, copy the response into the buffer
                if (evt->user_data) {
                    memcpy(evt->user_data + output_len, evt->data, evt->data_len);
                } else {
                    if (output_buffer == NULL) {
                        output_buffer = (char *) malloc(esp_http_client_get_content_length(evt->client));
                        output_len = 0;
                        if (output_buffer == NULL) {
                            ESP_LOGE(TAG, "Failed to allocate memory for output buffer");
                            return ESP_FAIL;
                        }
                    }
                    memcpy(output_buffer + output_len, evt->data, evt->data_len);
                }
                output_len += evt->data_len;
            }

            break;
        case HTTP_EVENT_ON_FINISH:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_FINISH");
            if (output_buffer != NULL) {
                // Response is accumulated in output_buffer. Uncomment the below line to print the accumulated response
                ESP_LOG_BUFFER_HEX(TAG, output_buffer, output_len);
                free(output_buffer);
                output_buffer = NULL;
                output_len = 0;
            }
            break;
        case HTTP_EVENT_DISCONNECTED:
            ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED");
            int mbedtls_err = 0;
            esp_err_t err = esp_tls_get_and_clear_last_error((esp_tls_last_error*)evt->data, &mbedtls_err, NULL);
            if (err != 0) {
                if (output_buffer != NULL) {
                    free(output_buffer);
                    output_buffer = NULL;
                    output_len = 0;
                }
                ESP_LOGI(TAG, "Last esp error code: 0x%x", err);
                ESP_LOGI(TAG, "Last mbedtls failure: 0x%x", mbedtls_err);
            }
            break;
    }
    return ESP_OK;
}


static void task_sendAlert2Telegram(void *ignore) {
  for (;;) {
    esp_http_client_handle_t http_client = esp_http_client_init(&http_config); 
    ESP_ERROR_CHECK(esp_http_client_set_url(http_client, "https://api.telegram.org/bot674653520:AAERJg5chmEQyJRpQhG2Bpg-enFVUSAMNsI/sendMessage?chat_id=573364432&text=DING%20DONG%20http://192.168.1.164/stream%20http://192.168.1.164/capture"));
    ESP_ERROR_CHECK(esp_http_client_perform(http_client));
    ESP_ERROR_CHECK(esp_http_client_cleanup(http_client)); //cleanup function calls close function itself, and close crashes sometimes
    // do not send alerts faster than every x seconds
    vTaskDelay(10000/portTICK_PERIOD_MS); 
  }
}


extern "C" {
   void app_main();
}

void app_main()
{
  esp_err_t ret = nvs_flash_init();
  if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
    ESP_ERROR_CHECK(nvs_flash_erase());
    ret = nvs_flash_init();
  }
  ESP_ERROR_CHECK(ret);
  ESP_ERROR_CHECK(esp_netif_init());
  ESP_ERROR_CHECK(esp_event_loop_create_default());

  /* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
   * Read "Establishing Wi-Fi or Ethernet Connection" section in
   * examples/protocols/README.md for more information about this function.
   */
  ESP_ERROR_CHECK(example_connect());
  ESP_LOGI(TAG, "Connected to AP, begin http example");
 
  xTaskCreate((TaskFunction_t)&task_sendAlert2Telegram, "task_sendAlert2Telegram",  4096,
          		  NULL, 5, NULL);
 
  ESP_LOGI(TAG, "  End of setup()\n\n");
}
I am really stuck; any help is appreciated1
Thanks

xxbbt123
Posts: 1
Joined: Thu Nov 10, 2022 4:56 pm

Re: esp_http_client_cleanup crashes with LoadProhibited (reproducable)

Postby xxbbt123 » Thu Nov 10, 2022 4:57 pm

Hi,

I know this is a bit long ago but did you figure out a solution? I am having a very similiar issue

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: esp_http_client_cleanup crashes with LoadProhibited (reproducable)

Postby ESP_Mahavir » Fri Nov 11, 2022 4:24 am

Hello,

Can you share your application code? You may modify example https://github.com/espressif/esp-idf/tr ... ttp_client here that can recreate this issue.

Who is online

Users browsing this forum: Google [Bot], robizzar72 and 78 guests