Closed mingodad closed 2 years ago
Valgrind output:
==1967== Invalid read of size 8
==1967== at 0x113C10: std::_Function_base::_M_empty() const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x144D45: std::function<void (unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator bool() const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x13CB39: peg::parser::post_process(char const*, unsigned long, peg::Definition::Result const&) const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x13C8BC: peg::parser::parse_n(char const*, unsigned long, char const*) const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x112D51: main (in cpp-peglib0/build/lint/peglint)
==1967== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==1967==
==1967==
==1967== Process terminating with default action of signal 11 (SIGSEGV)
==1967== Access not within mapped region at address 0x10
==1967== at 0x113C10: std::_Function_base::_M_empty() const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x144D45: std::function<void (unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator bool() const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x13CB39: peg::parser::post_process(char const*, unsigned long, peg::Definition::Result const&) const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x13C8BC: peg::parser::parse_n(char const*, unsigned long, char const*) const (in cpp-peglib0/build/lint/peglint)
==1967== by 0x112D51: main (in cpp-peglib0/build/lint/peglint)
==1967== If you believe this happened as a result of a stack
==1967== overflow in your program's main thread (unlikely but
==1967== possible), you can try to increase the size of the
==1967== main thread stack using the --main-stacksize= flag.
==1967== The main thread stack size used in this run was 8388608.
==1967==
==1967== HEAP SUMMARY:
==1967== in use at exit: 380,274 bytes in 3,790 blocks
==1967== total heap usage: 30,722 allocs, 26,932 frees, 1,539,374 bytes allocated
==1967==
==1967== LEAK SUMMARY:
==1967== definitely lost: 0 bytes in 0 blocks
==1967== indirectly lost: 0 bytes in 0 blocks
==1967== possibly lost: 0 bytes in 0 blocks
==1967== still reachable: 380,274 bytes in 3,790 blocks
==1967== suppressed: 0 bytes in 0 blocks
==1967== Rerun with --leak-check=full to see details of leaked memory
==1967==
==1967== For lists of detected and suppressed errors, rerun with: -s
==1967== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
@mingodad, thank you for the report. Could you narrow down the scope and find the smallest possible grammar revealing the segfault problem? Thanks!
@mingodad, I just tried it with peglint and on the playground. Both worked fine.
E 1 ┌[chunk] #0
E 1 │┌Sequence #1
...
L 1 │└x Sequence #1
L 1 └x [chunk] #0
bug.txt:1:6: syntax error, unexpected '[', expecting ';'.
When testing the grammar/input shown bellow with
peglint --trace
I'm getting a segfault at the end:Input:
Grammar: