Skip to content

[FIX] replace fprintf(), exit() with write(), _exit() to async-safe at SIGSEGV signal handler#435

Merged
r1viollet merged 2 commits into
mainfrom
r1viollet/SIGSEGV-async-safe-handler
Jan 21, 2025
Merged

[FIX] replace fprintf(), exit() with write(), _exit() to async-safe at SIGSEGV signal handler#435
r1viollet merged 2 commits into
mainfrom
r1viollet/SIGSEGV-async-safe-handler

Conversation

@r1viollet

Copy link
Copy Markdown
Collaborator

What does this PR do?

This is a continuation of the work proposed here.
I made some minor changes to include the address on which we are crashing (the address we attempt to access).

Motivation

Refer to original PR.
Thank you @Backend-Changyeon for suggesting the change.

Additional Notes

There will be more work on crashtracking.

How to test the change?

I added a minor unit test, though a proper test on the SIGSEGV would be welcome.

@pr-commenter

pr-commenter Bot commented Jan 16, 2025

Copy link
Copy Markdown

Benchmark results for collatz

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.19.0+706790c0.53177584 ddprof 0.19.0+cf9ec330.53551828

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-collatz --preset cpu_only collatz_runner.sh same

@pr-commenter

pr-commenter Bot commented Jan 16, 2025

Copy link
Copy Markdown

Benchmark results for BadBoggleSolver_run

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.19.0+706790c0.53177584 ddprof 0.19.0+cf9ec330.53551828

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-bad-boggle-solver BadBoggleSolver_run work 1000 same

@r1viollet
r1viollet force-pushed the r1viollet/SIGSEGV-async-safe-handler branch from 37e0884 to bedc627 Compare January 16, 2025 14:47
nsavoire
nsavoire previously approved these changes Jan 17, 2025
@yoochangyeon

Copy link
Copy Markdown
Contributor

@r1viollet Thank you for accepting my commit

@r1viollet
r1viollet force-pushed the r1viollet/SIGSEGV-async-safe-handler branch from bedc627 to 7c30284 Compare January 21, 2025 10:31
Comment thread include/signal_helper.hpp

int convert_addr_to_string(uintptr_t ptr, char *buff, size_t buff_size);

void sigsegv_handler(int sig, siginfo_t *si, void *uc);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up moving the signal handler logic to here.

- Improve the crash log to include address info
- Deduplicate the crash handling function with simple malloc
@r1viollet
r1viollet force-pushed the r1viollet/SIGSEGV-async-safe-handler branch from 7c30284 to cf9ec33 Compare January 21, 2025 13:56
@r1viollet

Copy link
Copy Markdown
Collaborator Author

@nsavoire I will need a new approval

@r1viollet
r1viollet merged commit 92480eb into main Jan 21, 2025
@r1viollet
r1viollet deleted the r1viollet/SIGSEGV-async-safe-handler branch January 21, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants