Ah, I am too good natured, I fixed it anyway.
When you try to strcpy a previously grown buffer buf_ into a buffer temp of BUFFER_INITIAL size, yes, then you segfault on a good operating system.
This regression was introduced in the fix of issue #242 (commit
a065117). It would cause the C++
generated printer to call resizeBuffer for every string appended to the
buffer, not just when resizing was needed. So for each call to
bufAppend(char*/String), O(n) bytes were copied, with the complexity
deteriorating to O(n^2).
Running
bnfc-system-tests
, I observed that the C++ AST printer forexamples/GF/gf.cf
https://github.com/BNFC/bnfc/blob/master/examples/GF/gf.cf segfaults when run onexamples/GF/example.gf
https://github.com/BNFC/bnfc/blob/master/examples/GF/example.gf .I do not want to debug this. A brief look into the generated printer shows that it has inline functions and destructive update of a
buf_
variable.bnfc/source/src/BNFC/Backend/CPP/PrettyPrinter.hs
Lines 146 to 163 in 344ccde
I leave this to C++ enthusiasts and fans of pointer manipulations. Happy segfaulting!
The text was updated successfully, but these errors were encountered: