Closed martinayotte closed 9 years ago
Exception (9) means an unaligned access, can you provide a objdump for the address around 0x4010177f?
$(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump" -S $(PNAME).elf
Hi Markus/Links2004 ,
Here it is :
40101768 -vPortFree-:
40101768: f0c112 addi a1, a1, -16
4010176b: 11c9 s32i.n a12, a1, 4
4010176d: 0109 s32i.n a0, a1, 0
4010176f: 02cd mov.n a12, a2
40101771: f29c beqz.n a2, 40101794 -vPortFree+0x2c-
40101773: ff7901 l32r a0, 40101558 -ets_timer_setfn+0x78-
40101776: 0000c0 callx0 a0
40101779: ffcf31 l32r a3, 401016b8 -xPortWantedSizeAlign+0x14-
4010177c: ffdc02 addmi a0, a12, 0xffffff00
4010177f: 3d2002 l32i a0, a0, 244
40101782: 4348 l32i.n a4, a3, 16
40101784: f0cc22 addi a2, a12, -16
40101787: 004a add.n a0, a0, a4
40101789: 4309 s32i.n a0, a3, 16
4010178b: 000905 call0 4010181c -pvPortRealloc+0x38-
4010178e: ff7301 l32r a0, 4010155c -ets_timer_setfn+0x7c-
40101791: 0000c0 callx0 a0
40101794: 11c8 l32i.n a12, a1, 4
40101796: 0108 l32i.n a0, a1, 0
40101798: 10c112 addi a1, a1, 16
4010179b: f00d ret.n
4010179d: 000000 ill
401017a0: 0018a4 excw
401017a3: 223040 excw
Is it in Espressif code ? I'm elligible to BugBounty ? :-)
BTW, why I had to change all brackets by "-" to make it readable in this post, markups seems to different from other sites, backticks doesn't work properly for inline code blocks ?
what is the name of the function?
the address points in to the code RAM. there can be our code or Espressif code.
normally there is a line like:
401017a0 <ets_timer_disarm>:
which name the function.
It is mentioned above : <vPortFree>
vPortFree is from the SDK. check the code if you try to use free to an null ptr
Highly likely that this is the same heap corruption issue as this one: https://github.com/esp8266/Arduino/issues/428
I have been working on that issue for three days (Saturday, Sunday, Monday), and made some progress (found an issue with String class reallocation). However, I haven't yet figured it out. There is some code which does out-of-bounds writes, and eventually this leads to heap corruption. It's been hard to trace because we only have one data breakpoint.
On Thu, Sep 24, 2015 at 6:21 PM, Markus notifications@github.com wrote:
vPortFree is from the SDK. check the code if you try to use free to an null ptr
— Reply to this email directly or view it on GitHub https://github.com/esp8266/Arduino/issues/813#issuecomment-142961018.
Ok ! I will add validation in the code above. But this means that the malloc() failed for some reason, I will need to investigate that too, because, as you can see above, the code is quite simple.
You can see this isn't a null ptr access:
Exception (9):
epc1=0x4010177f epc2=0x00000000 epc3=0x00000000 excvaddr=0x3fff596b depc=0x00000000
because excvaddr isn't close to 0.
Hi IGRR, If the case you've mentioned is hard to reproduce, maybe you can rely on my use-case, since the corruption seems to be almost instantaneous.
On the contrary, It's quite easy to reproduce it. There's a bunch of examples in the issue I've linked above.
Ah ! So, let hope that the good angels are with you :-)
With the change in 72c9033 your sample seems to work fine. I have replaced variable p
with Serial
because I didn't know what it was.
Here's the full sketch i used: https://gist.github.com/igrr/ae22f35a6d151f5fb622
Hi Ivan, Thanks for the fix ! So, angels were in GCC-vs-XCC ... :-0 (Yes, the p was for Print class since I use both Serial and/or WiFiClient with the same function)
The following code is working fine, although it seems that there is a delay between header and body :
But if it is replaced by the following code, it produce a crash :
The stack trace look like :
Exception (9): epc1=0x4010177f epc2=0x00000000 epc3=0x00000000 excvaddr=0x3fff596b depc=0x00000000
ctx: cont sp: 3ffecea0 end: 3ffed4c0 offset: 01a0
ets Jan 8 2013,rst cause:1, boot mode:(3,7)
load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld