Skip to content
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

ESP shuts down when instantiating std::regex object #6198

Closed
5 of 6 tasks
Gei0r opened this issue Jun 12, 2019 · 8 comments
Closed
5 of 6 tasks

ESP shuts down when instantiating std::regex object #6198

Gei0r opened this issue Jun 12, 2019 · 8 comments

Comments

@Gei0r
Copy link

Gei0r commented Jun 12, 2019

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-01 (D1 mini)
  • Core Version: 2.5.2
  • Development Env: Arduino IDE + Platformio
  • Operating System: Windows

Settings in IDE

  • Module: WeMos D1 R1
  • Flash Size: 4MB (no SPIFFS)
  • CPU Frequency: 80Mhz

Problem Description

When instantiating a std::regex object, the D1 mini shuts down.
It only works for very simple regexes, such as /a/, but not for (a little) more complicated ones.

I also tried enabling C++ exceptions and catching something, but nothing is caught.

MCVE Sketch

#include <Arduino.h>
#include <regex>

void setup() {
  Serial.begin(115200);
  Serial.println("Hi there!"); delay(20);
  static const std::regex holdRegex("hold ([\\d,=]+) (\\d+)");
  Serial.println("After instantiation"); delay(20);
}

void loop() {
}

Debug Messages

Hi there!

Exception (3):
epc1=0x4020b4d8 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4025a301 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffff610 end: 3fffffc0 offset: 01a0
3ffff7b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7c0:  4025a2f8 00000000 4025a314 402085fa  
3ffff7d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff7e0:  00000000 feefeffe feefeffe feefeffe  
3ffff7f0:  feefeffe feefeffe feefeffe 3ffeed68  
3ffff800:  40207ef0 00000000 3ffeed68 4020897c  
3ffff810:  feefeffe feefeffe feefeffe feefeffe  
3ffff820:  feefeffe feefeffe feefeffe feefeffe  
3ffff830:  feefeffe feefeffe feefeffe feefeffe  
3ffff840:  feefeffe feefeffe feefeffe 3ffeed68  
3ffff850:  40207ef0 3ffffb34 3ffeed68 40208e90  
3ffff860:  feefeffe feefeffe feefeffe feefeffe  
3ffff870:  feefeffe feefeffe feefeffe 40207ef1  
3ffff880:  3ffffb80 3ffffae4 3ffff8d0 40207109  
3ffff890:  feefeffe feefeffe feefeffe feefeffe  
3ffff8a0:  feefeffe feefeffe feefeffe feefeffe  
3ffff8b0:  feefeffe feefeffe feefeffe 40207ef1  
3ffff8c0:  3ffffb80 40214a27 3ffffae4 40207b63  
3ffff8d0:  00000000 00000000 00000000 00000000  
3ffff8e0:  00000000 00000000 00000000 00000000  
3ffff8f0:  00000000 00000000 00000000 00000000  
3ffff900:  00000000 00000000 00000000 00000000  
3ffff910:  00000000 00000000 00000000 00000000  
3ffff920:  00000000 00000000 00000000 00000000  
3ffff930:  00000000 00000000 00000000 00000000  
3ffff940:  00000000 00000000 00000000 00000000  
3ffff950:  00000000 00000000 00000000 00000000  
3ffff960:  00000000 00000000 00000000 00000000  
3ffff970:  00000000 00000000 00000000 00000000  
3ffff980:  00000000 00000000 feefeffe feefeffe  
3ffff990:  feefeffe feefeffe feefeffe 3ffff9b0  
3ffff9a0:  00000001 3fff14fc 000000b8 40207ef1  
3ffff9b0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9c0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9d0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9e0:  feefeffe feefeffe feefeffe feefeffe  
3ffff9f0:  feefeffe feefeffe feefeffe feefeffe  
3ffffa00:  feefeffe feefeffe feefeffe feefeffe  
3ffffa10:  feefeffe feefeffe feefeffe feefeffe  
3ffffa20:  feefeffe feefeffe feefeffe feefeffe  
3ffffa30:  feefeffe feefeffe feefeffe feefeffe  
3ffffa40:  feefeffe feefeffe feefeffe feefeffe  
3ffffa50:  feefeffe feefeffe feefeffe feefeffe  
3ffffa60:  feefeffe feefeffe feefeffe feefeffe  
3ffffa70:  feefeffe feefeffe feefeffe feefeffe  
3ffffa80:  feefeffe feefeffe feefeffe feefeffe  
3ffffa90:  feefeffe feefeffe feefeffe 00000001  
3ffffaa0:  00000001 40214bc4 0000000e 40204f74  
3ffffab0:  feefeffe 3ffffeec 0000000e 40214bc4  
3ffffac0:  00000001 40214bc4 00000001 40225344  
3ffffad0:  feefeffe 3ffffeec 00000000 0000000b  
3ffffae0:  00000001 00000000 00000000 00000000  
3ffffaf0:  00000000 00000000 00000000 00000000  
3ffffb00:  00000000 00000000 00000000 00000000  
3ffffb10:  00000000 00000000 00000000 00000000  
3ffffb20:  00000000 00000000 00000000 40207ef1  
3ffffb30:  00000000 00000000 00000000 00000000  
3ffffb40:  40000000 00000000 00000000 00000000  
3ffffb50:  00000000 00000000 00000000 00000000  
3ffffb60:  00000001 00000000 00000001 00000004  
3ffffb70:  3fff14fc 402149b8 3fff14fc 40214a27  
3ffffb80:  00000001 00000004 3fff151c 4022671a  
3ffffb90:  feefeffe 00000001 3ffffed0 40202580  
3ffffba0:  feefeffe feefeffe feefeffe feefeffe  
3ffffbb0:  feefeffe feefeffe feefeffe feefeffe  
3ffffbc0:  3ffeed0c feefeffe feefeffe feefeffe  
3ffffbd0:  feefeffe feefeffe feefeffe 3ffffef8  
3ffffbe0:  00000001 00000000 3ffffed0 40202bd8  
3ffffbf0:  4000050c feefeffe feefeffe feefeffe  
3ffffc00:  3ffeee28 0000024f 0000024f 40204d30  
3ffffc10:  00000008 3fff15a4 3fff1594 40205158  
3ffffc20:  3ffeee28 00000245 00000245 3ffffef8  
3ffffc30:  00000001 40214bc4 00000004 3ffffef8  
3ffffc40:  00000001 00000001 3ffffed0 40202c66  
3ffffc50:  3ffffef8 00000001 3ffffed0 40202908  
3ffffc60:  3ffeee28 00000245 00000245 40204d30  
3ffffc70:  00000001 00000001 3ffffed0 4020297c  
3ffffc80:  00000004 ffffffff 00000004 402142fe  
3ffffc90:  00000000 00000000 00000000 40201146  
3ffffca0:  00000000 00000001 3ffffed0 3ffffef8  
3ffffcb0:  00000001 00000001 3ffffed0 40202b58  
3ffffcc0:  3fff141c 00000001 40201110 40205480  
3ffffcd0:  3ffffef8 00000006 00000006 ffffffff  
3ffffce0:  3ffffef8 00000005 00000005 ffffffff  
3ffffcf0:  3fff1434 00000001 00000000 402027f3  
3ffffd00:  3ffffef8 00000020 00000004 3fffff14  
3ffffd10:  00000001 3fffff2c 3ffffed0 40202c66  
3ffffd20:  3ffffef8 3fffff2c 3ffffed0 40202908  
3ffffd30:  00000001 00000001 3ffffed0 40202c5d  
3ffffd40:  00000001 3fffff2c 3ffffed0 40202933  
3ffffd50:  3ffffef8 00000005 00000005 ffffffff  
3ffffd60:  00000001 3fffff2c 3ffffed0 40202933  
3ffffd70:  3ffffef8 00000004 00000004 ffffffff  
3ffffd80:  00000001 3fffff2c 3ffffed0 40202933  
3ffffd90:  3ffffef8 00000003 00000003 ffffffff  
3ffffda0:  00000001 3fffff2c 3ffffed0 40202933  
3ffffdb0:  3ffffef8 00000002 00000002 ffffffff  
3ffffdc0:  00000001 3fffff2c 3ffffed0 40202933  
3ffffdd0:  3ffffef8 00000001 00000001 ffffffff  
3ffffde0:  00000000 3ffffef8 3ffffed0 4020297c  
3ffffdf0:  00000004 ffffffff 00000004 402142fe  
3ffffe00:  00000000 00000000 00000000 40201146  
3ffffe10:  00000000 3ffffef8 3ffffed0 3fffff14  
3ffffe20:  00000000 3ffffef8 3ffffed0 40202da4  
3ffffe30:  3ffefc1c feefeffe feefeffe feefeffe  
3ffffe40:  feefeffe feefeffe feefeffe feefeffe  
3ffffe50:  feefeffe feefeffe feefeffe feefeffe  
3ffffe60:  feefeffe feefeffe feefeffe feefeffe  
3ffffe70:  3fff13fc feefeffe 40201110 40205480  
3ffffe80:  3ffffef8 00000000 00000000 ffffffff  
3ffffe90:  feefeffe feefeffe feefeffe 3ffeed98  
3ffffea0:  3ffffed4 4020d803 00000050 40204f74  
3ffffeb0:  feefeffe 3ffef388 00000007 3ffeed0c  
3ffffec0:  3ffeed08 3ffeed10 3ffeed18 40202ef0  
3ffffed0:  3ffeed0c 40205768 3ffe878e 3ffe878e  
3ffffee0:  00000010 3ffef8f8 0000000e 3fff1438  
3ffffef0:  00000009 3fff13f0 40205740 3fff15ac  
3fffff00:  3fff16fc 3fff172c 00000010 00000000  
3fffff10:  3ffef140 00000000 00000000 3fffff14  
3fffff20:  3fffff14 00000000 00000002 3fff1404  
3fffff30:  3fff1404 3fff1414 3ffefc1c 4021d080  
3fffff40:  3fffdad0 3ffeed98 3ffeed0c 4021d0a6  
3fffff50:  40203dc6 00000014 00000014 3ffeed0c  
3fffff60:  3ffeed08 3ffeed3c 3ffeed18 402030b9  
3fffff70:  3ffe878e 3ffe877a feefeffe feefeffe  
3fffff80:  feefeffe feefeffe feefeffe feefeffe  
3fffff90:  feefeffe feefeffe feefeffe 3ffeed98  
3fffffa0:  3fffdad0 00000000 3ffeed64 402038f4  
3fffffb0:  feefeffe feefeffe 3ffe85c4 401004d9  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld

Decoded stack trace:

Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
PC: 0x4020b4d8
EXCVADDR: 0x4025a301

Decoding stack results
0x402085fa: classify_object_over_fdes at ../../../../dl/gcc-xtensa/libgcc/unwind-dw2-fde.c line 628
0x40207ef0: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 88
0x4020897c: search_object at ../../../../dl/gcc-xtensa/libgcc/unwind-dw2-fde.c line 749
0x40207ef0: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 88
0x40208e90: _Unwind_Find_FDE at ../../../../dl/gcc-xtensa/libgcc/unwind-dw2-fde.c line 1025
0x40207ef1: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 89
0x40207109: uw_frame_state_for at ../../../../dl/gcc-xtensa/libgcc/unwind-dw2.c line 1245
0x40207ef1: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 89
0x40214a27: __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*)) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/eh_throw.cc line 83
0x40207b63: uw_init_context_1 at ../../../../dl/gcc-xtensa/libgcc/unwind-dw2.c line 1567
0x40207ef1: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 89
0x40214bc4: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40204f74: malloc(size_t) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x40214bc4: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40214bc4: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40225344: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 621
0x40207ef1: _Unwind_RaiseException at ../../../../dl/gcc-xtensa/libgcc/unwind.inc line 89
0x402149b8: __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/eh_throw.cc line 33
0x40214a27: __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*)) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/eh_throw.cc line 83
0x4022671a: std::__throw_regex_error(std::regex_constants::error_type) at ../../../../../../dl/gcc-xtensa/libstdc++-v3/src/c++11/functexcept.cc line 118
0x40202580: std::__detail::_Compiler   >::_M_bracket_expression() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 974
0x40202bd8: std::__detail::_Compiler   >::_M_atom() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 960
0x40204d30: _umm_free(void*) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1304
0x40205158: free(void*) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1764
0x40214bc4: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40202c66: std::__detail::_Compiler   >::_M_term() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 795
0x40202908: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 773
0x40204d30: _umm_free(void*) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1304
0x4020297c: std::__detail::_Compiler   >::_M_disjunction() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 759
0x402142fe: operator delete(void*) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/del_op.cc line 48
0x40201146: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 1954
0x40202b58: std::__detail::_Compiler   >::_M_atom() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 948
0x40201110: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 1931
0x40205480: std::_Function_handler    > >::_M_invoke(std::_Any_data const&, std::__detail::_PatternCursor const&, std::__detail::_Results&) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_nfa.h line 97
0x402027f3: std::__detail::_Compiler   >::_M_quantifier() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 866
0x40202c66: std::__detail::_Compiler   >::_M_term() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 795
0x40202908: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 773
0x40202c5d: std::__detail::_Compiler   >::_M_term() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 798
0x40202933: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 777
0x40202933: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 777
0x40202933: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 777
0x40202933: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 777
0x40202933: std::__detail::_Compiler   >::_M_alternative() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 777
0x4020297c: std::__detail::_Compiler   >::_M_disjunction() at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 759
0x402142fe: operator delete(void*) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/del_op.cc line 48
0x40201146: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 1954
0x40202da4: std::__detail::_Compiler   >::_Compiler(char const* const&, char const* const&, std::regex_traits &, unsigned int) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 730
0x40201110: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 1931
0x40205480: std::_Function_handler    > >::_M_invoke(std::_Any_data const&, std::__detail::_PatternCursor const&, std::__detail::_Results&) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_nfa.h line 97
0x4020d803: wctob at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdlib/wctob.c line 22
0x40204f74: malloc(size_t) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1677
0x40202ef0: std::__detail::__compile   >(char const* const&, char const* const&, std::regex_traits &, unsigned int) at c:\users\bw1ebed0\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2\bits/regex_compiler.h line 1105
0x4021d080: std::locale::_S_initialize_once() at ../../../../../../dl/gcc-xtensa/libstdc++-v3/src/c++98/locale_init.cc line 267
0x4021d0a6: std::locale::_S_initialize() at ../../../../../../dl/gcc-xtensa/libstdc++-v3/src/c++98/locale_init.cc line 280
0x40203dc6: delay(unsigned long) at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring.cpp line 57
0x402030b9: setup() at D:\UserData\bw1ebed0\Documents\Arduino\Regex/Regex.ino line 9
0x402038f4: loop_wrapper() at C:\Users\bw1ebed0\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 122
@devyte
Copy link
Collaborator

devyte commented Jun 12, 2019

The entire std C++ isn't supported/tested. In this case I'd say the issue is likely either stack size or free heap, but it could be some dependency as well, such as RTTI which we don't have.

@Gei0r
Copy link
Author

Gei0r commented Jun 14, 2019

Well ok I rewrote the code to not use regexes, but it's not ideal. Is there a way to get closer the the particular problem in this case?

@devyte
Copy link
Collaborator

devyte commented Jun 14, 2019

I'm for getting as close to standard as possible, so if you could pursue this it would be great.
As I mentioned above, there are two avenues to investigate that come to mind: heap/stack usage, and whether regex somehow requires RTTI.
Maybe @earlephilhower has some ideas how to pursue this?

@earlephilhower
Copy link
Collaborator

It was done before I came onboard, but IIRC the RTTI is disabled in the toolchain because it inflates the code size and adds bytes to every C++ object.

Theoretically, it's just a switch that needs to be enabled on the g++ toolchain (not just the IDE platform.txt, but the libstdc++ compilation in the esp-quick-toolchain).

@Gei0r
Copy link
Author

Gei0r commented Jun 27, 2019

I haven't looked into it further, but I don't think that RTTI is the problem. Can't imagine why compiling a regex object would have anything to do with RTTI.

@earlephilhower
Copy link
Collaborator

Yes, it doesn't look like a RTTI issue on second glance a little later. What it does look like is a memory error generating the regex parse tree. Your attached crash dump is with exceptions enabled. Without exceptions enabled, I get abort() called from esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 974:

  template<typename _InIter, typename _TraitsT>
    bool
    _Compiler<_InIter, _TraitsT>::
    _M_bracket_expression()
    {
      if (_M_match_token(_ScannerT::_S_token_bracket_begin))
        {
          _RMatcherT __matcher(_M_match_token(_ScannerT::_S_token_line_begin),
                               _M_traits);
          if (!_M_bracket_list(__matcher)
              || !_M_match_token(_ScannerT::_S_token_bracket_end))
>>>>            __throw_regex_error(regex_constants::error_brack);
          _M_stack.push(_StateSeq(_M_state_store,
                                  _M_state_store._M_insert_matcher(__matcher)));
          return true;
        }
      return false;
    }

And on further investigation, GCC 4.8 does not support regex properly : https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions

If you're adventurous, check out my GCC 7.2 PR #6267 . It might get your regex running.

Closing as this is a known issue in gcc 4.8...

@earlephilhower
Copy link
Collaborator

After much hacking, std::regex can compile at runtime with the latest GCC 9.1 pre-release, and I can probably backport the changes fo the existing 4.8 GCC.

You can give your app a try with PR #6294 if you want to do further experiments.

@Gei0r
Copy link
Author

Gei0r commented Jul 16, 2019

Wow, amazing. I'll give it a try on the weekend.

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

No branches or pull requests

3 participants