Boost C++ Libraries: Ticket #13370: Qi: Stack Smash with BOOST_SPIRIT_DEBUG defined https://svn.boost.org/trac10/ticket/13370 <p> Hi, </p> <p> I think I've found some code that touches on a boost::spirit soft-spot that causes a stack overflow when BOOST_SPIRIT_DEBUG is defined, but when debug is not defined, just does not work, *specifically* on Linux. </p> <p> I don't pretend to know why it happens, but it works perfectly well on Mac OS X. The only thing I know is that a stack smash is reported by GCC after boost::spirit::qi::parse() is called. </p> <p> I have this body of code that uses boost::spirit and thrift. I'm using TDD with gtest and developing primarily on Mac OS X. Recently, I added CI using <a class="missing wiki">GitLab</a> and the Docker runner, so the testsuites are being run in a pseudo-GNU / Linux environment, but then I also tried it in a Linux VM with the same results, so it's definitely somehow related to Linux. I even tried compiling with clang under Linux, with the same results. </p> <p> Sorry for submitting my whole project source, but this is the only way I've been able to trigger it reliably. To build the code </p> <p> install: </p> <p> boost thrift gtest </p> <p> and then run: </p> <p> sh autogen.sh ./configure --enable-debug make ./example/trigger_boost_stack_smash </p> <p> It should be reproducible (i.e. the stack will be smashed) on Linux, but not on Mac OS X. </p> <p> Also, if you remove --enable-debug, clean, and rebuild, then the stack will not be smashed, but the parser will fail under Linux, but not Mac OS X. </p> <p> The listing named below is an example program that triggers the smashed stack. I've reproduced this with GCC versions as old as 4.6 and as recent as 7.2 and have tried it with boost versions 1.58 and 1.65.1 . The thrift version I'm using is 0.11.0. </p> <p> example/trigger_boost_stack_smash.cpp </p> <p> The following two named test suites fail under Linux but pass under Mac OS X. </p> <p> test/test_set_thread.cpp test/test_report_target_status.cpp </p> <p> My code is still pre-alpha, so I haven't released it at all yet... but you might guess it's an Apache Thrift interface to GDB's RSP. </p> <p> I might not have written the best boost::spirit parsers, but regardless, the behaviour should be similar across different compilers and OS's. </p> <p> Please let me know if I can help isolate the problem. I have tried a ton of things, including valgrind, and just have no idea. </p> <p> Also, I'm sure that my code is horrible. Please don't judge me, but feel free to offer better suggestions (using boost::spirit) that do not trigger stack smashes :-) </p> <p> If anyone is able to *not* reproduce the stack smash using Linux, I would also be very curious to hear back about it. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13370 Trac 1.4.3 chrisfriedt@… Sat, 30 Dec 2017 13:19:00 GMT attachment set https://svn.boost.org/trac10/ticket/13370 https://svn.boost.org/trac10/ticket/13370 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gdb-rsp-20171230.tar.gz</span> </li> </ul> <p> source package </p> Ticket anonymous Sun, 31 Dec 2017 01:05:43 GMT <link>https://svn.boost.org/trac10/ticket/13370#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13370#comment:1</guid> <description> <p> Gah... nevermind. I just did a fresh build on Mac OS X and the same problems are happening there now. </p> </description> <category>Ticket</category> </item> <item> <author>Nikita Kniazev <nok.raven@…></author> <pubDate>Mon, 01 Jan 2018 17:13:35 GMT</pubDate> <title>summary changed; cc set https://svn.boost.org/trac10/ticket/13370#comment:2 https://svn.boost.org/trac10/ticket/13370#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">nok.raven@…</span> added </li> <li><strong>summary</strong> <span class="trac-field-old">Boost Spirit Stack Smash with BOOST_SPIRIT_DEBUG defined</span> → <span class="trac-field-new">Qi: Stack Smash with BOOST_SPIRIT_DEBUG defined</span> </li> </ul> <p> Boost periodically run tests with ASAN/UBSAN and I did not see problems. Maybe the bug in your code but not in Spirit. Try to run ASAN (do not forget to enable <code>-fsanitize-address-use-after-scope</code>) on your project. </p> Ticket Joel de Guzman Thu, 22 Nov 2018 13:55:39 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/13370#comment:3 https://svn.boost.org/trac10/ticket/13370#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket