Crash in wt code
Added by Sébastien D. over 13 years ago
Hello,
I am working on an application which uses Wt and I have a problem I can't seem to solve (among others ;))
The problem is, it might run smoothly the entire day, I let it run for the night, and when I come back in the morning it's crashed.
3 nights in row I've let it run, 3 crashes.
It crashes on this line (WebSession.C:2092):
WTimerWidget* t = dynamic_cast<WTimerWidget*>(esb->sender());
Here is the stack trace at the time of the crash:
mySoft.exe!Wt::WebSession::getEventType(const Wt::WEvent & event) Line 2092 C
mySoft.exe!Wt::WEvent::eventType() Line 93 C
mySoft.exe!ziam_CoreManager::notify(const Wt::WEvent & event) Line 288 + 0x8 bytes C
mySoft.exe!Wt::WebSession::handleRequest(Wt::WebSession::Handler & handler) Line 1378 + 0x3b bytes C
mySoft.exe!Wt::WebController::handleRequest(Wt::WebRequest * request) Line 603 C
mySoft.exe!http::server::WtReply::consumeRequestBody(const char * begin, const char * end, http::server::Request::State state) Line 139 C
mySoft.exe!http::server::RequestParser::parseBody(http::server::Request & req, boost::shared_ptrhttp::server::Reply reply, char * & begin, char * end) Line 142 C
mySoft.exe!http::server::Connection::handleReadBody() Line 228 C
mySoft.exe!http::server::Connection::handleReadRequest0() Line 166 C
mySoft.exe!http::server::Connection::handleReadRequest(const boost::system::error_code & e, unsigned int bytes_transferred) Line 198 + 0xd bytes C
mySoft.exe!boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> >(boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> function, ...) Line 65 C
mySoft.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int>,boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > >(const boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> & function, boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > & context) Line 39 + 0x56 bytes C
mySoft.exe!boost::asio::detail::win_iocp_socket_recv_op<boost::asio::mutable_buffers_1,boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > >::do_complete(boost::asio::detail::win_iocp_io_service * owner, boost::asio::detail::win_iocp_operation * base, boost::system::error_code ec, unsigned int bytes_transferred) Line 91 + 0x10 bytes C
mySoft.exe!boost::asio::detail::win_iocp_operation::complete(boost::asio::detail::win_iocp_io_service & owner, const boost::system::error_code & ec, unsigned int bytes_transferred) Line 42 + 0x1e bytes C
mySoft.exe!boost::asio::detail::win_iocp_io_service::do_one(bool block, boost::system::error_code & ec) Line 387 C
mySoft.exe!boost::asio::detail::win_iocp_io_service::run(boost::system::error_code & ec) Line 160 + 0xe bytes C
mySoft.exe!Wt::WIOService::run() Line 126 + 0x1b bytes C
mySoft.exe!boost::`anonymous namespace'::thread_start_function() + 0x63 bytes C
with the debugger, I can't display values of variables in getEventType, but in eventType() I get only garbage : http://bluebox.selfip.com/wt/plantage.PNG
lower, in WebSession::handleRequest() line 1378, _app is similar : http://bluebox.selfip.com/wt/plantage2.PNG
down one level again, WebControler.C:601, session seems good.
our function notify just calls EventType eventType = event.eventType();
(this was done to restart a timer in case of a UserEvent) and then calls WApplication::notify(event);
btw I'm using wt 3.2.0, but I've been experiencing the same thing with a previous version (wt 3.1.10) but not exactly at the same place (in Wt::WEvent::eventType())
I suspect some race condition, with a session being destroyed ... but why? how to collect more information about the crash? like what is this event ....
so if you have any idea to help me out with this ... I'd be glad to take it !
Replies (6)
RE: Crash in wt code - Added by Koen Deforche over 13 years ago
Hey,
While one could suspect that it simply crashes at midnight when ghosts awaken spook around inside your CPU, it is more plausible that there is a problem in Wt itself :-)
Looking at the place of the crash, I can already spot something that might be wrong:
The method WebSession::decodeSignal() could return 0, and this isn't checked in:
WTimerWidget* t = dynamic_cast<WTimerWidget*>(esb->sender());
So I suggest you try that modification:
EventSignalBase* esb = decodeSignal(*s, false);
if (!esb)
continue;
WTimerWidget* t = dynamic_cast<WTimerWidget*>(esb->sender());
...
and see if it survives next night ?
Regards,
koen
RE: Crash in wt code - Added by Sébastien D. over 13 years ago
will do, thanks.
But the fact that _app points to garbage, isn't it a sign that something else is wrong? like the session receiving this event was already destroyed or something alike?
we had a problem which is supposedly still here (I can't get to reproduce it, I haven't seen it in days) were the page just reloads with no apparent reason, and in the logs it's written session destroyed / session created ... (I work with gamel jones from this post : http://redmine.webtoolkit.eu/boards/2/topics/3409)
I'm thinking, if this happens while an event is being processed ... with just the right timing ...
RE: Crash in wt code - Added by Sébastien D. over 13 years ago
Hello,
I did the modification, and it did not crash, an exception was raised a little later. But I got a chance to understand better what's going on.
it seems to be related to timers firing after the session was destroyed.
I'll reduce the delay of those timers to investigate. In the meantime I believe the little modification you proposed should make it into the next release of Wt :)
All the gory details:
We have a long (1h) timer running for each session. When it times out, a message box is displayed to the user to tell him he's going to be disconnected.
If any UserEvent happens, the timer is restarted.
now what happened last night:
First-chance exception at 0x7c812afb in ziamA_Macadam.exe: Microsoft C exception: Wt::WException at memory location 0x022dde30..
stack trace at the time of the exception:
kernel32.dll!7c812afb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
kernel32.dll!7c812afb()
ziamA_Macadam.exe!Wt::WebSession::doRecursiveEventLoop() Line 969 C
ziamA_Macadam.exe!Wt::WDialog::exec(const Wt::WAnimation & animation) Line 245 C
ziamA_Macadam.exe!Wt::WMessageBox::show(const Wt::WString & caption, const Wt::WString & text, Wt::WFlags buttons, const Wt::WAnimation & animation) Line 157 C
ziamA_Macadam.exe!ziam_CoreManager::sessionTimeout() Line 340 + 0x4c bytes C
ziamA_Macadam.exe!boost::_mfi::mf0<void,ziam_AbstractController>::operator()(ziam_AbstractController * p) Line 50 C
ziamA_Macadam.exe!boost::_bi::list1<boost::_bi::value<ziam_DataProcessing *> >::operator()<boost::_mfi::mf0<void,ziam_DataProcessing>,boost::_bi::list6<Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &> >(boost::bi::type_formal, boost::_mfi::mf0<void,ziam_DataProcessing> & f, boost::_bi::list6<Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &,Wt::NoClass &> & a, boost::bi::type_formal) Line 254 C
ziamA_Macadam.exe!boost::_bi::bind_t<void,boost::_mfi::mf0<void,ziam_ReportController>,boost::_bi::list1<boost::_bi::value<ziam_ReportController *> > >::operator()Wt::WMouseEvent(Wt::WMouseEvent & a1) Line 33 C
ziamA_Macadam.exe!boost::detail::function::void_function_obj_invoker1<boost::_bi::bind_t<void,boost::_mfi::mf0<void,ziam_CoreManager>,boost::_bi::list1<boost::_bi::value<ziam_CoreManager *> > >,void,Wt::WMouseEvent>::invoke(boost::detail::function::function_buffer & function_obj_ptr, Wt::WMouseEvent a0) Line 154 C
ziamA_Macadam.exe!boost::function1<void,Wt::WMouseEvent>::operator()(Wt::WMouseEvent a0) Line 1013 + 0x22 bytes C
ziamA_Macadam.exe!boost::signals::detail::call_bound1::caller<Wt::WMouseEvent,boost::function1<void,Wt::WMouseEvent> >::operator()boost::signals::detail::connection_slot_pair(const boost::signals::detail::connection_slot_pair & slot) Line 120 C
ziamA_Macadam.exe!boost::last_value::operator()<boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1::caller<Wt::WMouseEvent,boost::function1<void,Wt::WMouseEvent> >,boost::signals::detail::named_slot_map_iterator> >(boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1::caller<Wt::WMouseEvent,boost::function1<void,Wt::WMouseEvent> >,boost::signals::detail::named_slot_map_iterator> first, boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1::caller<Wt::WMouseEvent,boost::function1<void,Wt::WMouseEvent> >,boost::signals::detail::named_slot_map_iterator> last) Line 49 + 0x1b bytes C
ziamA_Macadam.exe!boost::signal1<void,Wt::WMouseEvent,boost::last_value,int,std::less,boost::function1<void,Wt::WMouseEvent> >::operator()(Wt::WMouseEvent a1) Line 396 + 0xbf bytes C
ziamA_Macadam.exe!Wt::EventSignalWt::WMouseEvent::processDynamic(const Wt::JavaScriptEvent & jse) Line 1097 C
ziamA_Macadam.exe!Wt::WebSession::processSignal(Wt::EventSignalBase * s, const std::basic_string<char,std::char_traits,std::allocator > & se, const Wt::WebRequest & request, Wt::WebSession::SignalKind kind) Line 2394 C
ziamA_Macadam.exe!Wt::WebSession::notifySignal(const Wt::WEvent & e) Line 2364 C
ziamA_Macadam.exe!Wt::WebSession::notify(const Wt::WEvent & event) Line 65535 C
ziamA_Macadam.exe!ziam_CoreManager::notify(const Wt::WEvent & event) Line 310 C
ziamA_Macadam.exe!Wt::WebSession::handleRequest(Wt::WebSession::Handler & handler) Line 1378 + 0x3b bytes C
ziamA_Macadam.exe!Wt::WebController::handleRequest(Wt::WebRequest * request) Line 603 C
ziamA_Macadam.exe!http::server::WtReply::consumeRequestBody(const char * begin, const char * end, http::server::Request::State state) Line 139 C
ziamA_Macadam.exe!http::server::RequestParser::parseBody(http::server::Request & req, boost::shared_ptrhttp::server::Reply reply, char * & begin, char * end) Line 142 C
ziamA_Macadam.exe!http::server::Connection::handleReadBody() Line 228 C
ziamA_Macadam.exe!http::server::Connection::handleReadRequest0() Line 166 C
ziamA_Macadam.exe!http::server::Connection::handleReadRequest(const boost::system::error_code & e, unsigned int bytes_transferred) Line 198 + 0xd bytes C
ziamA_Macadam.exe!boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> >(boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> function, ...) Line 65 C
ziamA_Macadam.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int>,boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > >(const boost::asio::detail::binder2<boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > >,boost::system::error_code,unsigned int> & function, boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > & context) Line 39 + 0x56 bytes C
ziamA_Macadam.exe!boost::asio::detail::win_iocp_socket_recv_op<boost::asio::mutable_buffers_1,boost::_bi::bind_t<void,boost::_mfi::mf2<void,http::server::Connection,boost::system::error_code const &,unsigned int>,boost::_bi::list3<boost::_bi::value<boost::shared_ptrhttp::server::Connection >,boost::arg<1>,boost::arg<2> > > >::do_complete(boost::asio::detail::win_iocp_io_service * owner, boost::asio::detail::win_iocp_operation * base, boost::system::error_code ec, unsigned int bytes_transferred) Line 91 + 0x10 bytes C
ziamA_Macadam.exe!boost::asio::detail::win_iocp_operation::complete(boost::asio::detail::win_iocp_io_service & owner, const boost::system::error_code & ec, unsigned int bytes_transferred) Line 42 + 0x1e bytes C
ziamA_Macadam.exe!boost::asio::detail::win_iocp_io_service::do_one(bool block, boost::system::error_code & ec) Line 387 C
ziamA_Macadam.exe!boost::asio::detail::win_iocp_io_service::run(boost::system::error_code & ec) Line 160 + 0xe bytes C
ziamA_Macadam.exe!Wt::WIOService::run() Line 126 + 0x1b bytes C
ziamA_Macadam.exe!boost::`anonymous namespace'::thread_start_function() + 0x63 bytes C
logs:
not much except a new session pops up before the exception
and after (I had set the debugger to break on any exception):
2924 [/MYSOFT D82oKJZQtQDKarnR] [error] "Wt: Error during event handling: doRecursiveEventLoop(): session was killed"
2924 [/MYSOFT 4PeduAfSJmZchwdQ] [error] "Wt: Error during event handling: doRecursiveEventLoop(): session was killed"
2924 [/MYSOFT D82oKJZQtQDKarnR] [info] "WebController: timeout: expiring"
2924 - [info] "WebRequest: took 7968.75ms"
2924 [/MYSOFT 4PeduAfSJmZchwdQ] [info] "Wt: Session destroyed (#sessions = 0)"
2924 [/MYSOFT D82oKJZQtQDKarnR] [info] "Wt: Session destroyed (#sessions = 0)"
RE: Crash in wt code - Added by Koen Deforche over 13 years ago
Hey,
I'm not very familiar with msvc. But that exception is actually "correct" (it is a nuisance that it is an exception that is reported the way it is reported, and we should fix this).
What goes on is: when a session times out while a recursive event loop is busy (e.g. during WDialog::exec()), that stack needs to be unwound for the session to be able to cleanly terminate. We do this by throwing an exception.
So is there, besides this exception, is there any other misbehavior you see ?
Regards,
koen
RE: Crash in wt code - Added by Sébastien D. over 13 years ago
Hello,
nevermind, earlier I was chasing some exception and I activated an option in msvc which makes it break on every exception. that's it :)
In the meantime, I came to the same conclusion about the WMessageBox and I fixed that.
However I encountered an other bug, which I think is from WT. We're sending a file, generated on the fly, through a WFileUpload, and the the client receives only the end (actually he receives ] sizeOfTheFile % 8ko; endOfTheFile ] ). I found a post on this forum, with a somewhat similar problem, where you (I think) state that it'll get a fix in WT 3.2.1. Or maybe it was in the issue tracker, I can't remember, and I can't find it. I'm not at work at the moment.
Is it coming anytime soon? (3.2.1)
RE: Crash in wt code - Added by Koen Deforche over 13 years ago
Hey,
Yes, indeed, that is an unfortunate bug in 3.2.0, it's mentioned here:
http://redmine.webtoolkit.eu/issues/1097
And yes, we are actively working on a 3.2.1 release now.
Regards,
koen