-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit c7cc causes heap corruption. #6682
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 @MartinMueller2003, |
I had tested using #master as of 08:00AM ET 3 May 2022 and random versions between the last working and first broken version. I tested a total of 14 broken versions (not fun). The code in the output section is the only code that manipulates GPIO. The path that crashed most reliably is the one used by the PCA9685 driver (I2C Based) which uses an Arduino lib to manage the device. However, one of my tests was to comment out the PCA driver and I made sure all other GPIO actions in that module were disabled and the code still crashed. Then I added a delay loop before initializing the PCA driver and found that the code crashed in the loop (before it ever got to the PCA driver). This indicates that the issue is something earlier in the code and it just takes a while for the system to destabilize enough to crash. When I investigated further, I was able to see at least two distinct heap corruptions and uses of memory structures by some entity after the heap memory was given to another object. This also caused secondary crashes as my code tried to parse that memory. |
@MartinMueller2003 There is no general problem in actual Arduino core. We use it for project Tasmota. |
I will keep digging to see if I can narrow down which action is causing the issue. |
@MartinMueller2003 If you find something more specific, which is causing the issue, let us now so we can take a look. |
I kept digging and found an issue. I was passing in an invalid GPIO ID to pinMode prior to processing my full configuration. This resulted in triggering the heap corruption and subsequent crash, I suppose it is possible that the lower levels of code are not detecting the invalid GPIO Value and are writing data into ram indiscriminately using the bad GPIO as an index or some such thing. At any rate, making my code behave properly resolves the heap corruption. Thanks for taking the time to look into this and maybe you can convert this into an enhancement request to range check the GPIO values and output an error message when a bad one is encountered. |
Thanks for report :) Actually there is in pinMode detection if the pin is valid.
Can you send me exactly what pin / board you used, so I can retest that in simple sketch, to be sure if in the pinMode the valid pin detection works? Thanks |
There were two values and I did not dig to see which created the issue. -1 and 35. If I did not send those values, then memory did not get corrupted. |
Thanks! Can we close this issue and I will do some tests and open new issue or just make a PR with fix :) |
I don't have the same board you have. I use official Espressif boards and for what I see, your board does not have pin 35 available or it might be used for something internal (Analog Input Pins : VP, VN, 32, 33, 34, 35). If you try with -1, you get an error that pin is invalid :) So I think, nothing needs to be fixed. |
Board
ESP32 LoLin (real) D32 PRO
Device Description
None. / Nothing
Hardware Configuration
No
Version
other
IDE Name
PlatformIO
Operating System
Windows 10
Flash frequency
80
PSRAM enabled
yes
Upload speed
921600
Description
Code is working with commit: 70b7c3a
Code crashes with commit: c7cc5c9 (next commit to the repo)
Revert to commit: 70b7c3a and crash goes away
FYI: Code crashes on current main. Assuming it is the same issue.
No software changes between tests. Full rebuild between tests.
Sketch
Debug Message
Other Steps to Reproduce
I have added tracing to my code and see that the issue happens in different locations within the code flow. If I add a delay the issue happens earlier in my code. This indicates it is not an operation performed by my code that is causing the crash. I have even gotten the issue to happen when I used a long lived loop in my setup function that feeds WD and outputs a message via the console port.
FYI: Other than outputting strings to the console, this code performs no manipulation of hardware.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: