Segfault on Refresh (F5)
Added by Mark Petryk about 6 years ago
When I F5 (refresh) my browser, the server segfaults. This is what comes out on the terminal:
[2019-Jan-09 16:54:41.597] 18715 [/demo ZBHXgzOTEoJdHhcF] [warning] "WApplication: WApplication::addMetaHeader() with no effect"
Thread 5 "warehouse" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe658b700 (LWP 18791)]
Wt::WStatelessSlot::~WStatelessSlot (this=0xf09adb <Wt::Signals::Impl::ProtoSignal<Wt::Dbo::ptr<Mrp::Billing::Invoice::Item> >::SignalLink::unlinkBase(Wt::Signals::Impl::SignalLinkBase*)>, __in_chrg=<optimized out>) at /home/serveradmin/projects/wt-4/src/Wt/WStatelessSlot.C:44
44 connectingSignals_[i]->removeSlot(this);
So it appears I have an issue, but it also reads like like a 'signal' issue.
Obviously, I have something amuck in my code, but I've never known Wt to segfault on Connections or the like.
Any thoughts?
Replies (6)
RE: Segfault on Refresh (F5) - Added by Mark Petryk about 6 years ago
Never mind! This is totally not a Wt problem.
RE: Segfault on Refresh (F5) - Added by Christian Meyer 3 days ago
Hi Mark,
I am running into a similar issue...
My Program Segfaults on Destruction, but only on an edge case that i can not replicate in a sample application with the same modules I built.
I think I might have an Idea about where the error should originate, but no real understanding of why things do not work out there.
And just as I am writing this, I find another edge case that makes even less sense to me ...
It Segfaults on destruction of a unique_ptr<WStatelessSlot>
because _M_t._M_ptr()
returns unknown
.
If you still remember in what direction your solution went, I'd be very happy to hear!
Cheers,
Christian
RE: Segfault on Refresh (F5) - Added by Mark Petryk 3 days ago
Hi Christian,
Sorry, I don't remember!
I do recall that I spent some time inside valgrind to try to isolate a memory loss, but I can't recall now what that was.
~mark
RE: Segfault on Refresh (F5) - Added by Matthias Van Ceulebroeck 2 days ago
Hello Christian,
I am chiming in here, perhaps unhelpfully though, since like Mark I have not seen a segfault on signals before. I'm not saying they do not occur, just that I never encountered such a case.
The destruction of a stateless slot (and also of a jslot) will essentially set up a system to correctly destruct itself, once it gets disconnected, and it is now unused (based on a ref counter), similar to a shared_ptr
.
The only way I see this occur, is when the signal's base gets destructed, but a pointer to the slot itself still is present on some widget. The counter is now essentially out of sync with the state of the application.
I believe that under normal use, this should not occur. So I would posit a guess that at some point the slot is either destructed somewhere it shouldn't be (decreasing its ref counter), or attached weirdly, such that a (copied/temporary/...?) object wrongfully decreases the counter.
These are all stabs in the dark. It's a pity you aren't able to reproduce. That may even invalidate my above guesses, as that could point to something timing related.
If your investigation would produce results, I'd really appreciate a report back. Maybe something happened that warrants a caveat in the documentation, or perhaps something of a tutorial to avoid such cases.
If I can assist with something, please let me know.
Best,
Matthias
RE: Segfault on Refresh (F5) - Added by Christian Meyer 2 days ago
Hi Matthias, thanks for chiming in.
I found a way to reproduce the issue, but can probably not create a small Test Case.
I "accidentaly" fixed the problem when I had trouble with a blank Database.
I had a Submenu that was created in the sidebar but not shown. The call to set this sidebar disabled
created it by accident.
The Submenu had a signal and was connected on that. But the bound variable for the submenu was inside a template condition, which was deactivated itself.
Interestingly the segfault only occured when I was initializing on the login page (hiding the app Container and showing the login widget) but did not login -> closed the tab.
Login in and using the app did not segfault on session end. Neither on Logout or navigating the page without login.
So my guess is that it might have to do with an connected object that is not really in the pagetree?
But then I do not understand why it destroyed fine in case of the whole template itself visible but not when the whole template is hidden?
Maybe you have some insight and background information I do not to make sense of it.
Thank you anyway!
Cheers,
Christian
RE: Segfault on Refresh (F5) - Added by Matthias Van Ceulebroeck 2 days ago
Hello Christian,
thanks a lot for this context. I think this will really help with narrowing down the specific problem.
Wt does some optimizations, ensuring that data that is not visible, is not rendered out, and sent to the client. This keeps the scope of each update as limited as possible (and thus traffic as low as feasible).
Now, this systems is not flawless. We've had rendering edge-cases before with more complex layouts, that hide some content initially.
My guess currently is the following:
- content is added to a template
- this template has conditions, with some of them initially false
- widgets are BOUND to the hidden sections
- the widgets are constructed, but not loaded (lazy loading)
- on destruction, the signal is destructed, but it was never actually correctly attached to something
I will investigate this issue further soon.
Thanks for reporting your findings, I very much appreciate it!
Best,
Matthias