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

Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x, C++ exceptions #6273

Merged
merged 9 commits into from
Jul 21, 2019

Conversation

earlephilhower
Copy link
Collaborator

Rebuild the entire toolchain (including standard libraries) with the
latest pgm_read_xxx headers included (which fix unaligned dword reads
from progmem and run faster/smaller, and a pgm_read_byte change which
removes an instruction on each read saving flash).

Pull in latest bearssl while we're at it, too, which speeds up EC
handshakes and reduces ROM usage, too.

Rebuild the entire toolchain (including standard libraries) with the
latest pgm_read_xxx headers included (which fix unaligned dword reads
from progmem and run faster/smaller, and a pgm_read_byte change which
removes an instruction on each read saving flash).

Pull in latest bearssl while we're at it, too, which speeds up EC
handshakes and reduced ROM usage, too.
@earlephilhower earlephilhower changed the title Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x WIP -Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x Jul 14, 2019
@earlephilhower earlephilhower changed the title WIP -Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x Jul 14, 2019
@earlephilhower earlephilhower changed the title Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x WIP - Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x Jul 15, 2019
@earlephilhower
Copy link
Collaborator Author

As we've just found issues w/exceptions, it makes sense to hold off on this until we backport the 9.1 changes to 4.8.

@earlephilhower earlephilhower force-pushed the to_2.5.0-4 branch 2 times, most recently from a2081f1 to a750f52 Compare July 16, 2019 21:33
Apply the GCC9.1 patches (with needed changes) to GCC4.8.

Exception code now only does 32b aligned reads from progmem to access
the eh_table (some via -mforce-l32, some via hand-inserted pgm_read_x
macros).
@earlephilhower earlephilhower changed the title WIP - Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x Upgrade to 2.5.0-4 toolchain w/improved pgm_read_x, C++ exceptions Jul 16, 2019
@earlephilhower
Copy link
Collaborator Author

earlephilhower commented Jul 16, 2019

#include <Arduino.h>
#include <regex>
void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("Hi there!"); delay(20);
  try {
    char *x=new char[100000];
  } catch (...) {
    Serial.printf("gotcha\n");
  }
  //throw std::runtime_error("oops");
 
  static const std::regex holdRegex("hold ([\\d,=]+) (\\d+)");
  Serial.println("After instantiation"); delay(20);
}

void loop() {
}

Now works as expected (remember, regexes are broken in GCC until after 5.2, so the regex_error is expected):

Hi there!
gotcha

User exception (panic/abort/assert)
Unhandled C++ exception: regex_error

>>>stack>>>

ctx: cont
sp: 3ffffac0 end: 3fffffc0 offset: 0000
3ffffac0:  402039e4 40000000 00000000 00000000  
3ffffad0:  000000fe 00000000 00000000 00000000  
3ffffae0:  00000000 00000000 00000000 b8b1aabc  
....
3fffffa0:  3fffdad0 00000000 3ffeee74 402039fc  
3fffffb0:  feefeffe feefeffe 3ffe85c4 40100a3d  
<<<stack<<<

...


Decoding stack results
0x402039e4: loop_wrapper() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 124
0x40203e2a: raise_exception() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_postmortem.cpp line 236
0x40203872: __unhandled_exception_cpp() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 176
0x402080c4: _Unwind_RaiseException at /workdir/repo/gcc/libgcc/unwind.inc line 83
0x402143e4: __cxxabiv1::__terminate(void (*)()) at /workdir/repo/gcc/libstdc++-v3/libsupc++/eh_terminate.cc line 39
0x40214c80: __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/eh_throw.cc line 33
0x40226972: std::__throw_regex_error(std::regex_constants::error_type) at /workdir/repo/gcc/libstdc++-v3/src/c++11/functexcept.cc line 118
0x402027bc: std::__detail::_Compiler   >::_M_bracket_expression() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 974
0x40202fa0: setup() at /home/earle/Arduino/sketch_jul14b/sketch_jul14b.ino line 13
0x40202aec: std::__detail::_Compiler   >::_M_atom() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 960
0x40214474: operator new[](unsigned int) at /workdir/repo/gcc/libstdc++-v3/libsupc++/new_opv.cc line 31
0x40100598: _umm_free(void*) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.cpp line 1304
0x401009e0: free(void*) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.cpp line 1764
0x40214e8c: operator new(unsigned int) at /workdir/repo/gcc/libstdc++-v3/libsupc++/new_op.cc line 52
0x40202b6e: std::__detail::_Compiler   >::_M_term() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 795
0x40202b98: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 773
0x40100598: _umm_free(void*) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.cpp line 1304
0x40202890: std::__detail::_Compiler   >::_M_disjunction() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 759
0x4021446d: operator delete(void*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/del_op.cc line 48
0x40201143: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/functional line 1954
0x40202a6c: std::__detail::_Compiler   >::_M_atom() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/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 /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/functional line 1931
0x402050a8: std::_Function_handler    > >::_M_invoke(std::_Any_data const&, std::__detail::_PatternCursor const&, std::__detail::_Results&) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_nfa.h line 97
0x40202593: std::__detail::_Compiler   >::_M_quantifier() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 866
0x40202b6e: std::__detail::_Compiler   >::_M_term() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 795
0x40202b98: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 773
0x40202b65: std::__detail::_Compiler   >::_M_term() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 798
0x40202bc3: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 777
0x40202bc3: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 777
0x40202bc3: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 777
0x40202bc3: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 777
0x40202bc3: std::__detail::_Compiler   >::_M_alternative() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 777
0x40202890: std::__detail::_Compiler   >::_M_disjunction() at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 759
0x4021446d: operator delete(void*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/del_op.cc line 48
0x40201143: std::_Function_base::_Base_manager    > >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/functional line 1954
0x40202d1c: std::__detail::_Compiler   >::_Compiler(char const* const&, char const* const&, std::regex_traits &, unsigned int) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/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 /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/functional line 1931
0x402050a8: std::_Function_handler    > >::_M_invoke(std::_Any_data const&, std::__detail::_PatternCursor const&, std::__detail::_Results&) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_nfa.h line 97
0x4020da75: wctob at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdlib/wctob.c line 22
0x401007e8: malloc(size_t) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/umm_malloc/umm_malloc.cpp line 1677
0x40202e60: std::__detail::__compile   >(char const* const&, char const* const&, std::regex_traits &, unsigned int) at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/regex_compiler.h line 1105
0x4021d314: std::locale::_S_initialize_once() at /workdir/repo/gcc/libstdc++-v3/src/c++98/locale_init.cc line 267
0x4021d33a: std::locale::_S_initialize() at /workdir/repo/gcc/libstdc++-v3/src/c++98/locale_init.cc line 280
0x40203f12: delay(unsigned long) at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_wiring.cpp line 57
0x40203035: setup() at /home/earle/Arduino/sketch_jul14b/sketch_jul14b.ino line 25
0x402039fc: loop_wrapper() at /home/earle/Arduino/hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_main.cpp line 129

@earlephilhower
Copy link
Collaborator Author

Fixes #6305

@earlephilhower
Copy link
Collaborator Author

Fixes #6151
Fixes #6305
Fixes #6198

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.

2 participants