Skip to content

Adding default String() constructor to ensure init() is called. #3156

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

Closed
wants to merge 1 commit into from
Closed

Conversation

atanisoft
Copy link
Collaborator

Without a default constructor it is possible to crash the esp32 with a heap corruption since the invalidate() method called by the destructor expects init() to have been called previously.

Example backtrace decode showing the failure:

0x4008c285: invoke_abort at ...\framework-espidf\components\esp32/panic.c:687
0x4008c4f5: abort at ...\framework-espidf\components\esp32/panic.c:687
0x4008b753: multi_heap_assert at ...\framework-espidf\components\heap/multi_heap.c:699
0x4008b77d: get_prev_free_block at ...\framework-espidf\components\heap/multi_heap.c:699
0x4008bb96: multi_heap_free_impl at ...\framework-espidf\components\heap/multi_heap.c:699
0x4008bf4e: multi_heap_free at ...\framework-espidf\components\heap/multi_heap_poisoning.c:301
0x40084b81: heap_caps_free at ...\framework-espidf\components\heap/heap_caps.c:354
0x40087c79: _free_r at ...\framework-espidf\components\newlib/syscalls.c:42
0x401ab476: String::~String() at ...\framework-arduinoespressif32\cores\esp32/WString.cpp:840 (discriminator 2)
0x4011ad45: AsyncWebHeader::~AsyncWebHeader() at ...\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0/functional:1974
  \-> inlined by: operator() at ...\ESPAsyncWebServer\src/WebRequest.cpp:56
  \-> inlined by: _M_invoke at ...\toolchain-xtensa32\xtensa-esp32-elf\include\c++\5.2.0/functional:1871

prevents the ~String() call from causing heap corruption due to freeing
random memory.
@atanisoft atanisoft closed this Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant