Re: [Cppcms-users] Segmentation fault on FreeBSD in high load
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-08-08 19:43:58
|
Ok.... This is kind of stuff I actually would expect from FreeBSD users to find very fast.... All you need to do to prevent accidental crashes is to... Link directly with pthread, i.e. add -lpthread flag... These crashes caused by the fact that for some reason I don't 100% understand libstdc++ does not perform atomic operations where they are needed (reference counting of locale objects for example) This is an optimization for the single threaded case, but unfortunately if you don't link the main executable directly with libpthread it does not detect it properly (i.e. libcppcms linked to libpthread but not the main exe) So what happens that std::locale object that uses reference counting finally gets invalid value. If it goes too high than the locale object is not either destroyed (which leads to memory leak) or get destroyed to early - which leads to the crash... Once you link with pthread directly the problem goes away. So in you example you send, change LIBS=-lcppcms -lbooster -lcppdb to LIBS=-lcppcms -lbooster -lcppdb -lpthread And it would 100% work... I thought it was a critical bug in the framework and spend half a day on it... I'm glad it is not. But you, FreeBSD users should be the first one to notice that some threading stuff is missing. (BTW under Linux there is no such a problem, even if it is not linked with -lpthread it works 100%) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >>> ________________________________ >>> From: Vinicius Pavanelli <ds...@ha...> >> >>> Thanks for your reply Artyom, >>> >>> >>> I'm checking my code, taking the smaller part that reproduce this bug to understand it, if needed can send but this only happens on FreeBSD. >>> >>> >>> Is CppCMS under FreeBSD considered ok for production or it's mainly Linux? >>> >> >> Yes it is production ready and tested on daily basis: >> >> http://cppcms.com/files/nightly-build-report.html >> >> (of course as in any case there may be a bug) >> >> >>> >>> The line at #2 is just: set_content_header("text/html"), inside http_response.cpp, this looks very strange to me, it's very ok. >>> >> >> Ok, if so this does not related, you are right. >> >> >>> >>> I don't have info.h in my files so i'm assuming it's booster/booster/locale/info.h, is this correct, >>> >> >> Ok I see. >> >> Also indeed this bug is exactly related. >> >> >> http://sourceforge.net/tracker/?func=detail&aid=3535893&group_id=209965&atid=1011835 >> >> >> I have several questions: >> >> - What version do you use? Trunk or Stable? (If trunk, does it happens on stable as well?) > >CppCMS-1.0.1 stable > >> - Do you compile libcppcms with ICU or without? >> - If it is built with ICU, what version? >> > >ICU 4.8.1.1_1 (from packages) > >> - What is the system locale? (output of locale) >> > >freebsd# locale >LANG= >LC_CTYPE="C" >LC_COLLATE="C" >LC_TIME="C" >LC_NUMERIC="C" >LC_MONETARY="C" >LC_MESSAGES="C" >LC_ALL= > > >> - What is the content header returned by the application (when it is not crashed) > >Content-Type: text/html; charset=utf-8 > >> >> Now about libstdc++. >> >> - What version of GCC do you use, or you are using Clang? >> >> >> Please note: I ask about building CppCMS not your application. >> > >I used both gcc 4.2.1 (20070831) and clang 3.0 (20111021). > >> >> - How many cores does you computer has? > >4 cores > >> >> - How do you link with libcppcms library statically or dynamically? >> > >Dynamically > >> >> I don't think it is related to threading library it may be a bug >> connected to facets, locking and standard library. > >If I can provide any more info please let me know. > >Thanks for your help Artyom, > >> >> >>> >>> >>> Em 07/08/2012, às 00:57, Artyom Beilis escreveu: >>> >>> See: >>>> >>>> >>>> 1 0x0000000800939cb3 in cppcms::http::response::set_content_header >> (this=0x80ba7ac00, content_type=@0x7fffffffd590) at info.h:83 >>>> >>>> >>>> It looks like content_type you pass in info.h line 83 has very strange address 0x7fffffffd590 - i.e. it is very close to 0x7FFFFFFFF >>>> It seems strange to me check your code. >>>> >>>> >>>> Artyom Beilis >>>> -------------- >>>> CppCMS - C++ Web Framework: http://cppcms.com/ >>>> CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >>>> >>>> >>>> >>>>> ________________________________ >>>>> From: Vinicius Pavanelli <ds...@ha...> >>>>> To: cpp...@li... >>>>> Sent: Tuesday, August 7, 2012 5:15 AM >>>>> Subject: [Cppcms-users] Segmentation fault on FreeBSD in high load >>>>> >>>>> Hi, >>>>> >>>>> I'm new to CppCMS and been doing some work on it, too see where I get. >>>>> When I run the code on Linux/Gentoo it works fine, on FreeBSD it runs fine too, but on high loads it crashs (like when testing with siege). >>>>> Can anyone help me on what may be wrong with it? It's my code, something on FreeBSD? >>>>> >>>>> By the way, I got 22k trans/sec with CppCMS on Gentoo, running the embedded web server, the Apache with static files is way bellow this. >>>>> The performance gain from PHP to CppCMS is very impressive. >>>>> >>>>> Thanks in advance, >>>>> Vinicius >>>>> >>>>> >>>>> System: FreeBSD freebsd 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012 ro...@am...:/usr/obj/usr/src/sys/GENERIC amd64 >>>>> >>>>> The gdb log is: >>>>> ---------------------- >>>>> Program received signal SIGSEGV, Segmentation >> fault. >>>>> [Switching to Thread 804807400 (LWP 100101/wep)] >>>>> 0x000000000061d870 in vtable for __cxxabiv1::__class_type_info () >>>>> (gdb) bt >>>>> #0 0x000000000061d870 in vtable for __cxxabiv1::__class_type_info () >>>>> #1 0x0000000800939cb3 in cppcms::http::response::set_content_header (this=0x80ba7ac00, content_type=@0x7fffffffd590) at info.h:83 >>>>> #2 0x000000080093b90b in response (this=0x80ba7ac00, context=@0x807bf75b0) at /root/work/cppcms-1.0.1/src/http_response.cpp:116 >>>>> #3 0x000000080094953d in context (this=0x807bf75b0, conn=Variable "conn" is not available. >>>>> ) at /root/work/cppcms-1.0.1/src/http_context.cpp:58 >>>>> #4 0x0000000800a2dc07 in booster::callback<void ()(booster::system::error_code const&)>::callable_impl<void, cppcms::impl::cgi::socket_acceptor<cppcms::impl::cgi::http, cppcms::impl::cgi::http_creator>::accept_binder>::operator() (this=Variable "this" is not available. >>>>> ) at >> cgi_acceptor.h:140 >>>>> #5 0x0000000800cf9059 in operator() (this=0x8083feee0, e=Variable "e" is not available. >>>>> ) at callback.h:211 >>>>> #6 0x0000000800cee189 in booster::callback<void ()()>::callable_impl<void, booster::aio::event_loop_impl::event_handler_dispatcher>::operator() (this=Variable "this" is not available. >>>>> ) >>>>> at callback.h:211 >>>>> #7 0x0000000800cef490 in booster::aio::event_loop_impl::run_one (this=0x804842200, evs=0x80480e000, evs_size=128) at callback.h:201 >>>>> #8 0x0000000800cec349 in booster::aio::io_service::run (this=Variable "this" is not available. >>>>> ) at /root/work/cppcms-1.0.1/booster/lib/aio/src/io_service.cpp:144 >>>>> #9 0x0000000800918dde in cppcms::service::run (this=0x7fffffffda80) at /root/work/cppcms-1.0.1/src/service.cpp:574 >>>>> #10 0x000000000040d472 in main (argc=Variable "argc" is not available. >>>>> ) at >> wep.cpp:167 >>>>> ---------------------- >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Live Security Virtual Conference >>>>> Exclusive live event will cover all the ways today's security and >>>>> threat landscape has changed and how IT managers can respond. Discussions >>>>> will include endpoint security, mobile security and the latest in malware >>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >>>>> _______________________________________________ >>>>> Cppcms-users mailing list >>>>> Cpp...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>> Live Security Virtual Conference >>>> Exclusive live event will cover all the ways today's security and >>>> threat landscape has changed and how IT managers can respond. Discussions >>>> will include endpoint security, mobile security and the latest in malware >>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________ >>>> Cppcms-users mailing list >>>> Cpp...@li... >>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>>> >>> >>> ------------------------------------------------------------------------------ >>> Live Security Virtual Conference >>> Exclusive live event will cover all the ways today's security and >>> threat landscape has changed and how IT managers can respond. Discussions >>> will include endpoint security, mobile security and the latest in malware >>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >>> _______________________________________________ >>> Cppcms-users mailing list >>> Cpp...@li... >>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>> >>> >>> >> >> >> >> Artyom Beilis >> -------------- >> CppCMS - C++ Web Framework: http://cppcms.com/ >> CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users > > >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. Discussions >will include endpoint security, mobile security and the latest in malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |