mbedTLS with dynamic memory [IDFGH-4803]

bigfede
Posts: 9
Joined: Wed Feb 17, 2021 10:54 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby bigfede » Fri Mar 26, 2021 3:23 pm

Not working. Sorry for my late reply. Here below some logs.
The same code works with STATIC memory in mbedTLS, but once i switch with DYNAMIC it returns an error.

I (29581) mbedtls: ssl_tls.c:8203 => handshake

I (29581) mbedtls: ssl_cli.c:3785 client state: 0

I (29581) mbedtls: ssl_tls.c:2847 => flush output

I (29581) mbedtls: ssl_tls.c:2859 <= flush output

I (29591) mbedtls: ssl_cli.c:3785 client state: 1

I (29591) mbedtls: ssl_tls.c:2847 => flush output

I (29601) mbedtls: ssl_tls.c:2859 <= flush output

I (29601) mbedtls: ssl_cli.c:805 => write client hello

I (29611) mbedtls: ssl_tls.c:3286 => write handshake message

I (29621) mbedtls: ssl_tls.c:3445 => write record

I (29621) mbedtls: ssl_tls.c:2847 => flush output

I (29631) mbedtls: ssl_tls.c:2866 message length: 318, out_left: 318

I (29641) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 318 (-0xfffffec2)

I (29641) mbedtls: ssl_tls.c:2899 <= flush output

I (29651) mbedtls: ssl_tls.c:3578 <= write record

I (29651) mbedtls: ssl_tls.c:3422 <= write handshake message

I (29661) mbedtls: ssl_cli.c:1255 <= write client hello

I (29671) mbedtls: ssl_tls.c:2628 => fetch input

I (29671) mbedtls: ssl_tls.c:2789 in_left: 0, nb_want: 5

I (31371) mbedtls: ssl_tls.c:2813 in_left: 0, nb_want: 5

I (31371) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)

I (31371) mbedtls: ssl_tls.c:2834 <= fetch input

I (31381) mbedtls: ssl_cli.c:3785 client state: 2

I (31381) mbedtls: ssl_tls.c:2847 => flush output

I (31391) mbedtls: ssl_tls.c:2859 <= flush output

I (31391) mbedtls: ssl_cli.c:1684 => parse server hello

I (31401) mbedtls: ssl_tls.c:4419 => read record

I (31401) mbedtls: ssl_tls.c:2628 => fetch input

I (31411) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 5

I (31421) mbedtls: ssl_tls.c:2834 <= fetch input

I (31421) mbedtls: ssl_tls.c:2628 => fetch input

I (31431) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 3820

I (31431) mbedtls: ssl_tls.c:2813 in_left: 5, nb_want: 3820

I (31441) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 1419 (-0xfffffa75)

I (32071) mbedtls: ssl_tls.c:2813 in_left: 1424, nb_want: 3820

I (32071) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 1424 (-0xfffffa70)

I (32421) mbedtls: ssl_tls.c:2813 in_left: 2848, nb_want: 3820

I (32421) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 972 (-0xfffffc34)

I (32421) mbedtls: ssl_tls.c:2834 <= fetch input

I (32431) mbedtls: ssl_tls.c:4493 <= read record

I (32431) mbedtls: ssl_cli.c:2000 server hello, total extension length: 9

I (32441) mbedtls: ssl_cli.c:2200 <= parse server hello

I (32451) mbedtls: ssl_cli.c:3785 client state: 3

I (32451) mbedtls: ssl_tls.c:2847 => flush output

I (32461) mbedtls: ssl_tls.c:2859 <= flush output

I (32461) mbedtls: ssl_tls.c:5763 => parse certificate

I (32471) mbedtls: ssl_tls.c:4419 => read record

I (32471) mbedtls: ssl_tls.c:4493 <= read record

I (32491) mbedtls: ssl_tls.c:5971 <= parse certificate

I (32491) mbedtls: ssl_cli.c:3785 client state: 4

I (32491) mbedtls: ssl_tls.c:2847 => flush output

I (32501) mbedtls: ssl_tls.c:2859 <= flush output

I (32501) mbedtls: ssl_cli.c:2566 => parse server key exchange

I (32511) mbedtls: ssl_tls.c:4419 => read record

I (32521) mbedtls: ssl_tls.c:4493 <= read record

I (32521) mbedtls: ssl_cli.c:2268 ECDH curve: secp256r1

I (32531) mbedtls: ssl_cli.c:2507 Server used SignatureAlgorithm 1

I (32531) mbedtls: ssl_cli.c:2509 Server used HashAlgorithm 4

I (32571) mbedtls: ssl_cli.c:2926 <= parse server key exchange

I (32571) mbedtls: ssl_cli.c:3785 client state: 5

I (32571) mbedtls: ssl_tls.c:2847 => flush output

I (32581) mbedtls: ssl_tls.c:2859 <= flush output

I (32581) mbedtls: ssl_cli.c:2959 => parse certificate request

I (32591) mbedtls: ssl_tls.c:4419 => read record

I (32601) mbedtls: ssl_tls.c:4493 <= read record

I (32601) mbedtls: ssl_cli.c:3115 <= parse certificate request

I (32611) mbedtls: ssl_cli.c:3785 client state: 6

I (32611) mbedtls: ssl_tls.c:2847 => flush output

I (32621) mbedtls: ssl_tls.c:2859 <= flush output

I (32621) mbedtls: ssl_cli.c:3125 => parse server hello done

I (32631) mbedtls: ssl_tls.c:4419 => read record

I (32641) mbedtls: ssl_tls.c:4489 reuse previously read message

I (32641) mbedtls: ssl_tls.c:4493 <= read record

I (32651) mbedtls: ssl_cli.c:3155 <= parse server hello done

I (32661) mbedtls: ssl_cli.c:3785 client state: 7

I (32661) mbedtls: ssl_tls.c:2847 => flush output

I (32671) mbedtls: ssl_tls.c:2859 <= flush output

I (32671) mbedtls: ssl_tls.c:5437 => write certificate

I (32681) mbedtls: ssl_tls.c:5454 <= skip write certificate

I (32681) mbedtls: ssl_cli.c:3785 client state: 8

I (32691) mbedtls: ssl_tls.c:2847 => flush output

I (32701) mbedtls: ssl_tls.c:2859 <= flush output

I (32701) mbedtls: ssl_cli.c:3167 => write client key exchange

I (38781) mbedtls: ssl_tls.c:3286 => write handshake message

I (38781) mbedtls: ssl_tls.c:3445 => write record

I (38781) mbedtls: ssl_tls.c:2847 => flush output

I (38791) mbedtls: ssl_tls.c:2866 message length: 75, out_left: 75

I (38791) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 75 (-0xffffffb5)

I (38801) mbedtls: ssl_tls.c:2899 <= flush output

I (38811) mbedtls: ssl_tls.c:3578 <= write record

I (38811) mbedtls: ssl_tls.c:3422 <= write handshake message

I (38821) mbedtls: ssl_cli.c:3444 <= write client key exchange

I (38831) mbedtls: ssl_cli.c:3785 client state: 9

I (38831) mbedtls: ssl_tls.c:2847 => flush output

I (38841) mbedtls: ssl_tls.c:2859 <= flush output

I (38841) mbedtls: ssl_cli.c:3496 => write certificate verify

I (38851) mbedtls: ssl_tls.c:653 => derive keys

I (38851) mbedtls: ssl_tls.c:1228 => calc verify sha256

I (38861) mbedtls: ssl_tls.c:1234 <= calc verify

I (38871) mbedtls: ssl_tls.c:1139 <= derive keys

I (38871) mbedtls: ssl_cli.c:3525 <= skip write certificate verify

I (38881) mbedtls: ssl_cli.c:3785 client state: 10

I (38881) mbedtls: ssl_tls.c:2847 => flush output

I (38891) mbedtls: ssl_tls.c:2859 <= flush output

I (38891) mbedtls: ssl_tls.c:5987 => write change cipher spec

I (38901) mbedtls: ssl_tls.c:3286 => write handshake message

I (38911) mbedtls: ssl_tls.c:3445 => write record

I (38911) mbedtls: ssl_tls.c:2847 => flush output

I (38921) mbedtls: ssl_tls.c:2866 message length: 6, out_left: 6

I (38931) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 6 (-0xfffffffa)

I (38931) mbedtls: ssl_tls.c:2899 <= flush output

I (38941) mbedtls: ssl_tls.c:3578 <= write record

I (38941) mbedtls: ssl_tls.c:3422 <= write handshake message

I (38951) mbedtls: ssl_tls.c:6001 <= write change cipher spec

I (38961) mbedtls: ssl_cli.c:3785 client state: 11

I (38961) mbedtls: ssl_tls.c:2847 => flush output

I (38971) mbedtls: ssl_tls.c:2859 <= flush output

I (38971) mbedtls: ssl_tls.c:6515 => write finished

I (38981) mbedtls: ssl_tls.c:6331 => calc finished tls sha256

I (38991) mbedtls: ssl_tls.c:6361 <= calc finished

I (38991) mbedtls: ssl_tls.c:3286 => write handshake message

I (39001) mbedtls: ssl_tls.c:3445 => write record

I (39001) mbedtls: ssl_tls.c:1446 => encrypt buf

I (39011) mbedtls: ssl_tls.c:1780 <= encrypt buf

I (39011) mbedtls: ssl_tls.c:2847 => flush output

I (39021) mbedtls: ssl_tls.c:2866 message length: 85, out_left: 85

I (39031) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 85 (-0xffffffab)

I (39041) mbedtls: ssl_tls.c:2899 <= flush output

I (39041) mbedtls: ssl_tls.c:3578 <= write record

I (39051) mbedtls: ssl_tls.c:3422 <= write handshake message

I (39051) mbedtls: ssl_tls.c:6624 <= write finished

I (39061) mbedtls: ssl_tls.c:2628 => fetch input

I (39061) mbedtls: ssl_tls.c:2789 in_left: 0, nb_want: 5

I (39971) mbedtls: ssl_tls.c:2813 in_left: 0, nb_want: 5

I (39971) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)

I (39971) mbedtls: ssl_tls.c:2834 <= fetch input

I (39981) mbedtls: ssl_cli.c:3785 client state: 12

I (39981) mbedtls: ssl_tls.c:2847 => flush output

I (39991) mbedtls: ssl_tls.c:2859 <= flush output

I (39991) mbedtls: ssl_tls.c:6010 => parse change cipher spec

I (40001) mbedtls: ssl_tls.c:4419 => read record

I (40001) mbedtls: ssl_tls.c:2628 => fetch input

I (40011) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 5

I (40021) mbedtls: ssl_tls.c:2834 <= fetch input

I (40021) mbedtls: ssl_tls.c:2628 => fetch input

I (40031) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 6

I (40031) mbedtls: ssl_tls.c:2813 in_left: 5, nb_want: 6

I (40041) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 1 (-0xffffffff)

I (40051) mbedtls: ssl_tls.c:2834 <= fetch input

I (40051) mbedtls: ssl_tls.c:4493 <= read record

I (40061) mbedtls: ssl_tls.c:6074 <= parse change cipher spec

I (40071) mbedtls: ssl_tls.c:2628 => fetch input

I (40071) mbedtls: ssl_tls.c:2789 in_left: 0, nb_want: 5

I (40081) mbedtls: ssl_tls.c:2813 in_left: 0, nb_want: 5

I (40081) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)

I (40091) mbedtls: ssl_tls.c:2834 <= fetch input

I (40101) mbedtls: ssl_cli.c:3785 client state: 13

I (40101) mbedtls: ssl_tls.c:2847 => flush output

I (40111) mbedtls: ssl_tls.c:2859 <= flush output

I (40111) mbedtls: ssl_tls.c:6641 => parse finished

I (40121) mbedtls: ssl_tls.c:6331 => calc finished tls sha256

I (40131) mbedtls: ssl_tls.c:6361 <= calc finished

I (40131) mbedtls: ssl_tls.c:4419 => read record

I (40141) mbedtls: ssl_tls.c:2628 => fetch input

I (40141) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 5

I (40151) mbedtls: ssl_tls.c:2834 <= fetch input

I (40151) mbedtls: ssl_tls.c:2628 => fetch input

I (40161) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 85

I (40171) mbedtls: ssl_tls.c:2813 in_left: 5, nb_want: 85

I (40171) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 80 (-0xffffffb0)

I (40181) mbedtls: ssl_tls.c:2834 <= fetch input

I (40191) mbedtls: ssl_tls.c:1943 => decrypt buf

I (40191) mbedtls: ssl_tls.c:2468 <= decrypt buf

I (40201) mbedtls: ssl_tls.c:4493 <= read record

I (40201) mbedtls: ssl_tls.c:6709 <= parse finished

I (40211) mbedtls: ssl_cli.c:3785 client state: 14

I (40211) mbedtls: ssl_tls.c:2847 => flush output

I (40221) mbedtls: ssl_tls.c:2859 <= flush output

I (40231) mbedtls: ssl_cli.c:3896 handshake: done

I (40231) mbedtls: ssl_cli.c:3785 client state: 15

I (40241) mbedtls: ssl_tls.c:2847 => flush output

I (40241) mbedtls: ssl_tls.c:2859 <= flush output

I (40251) mbedtls: ssl_tls.c:8213 <= handshake

I (40251) 32|TASK: HTTP_EVENT_ON_CONNECTED
I (40261) mbedtls: ssl_tls.c:8805 => write

I (40261) mbedtls: ssl_tls.c:3445 => write record

I (40271) mbedtls: ssl_tls.c:1446 => encrypt buf

I (40281) mbedtls: ssl_tls.c:1780 <= encrypt buf

I (40281) mbedtls: ssl_tls.c:2847 => flush output

I (40291) mbedtls: ssl_tls.c:2866 message length: 293, out_left: 293

I (40291) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 293 (-0xfffffedb)

I (40301) mbedtls: ssl_tls.c:2899 <= flush output

I (40311) mbedtls: ssl_tls.c:3578 <= write record

I (40311) mbedtls: ssl_tls.c:8833 <= write

I (40321) 36|TASK: HTTP_EVENT_HEADER_SENT
W (40321) 242|TASK: POST
I (40331) mbedtls: ssl_tls.c:8805 => write

I (40331) mbedtls: ssl_tls.c:3445 => write record

I (40341) mbedtls: ssl_tls.c:1446 => encrypt buf

I (40341) mbedtls: ssl_tls.c:1780 <= encrypt buf

I (40351) mbedtls: ssl_tls.c:2847 => flush output

I (40351) mbedtls: ssl_tls.c:2866 message length: 85, out_left: 85

I (40361) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 85 (-0xffffffab)

I (40371) mbedtls: ssl_tls.c:2899 <= flush output

I (40371) mbedtls: ssl_tls.c:3578 <= write record

I (40381) mbedtls: ssl_tls.c:8833 <= write

I (40381) 247|TASK: Post Body: {"Hello":"world"}
I (41921) mbedtls: ssl_tls.c:2628 => fetch input

I (41921) mbedtls: ssl_tls.c:2789 in_left: 0, nb_want: 5

I (41921) mbedtls: ssl_tls.c:2813 in_left: 0, nb_want: 5

I (41921) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)

I (41931) mbedtls: ssl_tls.c:2834 <= fetch input

I (41941) mbedtls: ssl_tls.c:8389 => read

I (41941) mbedtls: ssl_tls.c:4419 => read record

I (41951) mbedtls: ssl_tls.c:2628 => fetch input

I (41951) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 5

I (41961) mbedtls: ssl_tls.c:2834 <= fetch input

I (41961) mbedtls: ssl_tls.c:2628 => fetch input

I (41971) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 69

I (41981) mbedtls: ssl_tls.c:2813 in_left: 5, nb_want: 69

I (41981) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 64 (-0xffffffc0)

I (41991) mbedtls: ssl_tls.c:2834 <= fetch input

I (42001) mbedtls: ssl_tls.c:1943 => decrypt buf

I (42001) mbedtls: ssl_tls.c:2468 <= decrypt buf

I (42011) mbedtls: ssl_tls.c:4493 <= read record

W (42011) mbedtls: ssl_tls.c:8476 received handshake message

I (42021) mbedtls: ssl_tls.c:8258 => renegotiate

I (42031) mbedtls: ssl_tls.c:8203 => handshake

I (42031) mbedtls: ssl_cli.c:3785 client state: 0

I (42041) mbedtls: ssl_tls.c:2847 => flush output

I (42041) mbedtls: ssl_tls.c:2859 <= flush output

I (42051) mbedtls: ssl_cli.c:3785 client state: 1

I (42051) mbedtls: ssl_tls.c:2847 => flush output

I (42061) mbedtls: ssl_tls.c:2859 <= flush output

I (42061) mbedtls: ssl_cli.c:805 => write client hello

I (42071) mbedtls: ssl_tls.c:3286 => write handshake message

I (42081) mbedtls: ssl_tls.c:3445 => write record

I (42081) mbedtls: ssl_tls.c:1446 => encrypt buf

I (42091) mbedtls: ssl_tls.c:1780 <= encrypt buf

I (42091) mbedtls: ssl_tls.c:2847 => flush output

I (42101) mbedtls: ssl_tls.c:2866 message length: 389, out_left: 389

I (42111) mbedtls: ssl_tls.c:2871 ssl->f_send() returned 389 (-0xfffffe7b)

I (42111) mbedtls: ssl_tls.c:2899 <= flush output

I (42121) mbedtls: ssl_tls.c:3578 <= write record

I (42121) mbedtls: ssl_tls.c:3422 <= write handshake message

I (42131) mbedtls: ssl_cli.c:1255 <= write client hello

I (42141) mbedtls: ssl_cli.c:3785 client state: 2

I (42141) mbedtls: ssl_tls.c:2847 => flush output

I (42151) mbedtls: ssl_tls.c:2859 <= flush output

I (42151) mbedtls: ssl_cli.c:1684 => parse server hello

I (42161) mbedtls: ssl_tls.c:4419 => read record

I (42161) mbedtls: ssl_tls.c:2628 => fetch input

I (42171) mbedtls: ssl_tls.c:2789 in_left: 0, nb_want: 5

I (44221) mbedtls: ssl_tls.c:2813 in_left: 0, nb_want: 5

I (44221) mbedtls: ssl_tls.c:2814 ssl->f_recv(_timeout)() returned 5 (-0xfffffffb)

I (44221) mbedtls: ssl_tls.c:2834 <= fetch input

I (44231) mbedtls: ssl_tls.c:2628 => fetch input

I (44231) mbedtls: ssl_tls.c:2789 in_left: 5, nb_want: 3925

Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x40089658 PS : 0x00060b33 A0 : 0x80089b85 A1 : 0x3ffde560
A2 : 0x3ffe4364 A3 : 0xfc4dc21b A4 : 0x8e01d87a A5 : 0x00000002
A6 : 0x00000001 A7 : 0x3ffc4bc0 A8 : 0x3ffec380 A9 : 0x00000013
A10 : 0x00000000 A11 : 0x00000333 A12 : 0x000005f2 A13 : 0xcc34baf8
A14 : 0xcc34bafb A15 : 0x00000019 SAR : 0x0000001a EXCCAUSE: 0x0000001d
EXCVADDR: 0xfc4dc227 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0x00000000

Backtrace:0x40089655:0x3ffde560 0x40089b82:0x3ffde580 0x400816e6:0x3ffde5a0 0x40089e2d:0x3ffde5c0 0x400ebfa8:0x3ffde5e0 0x400ebfff:0x3ffde600 0x400ec08b:0x3ffde620 0x400ecaf4:0x3ffde640 0x400e8eae:0x3ffde660 0x400ea1e7:0x3ffde6a0 0x400ea28e:0x3ffde700 0x400d4b41:0x3ffde720 0x4000bdbb:0x3ffde740 0x400017ea:0x3ffde760 0x4010be39:0x3ffde780 0x40109681:0x3ffde7a0 0x4010a716:0x3ffde7d0 0x4010ea0a:0x3ffde8b0 0x4010c01c:0x3ffde960 0x401082c7:0x3ffde980 0x40108300:0x3ffde9a0 0x40108704:0x3ffde9c0 0x4010bbc8:0x3ffde9e0 0x4010c0ad:0x3ffdea00 0x4010014d:0x3ffdea20 0x4012477b:0x3ffdea40 0x4013cb5f:0x3ffdea60 0x40100c14:0x3ffdea80 0x400dc991:0x3ffdeaa0

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby ESP_YJM » Tue Mar 30, 2021 6:42 am

Could you please offer your project code and reproduce step for me and i can reproduce it on my own environment. Could you please also offer the sdkconfig file and the *.elf file corresponding to your crash.
Last edited by ESP_YJM on Tue Mar 30, 2021 7:48 am, edited 1 time in total.

bigfede
Posts: 9
Joined: Wed Feb 17, 2021 10:54 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby bigfede » Tue Mar 30, 2021 7:21 am

Actually I can't. But the example at the beginning of this thread should reproduce the problem. I can't share with you certificates and the URL for the POST.

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby ESP_YJM » Tue Mar 30, 2021 7:50 am

Okay, could you offer the sdkconfig and the *.elf,which i can disassembled the code.

bigfede
Posts: 9
Joined: Wed Feb 17, 2021 10:54 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby bigfede » Tue Mar 30, 2021 8:31 am

Not possible. I will prepare an example more in detail in a few days. Trust me It' more easy than you expected. It is just an HTTPS client, and I know for sure that the input fragment coming from the server are 16k.

ESP_Faye
Posts: 25
Joined: Thu Dec 10, 2015 6:47 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby ESP_Faye » Wed Apr 07, 2021 9:24 am

Hi bigfede,
bigfede wrote: I will prepare an example more in detail in a few days.
May I ask if there is any update of the example that can reproduce the issue?
We'd like to solve the issue you met, if there is any test example that can help us reproduce it and debug it, it will be very helpful.
Thanks in advance.

bigfede
Posts: 9
Joined: Wed Feb 17, 2021 10:54 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby bigfede » Fri Apr 16, 2021 6:54 am

Hi,
actually I have not time to set up and example. Is it possible to have by your side a IoTHUB and a pair of certificate to autenticate?
If yes, i will rearrange to create an example with your iothub in a couple of days.

Thanks

ESP_Faye
Posts: 25
Joined: Thu Dec 10, 2015 6:47 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby ESP_Faye » Tue Apr 20, 2021 3:12 am

@bigfede, could you provide the server domain you connect to, and also a pair of certificate to authenticate, so we can try to reproduce and analyze the issue you met?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby ESP_YJM » Tue Jun 22, 2021 9:47 am

Hi bigfede,
Could you please try the latest code in ESP-IDF master branch to check this issue?

TomBulsink
Posts: 1
Joined: Thu Jan 26, 2023 8:02 am

Re: mbedTLS with dynamic memory [IDFGH-4803]

Postby TomBulsink » Thu Jan 26, 2023 8:10 am

@ESP_YJM @ESP_Faye

Is there any progress on this issue? I'm having the same problems the topic starter is having when testing a HTTPS POST to Azure using the IDF 4.4.3 tag:

Code: Select all

void StartUpload()
{
  ESP_LOGI("BLOB_UPLOAD", "blob upload started");

  const char* url  = R"(https://***Azure IoT hub URL****/files?api-version=2020-03-13)";
  const char* data = R"({"blobName":"hi_my_name_is_Blob.txt"})";

  static esp_http_client_config_t m_httpConfig = {};
  m_httpConfig.method                          = HTTP_METHOD_POST;
  m_httpConfig.url                             = url;
  m_httpConfig.timeout_ms                      = 30000;
  m_httpConfig.transport_type                  = HTTP_TRANSPORT_OVER_SSL;
  m_httpConfig.crt_bundle_attach               = esp_crt_bundle_attach;
  m_httpConfig.client_cert_pem                 = CDeviceCertificateStore::GetInstance().GetCertificateChain();
  m_httpConfig.client_cert_len                 = 0;
  m_httpConfig.client_key_pem                  = CDeviceCertificateStore::GetInstance().GetPrivateKey();
  m_httpConfig.client_key_len                  = 0;

  m_httpConfig.buffer_size_tx = 4096;
  m_httpConfig.buffer_size    = 4096;

  static esp_http_client_handle_t client = esp_http_client_init(&m_httpConfig);
  esp_http_client_set_header(client, "Content-Type", "application/json");
  esp_http_client_set_post_field(client, data, strlen(data));
  auto err = esp_http_client_perform(client);
  esp_http_client_cleanup(client);

  ESP_LOGI("BLOB_UPLOAD", "%d", err);
}
I (11731) BLOB_UPLOAD: blob upload started
I (11914) esp-x509-crt-bundle: Certificate validated
E (12672) esp-tls-mbedtls: read error :-0x0050:
E (12672) TRANSPORT_BASE: esp_tls_conn_read error, errno=Connection reset by peer
CORRUPT HEAP: Bad head at 0x3fff78bc. Expected 0xabba1234 got 0xb4e095d5

assert failed: multi_heap_free multi_heap_poisoning.c:253 (head != NULL)


Backtrace: 0x40081e1e:0x3ffd64c0 0x40092211:0x3ffd64e0 0x40099d39:0x3ffd6500 0x40098d63:0x3ffd6630 0x400822b6:0x3ffd6650 0x4008d2d1:0x3ffd6670 0x4017b31e:0x3ffd6690 0x40171187:0x3ffd66b0 0x4017cb55:0x3ffd66d0 0x40179b62:0x3ffd66f0 0x40179851:0x3ffd6710 0x4016a544:0x3ffd6730 0x4016a571:0x3ffd6750 0x40169cfd:0x3ffd6770 0x401b5747:0x3ffd6790 0x401d6dfb:0x3ffd67b0 0x4016b34d:0x3ffd67d0 0x4016b365:0x3ffd67f0 0x400e405b:0x3ffd6810 0x400e429a:0x3ffd6830 0x400e42ad:0x3ffd6850 0x400f9712:0x3ffd6870 0x400e3f3e:0x3ffd6910 0x401d291f:0x3ffd6930 0x40095e81:0x3ffd6950
0x40081e1e: panic_abort at /home/tom/Lib/esp-idf-v4.4.3/components/esp_system/panic.c:402

0x40092211: esp_system_abort at /home/tom/Lib/esp-idf-v4.4.3/components/esp_system/esp_system.c:128

0x40099d39: __assert_func at /home/tom/Lib/esp-idf-v4.4.3/components/newlib/assert.c:85

0x40098d63: multi_heap_free at /home/tom/Lib/esp-idf-v4.4.3/components/heap/multi_heap_poisoning.c:253 (discriminator 1)

0x400822b6: heap_caps_free at /home/tom/Lib/esp-idf-v4.4.3/components/heap/heap_caps.c:361

0x4008d2d1: esp_mbedtls_mem_free at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/port/esp_mem.c:46

0x4017b31e: mbedtls_free at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/mbedtls/library/platform.c:66

0x40171187: mbedtls_mpi_free at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/mbedtls/library/bignum.c:108

0x4017cb55: mbedtls_rsa_free at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/mbedtls/library/rsa.c:2354

0x40179b62: rsa_free_wrap at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/mbedtls/library/pk_wrap.c:174

0x40179851: mbedtls_pk_free at /home/tom/Lib/esp-idf-v4.4.3/components/mbedtls/mbedtls/library/pk.c:72

0x4016a544: esp_mbedtls_cleanup at /home/tom/Lib/esp-idf-v4.4.3/components/esp-tls/esp_tls_mbedtls.c:308

0x4016a571: esp_mbedtls_conn_delete at /home/tom/Lib/esp-idf-v4.4.3/components/esp-tls/esp_tls_mbedtls.c:255

0x40169cfd: esp_tls_conn_destroy at /home/tom/Lib/esp-idf-v4.4.3/components/esp-tls/esp_tls.c:105

0x401b5747: base_close at /home/tom/Lib/esp-idf-v4.4.3/components/tcp_transport/transport_ssl.c:270

0x401d6dfb: esp_transport_close at /home/tom/Lib/esp-idf-v4.4.3/components/tcp_transport/transport.c:172

0x4016b34d: esp_http_client_close at /home/tom/Lib/esp-idf-v4.4.3/components/esp_http_client/esp_http_client.c:1448

0x4016b365: esp_http_client_cleanup at /home/tom/Lib/esp-idf-v4.4.3/components/esp_http_client/esp_http_client.c:773

Who is online

Users browsing this forum: No registered users and 103 guests