rust-lang / rust-lang/libc

Using the correct type of sighandler_t windows

Open
#1,637 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breakage-candidate E-easy O-windows
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

I'm opening this here as continuation of discussion on #1626. This also might be related to #1359.

Currently, sighandler_t is an alias to usize on Windows targets. While this works, it is strictly speaking wrong and the right type should be something like Option<extern "C" fn(c_int) -> ()>.

There are, however, concerns about the switch:

  • It is an API change that might break someone's code. At least a crater run would be needed.
  • What is the correct type? Due to the fact this doesn't always contain a valid function pointer, but also some marker constants (eg. SIG_IGN, which has value of 1), it is unclear if this is correct on the Rust side. It seems the consensus is function pointers need to be non-null (solved by the Option) and properly aligned, but the alignment of function pointer on all platforms Windows currently run is 1, so for that reason this should be fine.

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 by reading the discussion in #1626 and the related issue #1359, then inspect the Windows definition of sighandler_t. Check how function pointers and marker constants such as SIG_IGN are represented, and assess the API impact, including whether a crater run is needed. Done means the correct type and a compatible change path are agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.