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
Memory corruptions with std::string in SPI RAM (IDFGH-596) #3006
Comments
Could be this problem: #2892 |
Maybe the same fundamental issue as #2892 We tried changing CONFIG_SPIRAM_SIZE to 2MB, but that had no improvement. We then tried adding a kludgy:
to the start of the code, and then the fault seemed to go away. Could this be related to just the bottom 2MB of SPIRAM? Or are they somehow mapped between cores differently? Our code runs mostly on core 1. |
Running the test project with that 2 MB allocation and also starting the test task on core 0 shows the corruptions again. It seems core 0 can only work reliably with the lower 2 MB and core 1 only with the higher 2 MB. |
Issue solved by PSRAM fix in toolchain release 1.22.0-96-g2852398: |
Environment
Problem Description
When building a text message within a task running on core 1 by appending text values to a std::string buffer located in SPI RAM, the buffer randomly gets corrupted by NUL bytes overwriting 1 to 3 bytes of the buffer.
The bug only shows on core 1 and only when using a std::string to build the message and only when the std::string is in SPI RAM.
The bug frequency rises with stress on both cores. On an idle module it may not appear. The attached test project reproduces the bug reliably by starting wifi in apsta mode and running a memory stressing task on each core. Starting wifi alone is sufficient to trigger the bug, as well as starting one of the mem stressers on any core.
The test is performed in four modes of different message part sources:
Modes 1 & 2 trigger the bug very frequently (run quickly into error limit), modes 3 & 4 less often (single test runs may not show the bug at all).
If using a char buffer instead of a std::string, neither stpcpy() nor memcpy() trigger the bug.
Expected Behavior
No buffer corruptions.
Actual Behavior
Buffer corruptions.
Steps to repropduce
Code to reproduce this issue
test-memory-corruption.zip
Debug Logs
Test log also included in ZIP:
test-log-20190129.txt
Other items if possible
Project origin
https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/
openvehicles/Open-Vehicle-Monitoring-System-3#189
The text was updated successfully, but these errors were encountered: