asmaloney / asmaloney/asmCrashReport

Linux support

Open
#7 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
54
Forks
28
PR merge metrics
No merged PRs in 30d

Description

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
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(sAlternateStack), SIGSTKSZ, 0 };
+#ifdef Q_OS_LINUX^M
+ stack_t ss {static_cast(sAlternateStack), 0, SIGSTKSZ};^M
+#else^M
+ stack_t ss {static_cast(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.

```c++
#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]
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/asmCrashReport.cpp, especially _posixSetupSignalHandler and _posixSignalHandler, and reproduce the reported behavior on Ubuntu 16.04 with Qt 5.12. Check the stack_t initialization, sigaltstack, SIGSEGV handling, and SA_ONSTACK behavior; done means Linux builds and reliably reports the tested access-violation and stack-overflow cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux, ubuntu
Domain
devtools, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.