stack being smashing
Christopher Friedt <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <CAF4BF-TkixPVBo0qj8159=VKMBqpYsmpcYoTZpcDUsU8nC=-dg@mail.gmail.com> |
Hi list,
first of all, I have to say that I'm really excited to use boost::spirit
more regularly. A parser integrated directly into the language is much
better than requiring separate grammar files or separate tools.
I am having a really strange issue though, and I'm sure it's probably just
user error. Somehow my stack is being smashed by the parser when I define
BOOST_SPIRIT_DEBUG. The smashed stack was detected by default using gcc /
linux (versions ranging from 4.9 to 7.2), but clang / mac was actually
producing the expected results until I added -fstack-protector-strong.
I filed a bug report, although perhaps it is simply a user error. I've read
the docs and rewrote to no avail.
https://svn.boost.org/trac10/ticket/13370
In any case, I'll just try and outline the issue with relevant parts below
- I haven't found the root cause unfortunately.
Any help would be much appreciated.
C
typedef std::pair<std::string,uint8_t> token_val_t;
template <typename Iterator>
struct grammar_
: qi::grammar<Iterator, token_val_t()>
{
grammar_()
: grammar_::base_type( resp )
{
using qi::hex;
using ascii::string;
using phoenix::construct;
resp %= ok | err;
ok = ( string( "OK" ) ) [ _val = construct<token_val_t>( _1, 0 ) ];
err = ( string( "E" ) > hex ) [ _val = construct<token_val_t>( _1,
_2 ) ];
}
qi::rule<Iterator, token_val_t()> resp;
qi::rule<Iterator, token_val_t()> ok, err;
};
The input to this parser is the string "OK" ... so yeah... not really sure
what's causing it to segfault.
My debug log is:
$ ./test/test_set_thread
Running main() from gtest_main.cc
[==========] Running 7 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 7 tests from test_set_thread_fixture
[ RUN ] test_set_thread_fixture.TestOpOtherIdAny
D: client.cpp: 115: created client
D: set_thread.cpp: 134: generating request..
D: client.cpp: 229: sending request 'Hg0'
D: client.cpp: 234: request frame is '$Hg0#df'
D: client.cpp: 82: D: client.cpp: 92: D: client.cpp: 136: about to call
qi::parse()
D: client.cpp: 145: Parsing succeeded \o/. Received 2 (unchecked) frames!
D: client.cpp: 149: (unchecked) frame is '+'
D: client.cpp: 154: Received an ACK! \o/
D: client.cpp: 149: (unchecked) frame is '$OK#9a'
D: client.cpp: 172: frame is 'OK' cs is '9a'
D: client.cpp: 190: Parsed 2 frames
D: client.cpp: 201: r: '+'
D: client.cpp: 205: longest_payload: 1
D: client.cpp: 252: Received an ACK \o/
D: set_thread.cpp: 138: about to call get_next_frame()
D: client.cpp: 82: D: client.cpp: 92: D: client.cpp: 201: r: 'OK'
D: client.cpp: 205: longest_payload: 2
D: set_thread.cpp: 142: input is 'OK'
D: set_thread.cpp: 151: about to call parse()
<resp>
<try>Segmentation fault: 11
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general