Exception in the ANTLR shim
See original GitHub issueAfter few minutes of fuzzing mruby using the testcases from test/t/
terminate called after throwing an instance of 'std::range_error'
what(): wstring_convert::from_bytes
==13251==
==13251== Process terminating with default action of signal 6 (SIGABRT)
==13251== at 0x4E7AF47: raise (raise.c:51)
==13251== by 0x4E7C8B0: abort (abort.c:79)
==13251== by 0x71F2256: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==13251== by 0x71FD605: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==13251== by 0x71FD670: std::terminate() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==13251== by 0x71FD904: __cxa_throw (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==13251== by 0x71F4C0B: std::__throw_range_error(char const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==13251== by 0x6D94479: std::__cxx11::wstring_convert<std::codecvt_utf8<char32_t, 1114111ul, (std::codecvt_mode)0>, char32_t, std::allocator<char32_t>, std::allocator<char> >::from_bytes(char const*, char const*) (locale_conv.h:324)
==13251== by 0x6D94032: antlrcpp::utf8_to_utf32[abi:cxx11](char const*, char const*) (StringUtils.h:43)
==13251== by 0x6D934D4: antlr4::ANTLRInputStream::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (ANTLRInputStream.cpp:40)
==13251== by 0x6D9322B: antlr4::ANTLRInputStream::ANTLRInputStream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (ANTLRInputStream.cpp:22)
==13251== by 0x6D932CA: antlr4::ANTLRInputStream::ANTLRInputStream(char const*, unsigned long) (ANTLRInputStream.cpp:26)
==13251==
==13251== HEAP SUMMARY:
==13251== in use at exit: 1,082,303,564 bytes in 18,122,690 blocks
==13251== total heap usage: 59,484,413 allocs, 41,361,723 frees, 3,887,947,618 bytes allocated
==13251==
==13251== LEAK SUMMARY:
==13251== definitely lost: 0 bytes in 0 blocks
==13251== indirectly lost: 0 bytes in 0 blocks
==13251== possibly lost: 69,776 bytes in 4 blocks
==13251== still reachable: 1,082,233,788 bytes in 18,122,686 blocks
==13251== of which reachable via heuristic:
==13251== stdstring : 52 bytes in 1 blocks
==13251== suppressed: 0 bytes in 0 blocks
==13251== Rerun with --leak-check=full to see details of leaked memory
==13251==
==13251== For counts of detected and suppressed errors, rerun with: -v
==13251== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Aborted
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
RecognitionException (ANTLR 4 Runtime 4.11.1 API)
The root of the ANTLR exception hierarchy. In general, ANTLR tracks just 3 kinds of errors: prediction errors, failed predicate errors, and mismatched...
Read more >ANTLR Mega Tutorial - Hacker News
1) ANTLR is a good tool for generating "happy path" parsers. With a grammar specification, it easily generates a parser that accepts or...
Read more >Error Handling and Recovery - ANTLR Parser Generator
ANTLR-generated parsers throw exceptions to signal recognition errors or other stream problems. All exceptions derive from ANTLRException.
Read more >AntlrVSIX - Visual Studio Marketplace
AntlrVSIX is a tool to support editing, analysis, refactoring, and conversion of context-free grammars, including Antlr, Bison, ISO 14977, LBNF, ...
Read more >Antlr Handling Exceptions - java - Stack Overflow
The code above allows you to track "recoverable" errors, errors that ANTLR can skip over. There are still scenarios that produce unrecoverable errors,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
lgtm
This issue has been solved in b9b5d303902df6cd2a0f57669b2e6a824d277a6e.
I wrap the parsing function with a try/catch. A
nullptr
will be returned if any errors occur.The grammar mutator will skip a test case, if there is no previously stored tree file, or a parsing error occurs.