swiftlang / swiftlang/swift-corelibs-libdispatch

[SR-9863] Libdispatch's semaphores mishandle exits due to signals

Open
#623 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug libdispatch
Dominant language
C
Stars
2.6k
Forks
496
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Previous ID SR-9863
Radar rdar://problem/47791327
Original Reporter gmilos (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug
Assignee ktopley-apple (JIRA)
Priority Medium

md5: e78b5ae6fce74b3d638d2adebfa603b3

Issue Description:

The attached reproduction shows how libdispatch semaphore crashes if the process is configured to receive a signal (non-default).

This is due to unguarded sem_wait:
https://github.com/apple/swift-corelibs-libdispatch/blob/dde58922492859d3664ee0bc296a26dee80ee369/src/shims/lock.c#L206

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/shims/lock.c around line 206 and inspect the attached reproduction. Run the reproduction with the process configured to receive a non-default signal, then trace the semaphore wait path and its signal behavior. Done means the reproduction no longer crashes under that signal configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.