Skip to content

Linux support #7

@huseyinkozan

Description

@huseyinkozan

Hi,

I tried my development env which is Ubuntu 16.04 64bit, and got some problems. I got prebuilt Qt 5.12 which installed by Qt installer.

First, line endings are not LF. Editing and sending to git may cause problems, so did not try to add a PR.

Could not catch divide by zero, so tried with access violation.

stack_t have different order than you initialized. Got asmCrashReportExample: sigaltstack: Invalid argument error. I have fixed by adding a correct ordered initialization.

With SA_ONSTACK, does not call handler at access violation. Also, cannot catch stack overflow with or without SA_ONSTACK.

diff --git a/src/asmCrashReport.cpp b/src/asmCrashReport.cpp
index 3799d11..bfbcc89 100644
--- a/src/asmCrashReport.cpp
+++ b/src/asmCrashReport.cpp
@@ -391,7 +391,11 @@ namespace asmCrashReport
    void _posixSetupSignalHandler()
    {
       // setup alternate stack
-      stack_t ss{ static_cast<void*>(sAlternateStack), SIGSTKSZ, 0 };
+#ifdef Q_OS_LINUX^M
+      stack_t ss {static_cast<void*>(sAlternateStack), 0, SIGSTKSZ};^M
+#else^M
+      stack_t ss {static_cast<void*>(sAlternateStack), SIGSTKSZ, 0};^M
+#endif^M
 
       if ( sigaltstack( &ss, nullptr ) != 0 )
       {
@@ -409,7 +413,8 @@ namespace asmCrashReport
       // backtrace() doesn't work on macOS when we use an alternate stack
       sigAction.sa_flags = SA_SIGINFO;
 #else
-      sigAction.sa_flags = SA_SIGINFO | SA_ONSTACK;
+      // sigAction.sa_flags = SA_SIGINFO | SA_ONSTACK;  // _posixSignalHandler does not called with SA_ONSTACK^M
+      sigAction.sa_flags = SA_SIGINFO;^M
 #endif
 
       if ( sigaction( SIGSEGV, &sigAction, nullptr ) != 0 ) { err( 1, "sigaction" ); }

I have checked sigaction.h and it seems disable. I tried to add below defines before csignal but no luck. Also, IDE shows _GNU_SOURCE already defined.

#define _XOPEN_SOURCE 700
#define _GNU_SOURCE

Here the catched output:

asmCrashReportTest v1.0.0
04 Ara 2019 @ 10:02:19

Caught SIGSEGV: Segmentation Fault

/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7fefff690390]
/home/hk/p/asmCrashReport/build-test-Desktop_Qt_5_12_5_GCC_64bit-Release/asmCrashReportTest() [0x4028f1]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7feffed3d830]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions