Install a signal handler for SIGABRT and SIGSEGV for kwin_wayland
ClosedPublic

Authored by graesslin on Jun 25 2016, 12:51 PM.

Details

Summary

kwin_wayland disables ptrace on itself. This has the side effect of
core dumps no longer be created - which we want as DrKonqi doesn't
work for kwin_wayland.

This change introduces a dedicated signal handler for abort and
segfault. The signal handler enables ptrace again, unsets itself as
signal handler and raises the signal again, so that the proper crash,
abort handling can be performed.

Test Plan

Added a crash, added an abort and verified that coredumpctl
shows the expected coredump.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin updated this revision to Diff 4718.Jun 25 2016, 12:51 PM
graesslin retitled this revision from to Install a signal handler for SIGABRT and SIGSEGV for kwin_wayland.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
Restricted Application added projects: Plasma on Wayland, KWin. · View Herald TranscriptJun 25 2016, 12:51 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
bshah accepted this revision.Jun 25 2016, 12:56 PM
bshah edited edge metadata.
bshah added a subscriber: tcberner.
bshah added inline comments.
main_wayland.cpp
424–426

This also need adaption for HAVE_PROC_TRACE_CTL perhaps? @tcberner can help us here maybe.

This revision is now accepted and ready to land.Jun 25 2016, 12:56 PM
This revision was automatically updated to reflect the committed changes.
tcberner added inline comments.Jun 25 2016, 5:55 PM
main_wayland.cpp
424–426

Sure, I will create a request as soon as I have some time to add it.

Btw, couldn't this be added as some function try_disable_ptrace() and try_enable_ptrace() or something of the form

int try_disable_ptrace()
{
#if HAVE_PR_SET_DUMPABLE
    return     prctl(PR_SET_DUMPABLE, 0);
#endif
#if HAVE_PROC_TRACE_CTL
    int mode = PROC_TRACE_CTL_DISABLE;
    return procctl(P_PID, getpid(), PROC_TRACE_CTL, &mode);
#endif
   qWarning() << "Ptrace disabling not supported";
   return -1;
}
int try_enable_ptrace()
{
#if HAVE_PR_SET_DUMPABLE
    return     prctl(PR_SET_DUMPABLE, 1);
#endif
#if HAVE_PROC_TRACE_CTL
    int mode = PROC_TRACE_CTL_ENABLE;
    return procctl(P_PID, getpid(), PROC_TRACE_CTL, &mode);
#endif
   qWarning() << "Ptrace enabling not supported";
   return -1;
}

and then just use these two functions everywhere instead of always retyping both?