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

Qi bad access/segmentation fault with grammar grammar alternative #406

Closed
Superlokkus opened this issue Oct 13, 2018 · 3 comments
Closed
Labels

Comments

@Superlokkus
Copy link

Superlokkus commented Oct 13, 2018

Hi,

I'am writing a RTSP1.0 parser with Qi, so I created a grammar for response message types and one for request message types. All worked perfectly so far, unit tested them, using no state or semantic actions but the attributed types struct bindings. Now I just wanted to combine them as a simple alternative into a boost::variant. (see https://github.com/Superlokkus/boost_spirit_bug/blob/parser_vtable_bad_access_minimal_example/src/streaming_lib/include/rtsp_message.hpp#L142 )
(so that I can just parse in general rtsp messages, which is need for rtsp clients since they could also get request from the server, and so messages are even rfc defined as the alternative)

But this simple grammar which combines the mentioned grammars, explodes with segmentation faults/memory access violation: invalid permissions in boost::function4 with fusion while parsing.

I tested it with boost 1.66 Apple LLVM version 10.0.0 (clang-1000.11.45.2) on a mac host and with boost 1.69 gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812] on a suse x86-64 host.

I would paste a wandbox link, but boost::test or boost::spirit needs to much ram for compiling and quits because of this. Find a stack trace attached if you can not clone and execute it yourself.

I can try to make the example more minimal, but I hope since the grammars don't have custom side effects and valid grammars, that you can already use it.

Code/Repo: https://github.com/Superlokkus/boost_spirit_bug
boost_spirt_stack.txt

@Kojoley
Copy link
Collaborator

Kojoley commented Oct 13, 2018

You are binding to a temporary here

        start %= rtsp_request_grammar<Iterator>{} | rtsp_response_grammar<Iterator>{};

@Kojoley Kojoley closed this as completed Oct 13, 2018
@Superlokkus
Copy link
Author

You are right. I'm so sorry. What was I thinking.

@Kojoley
Copy link
Collaborator

Kojoley commented Oct 13, 2018

You can try to use ASan to catch these type of bugs and prevent yourself from wasting anybody's time :-)

@Kojoley Kojoley added the invalid label Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants