Re: [Cppcms-users] Segmentaion fault occurs to booster::aio::io_service running in booster::thread
Brought to you by:
artyom-beilis
From: CN <cn...@fa...> - 2016-05-09 13:01:45
|
I am trying to implement a mechanism so that the program catches SIGHUP signal and accordingly reloads configuration file as suggested here: http://cppcms.com/wikipp/en/page/cppcms_1x_reload_application The signals handler installed by void service::setup_exit_handling() in file "service.cpp" simply calls cppcms::service::shutdown(). I therefore have to roll my own. Regarding the log of gdb backtrace, I seem to have encountered some trouble - upon the arrival of signal HUP, the process straightly disappears from gdb's control without trace leaving command "backtrace" useless. I am still trying to figure out how. I will post it as soon as I have it. Best regards, CN On Mon, May 9, 2016, at 06:36 PM, Artyom Beilis wrote: > 1st why are you using your own signal handler instead of one used > by CppCMS? > On segfault - can you show the backtrace of the stack from gdb when it > happens. > > > Artyom > >> **From:** CN <cn...@fa...> **To:** cppcms- >> us...@li... **Sent:** Sunday, May 8, 2016 5:04 PM >> **Subject:** [Cppcms-users] Segmentaion fault occurs to >> booster::aio::io_service running in booster::thread >> >> File "t.cpp": >> >> #include <booster/aio/io_service.h> >> #include <cppcms/service.h> >> #include <boost/bind.hpp> >> #include <booster/shared_ptr.h> >> #include <booster/log.h> >> #include <signal.h> >> booster::shared_ptr<cppcms::service> this_cppcms_service; >> static int caught_signal=-1; >> >> void signal_handler(int signal_number) >> { >> BOOSTER_DEBUG("begin handler"); >> caught_signal=signal_number; >> this_cppcms_service->shutdown(); >> BOOSTER_DEBUG("end handler"); >> } >> >> class my_class { >> private: >> booster::aio::io_service io_service; >> public: >> void start(){ >> io_service.run(); >> } >> void stop(){ >> io_service.stop(); >> } >> }; >> >> >> int main(int argc,char ** argv) >> { >> while(true){ >> try{ >> this_cppcms_service.reset(new >> cppcms::service(argc,argv)); >> //Install signals catchers. >> struct sigaction actions; >> memset(&actions,0,sizeof(actions)); >> actions.sa_handler=signal_handler; >> int result; >> if( >> (result=sigaction(SIGTERM,&actions,NULL)) >> != 0 >> || >> (result=sigaction(SIGHUP,&actions,NULL)) >> != 0 >> ){ >> BOOSTER_ERROR("") << "sigaction() >> failed"; >> exit(EXIT_FAILURE); >> } >> my_class mc; >> booster::thread >> mc_thread(boost::bind(&my_class::start,&mc)); >> >> BOOSTER_DEBUG("==1=="); >> this_cppcms_service->run(); >> BOOSTER_DEBUG("==2=="); >> mc.stop(); mc_thread.join(); >> BOOSTER_DEBUG("==3=="); >> if(caught_signal == SIGTERM) >> return 0; >> BOOSTER_DEBUG("==4=="); >> //SIGHUP to reload configurations >> } >> catch(std::exception const &e){ >> BOOSTER_ERROR("") << e.what(); >> return 1; >> } >> } >> return 0; >> } >> >> ---------- >> >> File "t.js": >> >> { >> "service" : { >> "api" : "fastcgi", >> "socket" : "/tmp/t.sock", >> "disable_global_exit_handling":true >> }, >> "daemon":{ >> "enable":true, >> "lock":"/tmp/t.pid" >> }, >> "logging" : { >> "level" : "debug", >> "stderr" : false, >> "syslog" : { >> "enable":true, >> "id" : "t" >> } >> } >> } >> >> -------- >> >> Commands issued: >> >> cd /tmp >> g++ -lbooster -lcppcms -lboost_system t.cpp >> ./a.out -c t.js >> kill -TERM `cat t.pid` >> >> -------- >> >> File "/var/log/syslog": >> >> May 8 21:36:13 host t: ==1==: (t.cpp:51) >> May 8 21:36:36 host t: begin handler: (t.cpp:12) >> May 8 21:36:36 host t: end handler: (t.cpp:15) >> May 8 21:36:36 host t: ==2==: (t.cpp:53) >> May 8 21:36:36 host kernel: a.out[5146]: segfault at b5b5dba8 ip >> b715205e sp bfad0620 error 4 in libpthread-2.19.so[b714a000+18000] >> >> >> With this simple code, I get segfault at "mc.stop(); >> mc_thread.join();" >> after issuing command "kill -TERM <pid>". Would someone please >> enlighten >> me why? >> >> Best regards, >> CN >> >> -- >> http://www.fastmail.com [1]- Accessible with your email software >> or over the web >> >> >> --------------------------------------------------------------------- >> --------- >> Find and fix application performance issues faster with Applications >> Manager >> Applications Manager provides deep performance insights into multiple >> tiers of >> your business applications. It resolves application problems >> quickly and >> reduces your MTTR. Get your free trial! >> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > ---------------------------------------------------------------------- > -------- > Find and fix application performance issues faster with > Applications Manager > Applications Manager provides deep performance insights into multiple > tiers of > your business applications. It resolves application problems > quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z[2] > _________________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users Links: 1. http://www.fastmail.com/ 2. https://ad.doubleclick.net/ddm/clk/302982198%3B130105516%3Bz -- http://www.fastmail.com - IMAP accessible web-mail |