Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use signal-safe functions in signal handler #3557

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

mkindahl
Copy link
Contributor

@mkindahl mkindahl commented Sep 7, 2021

Reporting errors using ereport can call malloc(), which is not
signal-safe. Using ereport() in a signal handler can therefore cause
malloc() to run nested inside malloc() if the termination handler
is called in the middle of a malloc() call, which will trigger an
assertion in malloc() that will take down the server.

This commit fixes this by using the signal-safe write_stderr() inside
the signal handlers for the background workers.

Fixes #3469

@mkindahl mkindahl requested a review from a team as a code owner September 7, 2021 11:33
@mkindahl mkindahl requested review from berkley, fabriziomello and afiskon and removed request for a team September 7, 2021 11:33
@mkindahl mkindahl self-assigned this Sep 7, 2021
@mkindahl mkindahl enabled auto-merge (rebase) September 7, 2021 13:08
Reporting errors using `ereport` can call `malloc()`, which is not
signal-safe. Using `ereport()` in a signal handler can therefore cause
`malloc()` to run nested inside `malloc()` if the termination handler
is called in the middle of a `malloc()` call, which will trigger an
assertion in `malloc()` that will take down the server.

This commit fixes this by using the signal-safe `write_stderr()` inside
the signal handlers for the background workers.

Fixes timescale#3469
@mkindahl mkindahl merged commit 29f3b51 into timescale:master Sep 8, 2021
@mkindahl mkindahl deleted the bgw-init-crash branch September 8, 2021 08:33
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.

TimescaleDB Background Worker Scheduler crash with "malloc.c:2394: sysmalloc: Assertion ... failed"
3 participants