Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,269
    • Issues 4,269
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19205

Closed
Open
Opened Jan 12, 2021 by Douglas Wilson@duog

signal handlers not async signal safe

Summary

Signal handlers are highly constrained in what functions they can call. In particular, they can't malloc or free because mutexes in glibc may already be held by the interrupted thread, resulting in a deadlock. See https://man7.org/linux/man-pages/man7/signal-safety.7.html.

Our signal handlers (in Signals.c) end up calling fprintf and vfprintf in at least rtsSysErrorMsgFn and the libdw backtrace code. I think in practice this is fine, so long as you don't try to format floats.

Chromium have a BSD-ish licensed safe_sprintf in C++ here: https://chromium.googlesource.com/chromium/src/base/+/master/strings/safe_sprintf.h

I understand mysql has one too, but I haven't looked for it.

EDIT: On further investigation, the dwarf backtrace (in Libdw.c) code calls malloc/free. I haven't investigated whether libdw call's malloc internally.

Environment

  • GHC version used: master

Optional:

  • Operating System: Linux
  • System Architecture:
Edited Jan 12, 2021 by Douglas Wilson
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#19205