Including boost::property_tree::read_json() breaks application.
Added by Erik Sanchez over 9 years ago
I've encountered an issue while integrating a simple wt application with an existing code base. After many iterations of simplification, I now have a pretty simple test case that will break with the simple inclusion of a call to boost::property_tree::read_json(...).
Note that I don't actually call this method, I simply need to include it in the compiled file.
When a client connects to the "broken" application I either get a SIGABRT or it returns a std::bad_alloc. I can only imagine that it's a bad combination of my boost library and my WT installation?
- boost 1.58
- wt 3.3.4
- gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2
I've included my code here as well as an attachment. I've included the CMakeCache.txt in case that is helpful. Any insight or advice would be greatly appreciated!
#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WServer>
#include <Wt/WText>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
using namespace Wt;
class MyApplication : public WApplication
{
public:
MyApplication(const WEnvironment& env)
: WApplication(env)
{
WText *text = new WText();
text->setText("Hello!");
root()->addWidget(text);
}
};
WApplication *createApplication(const WEnvironment& env)
{
/*
* You could read information from the environment to decide whether
* the user has permission to start a new application
*/
return new MyApplication(env);
}
// Note: this function is never called
void crash_me()
{
boost::property_tree::ptree pt;
// Uncommenting the following line causes problems
boost::property_tree::read_json("any-path", pt);
}
int main(int argc, char **argv)
{
// Create user interface
WServer server(argc, argv, WTHTTP_CONFIGURATION);
server.addEntryPoint(Wt::Application, createApplication);
if (server.start())
{
int sig = WServer::waitForShutdown();
std::cerr << "Shutting down: (signal = " << sig << ")" << std::endl;
server.stop();
}
}
Dump of thread's stack with SIGABRT
#0 0x00007ffff66eb267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55 in ../sysdeps/unix/sysv/linux/raise.c
bt
#0 0x00007ffff66eb267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1 0x00007ffff66ececa in __GI_abort () at abort.c:89
#2 0x00007ffff6cf706d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff6cf4ee6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff6cf4f31 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff79c70e2 in boost::spirit::classic::grammar<Wt::(anonymous namespace)::ValueListParser, boost::spirit::classic::parser_context<boost::spirit::classic::nil_t> >::~grammar (this=this@entry=0x7ffff4daaef0, __in_chrg=<optimized out>) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp:88
#6 0x00007ffff79c79bd in ~ValueListParser (this=0x7ffff4daaef0, __in_chrg=<optimized out>) at /home/erik/src/wt-3.3.4/src/web/WebRequest.C:174
#7 ~value (this=0x7ffff4daaef0, __in_chrg=<optimized out>) at /usr/local/include/boost/bind/bind.hpp:112
#8 storage2 (a1=..., this=0x7ffff4daae30) at /usr/local/include/boost/bind/storage.hpp:97
#9 list2 (a1=..., this=0x7ffff4daae30, a2=...) at /usr/local/include/boost/bind/bind.hpp:283
#10 bind<void, Wt::(anonymous namespace)::ValueListParser, double, Wt::(anonymous namespace)::ValueListParser, boost::arg<1> > (a1=..., f=(void (Wt::(anonymous namespace)::ValueListParser::*)(const Wt::(anonymous namespace)::ValueListParser * const, double)) 0x7ffff79c38a0 <Wt::(anonymous namespace)::ValueListParser::setQuality(double) const>, a2=...) at /usr/local/include/boost/bind/bind_mf_cc.hpp:78
#11 definition (self=..., this=0x7fffec0060e0) at /home/erik/src/wt-3.3.4/src/web/WebRequest.C:208
#12 define (target_grammar=0x7ffff4daacb0, this=0x7fffec006060) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp:159
#13 get_definition<Wt::(anonymous namespace)::ValueListParser, boost::spirit::classic::parser_context<>, boost::spirit::classic::scanner<char const*, boost::spirit::classic::scanner_policies<boost::spirit::classic::skipper_iteration_policy<> > > > (self=0x7ffff4daacb0) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp:232
#14 grammar_parser_parse<0, Wt::(anonymous namespace)::ValueListParser, boost::spirit::classic::parser_context<>, boost::spirit::classic::scanner<char const*, boost::spirit::classic::scanner_policies<boost::spirit::classic::skipper_iteration_policy<> > > > (scan=..., self=0x7ffff4daacb0) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp:271
#15 parse_main<boost::spirit::classic::scanner<char const*, boost::spirit::classic::scanner_policies<boost::spirit::classic::skipper_iteration_policy<> > > > (scan=..., this=0x7ffff4daacb0) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/grammar.hpp:57
#16 parse<boost::spirit::classic::scanner<char const*, boost::spirit::classic::scanner_policies<boost::spirit::classic::skipper_iteration_policy<> > > > (scan=..., this=0x7ffff4daacb0) at /usr/local/include/boost/spirit/home/classic/core/non_terminal/grammar.hpp:65
#17 parse<char const*, Wt::(anonymous namespace)::ValueListParser> (first_=<synthetic pointer>, p=..., last=<synthetic pointer>) at /usr/local/include/boost/spirit/home/classic/core/scanner/impl/skipper.ipp:133
#18 parse<char const*, Wt::(anonymous namespace)::ValueListParser, boost::spirit::classic::space_parser> (first=<synthetic pointer>, skip=..., p=..., last=<synthetic pointer>) at /usr/local/include/boost/spirit/home/classic/core/scanner/impl/skipper.ipp:155
#19 parse<char, Wt::(anonymous namespace)::ValueListParser, boost::spirit::classic::space_parser> (skip=..., p=..., str=0x7fffec000b4a "en-US,en;q=0.5") at /usr/local/include/boost/spirit/home/classic/core/scanner/impl/skipper.ipp:173
#20 Wt::WebRequest::parsePreferredAcceptValue (this=this@entry=0x7fffec003e90, str=0x7fffec000b4a "en-US,en;q=0.5") at /home/erik/src/wt-3.3.4/src/web/WebRequest.C:247
#21 0x00007ffff79c89b4 in Wt::WebRequest::parseLocale (this=this@entry=0x7fffec003e90) at /home/erik/src/wt-3.3.4/src/web/WebRequest.C:275
#22 0x00007ffff76d2358 in Wt::WEnvironment::init (this=0x7fffec0058d8, request=...) at /home/erik/src/wt-3.3.4/src/Wt/WEnvironment.C:147
#23 0x00007ffff79cb8f0 in Wt::WebSession::init (this=this@entry=0x7fffec004060, request=...) at /home/erik/src/wt-3.3.4/src/web/WebSession.C:367
#24 0x00007ffff79cf500 in Wt::WebSession::handleRequest (this=0x7fffec004060, handler=...) at /home/erik/src/wt-3.3.4/src/web/WebSession.C:1353
#25 0x00007ffff79c0c52 in Wt::WebController::handleRequest (this=0x65b840, request=0x7fffec003e90) at /home/erik/src/wt-3.3.4/src/web/WebController.C:713
#26 0x00007ffff704bc9f in operator() (a1=0x7fffec003e90, p=0x65b840, this=<synthetic pointer>) at /usr/local/include/boost/bind/mem_fn_template.hpp:165
#27 operator()<boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list0> (a=<synthetic pointer>, f=<synthetic pointer>, this=<synthetic pointer>) at /usr/local/include/boost/bind/bind.hpp:313
#28 operator() (this=<synthetic pointer>) at /usr/local/include/boost/bind/bind.hpp:893
#29 asio_handler_invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > > (function=<synthetic pointer>) at /usr/local/include/boost/asio/handler_invoke_hook.hpp:69
#30 invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > >, boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > > (context=<synthetic pointer>, function=<synthetic pointer>) at /usr/local/include/boost/asio/detail/handler_invoke_helpers.hpp:37
#31 boost::asio::detail::completion_handler<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > >::do_complete (owner=0x65ce00, base=0x7fffec002aa0) at /usr/local/include/boost/asio/detail/completion_handler.hpp:68
#32 0x00007ffff771f571 in complete (bytes_transferred=<optimized out>, ec=..., owner=..., this=<optimized out>) at /usr/local/include/boost/asio/detail/task_io_service_operation.hpp:38
#33 do_run_one (ec=..., this_thread=..., lock=..., this=0x65ce00) at /usr/local/include/boost/asio/detail/impl/task_io_service.ipp:372
#34 boost::asio::detail::task_io_service::run (this=0x65ce00, ec=...) at /usr/local/include/boost/asio/detail/impl/task_io_service.ipp:149
#35 0x00007ffff771cad9 in run (this=0x65c0a8) at /usr/local/include/boost/asio/impl/io_service.ipp:59
#36 Wt::WIOService::run (this=0x65c0a0) at /home/erik/src/wt-3.3.4/src/Wt/WIOService.C:180
#37 0x00007ffff64a4bfa in thread_proxy () from /usr/local/lib/libboost_thread.so.1.58.0
#38 0x00007ffff55536aa in start_thread (arg=0x7ffff4dae700) at pthread_create.c:333
#39 0x00007ffff67bceed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
main.cpp (1.17 KB) main.cpp | |||
CMakeCache.txt (30 KB) CMakeCache.txt |