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

Fix: use uninitialized LibC::SigsetT #15144

Conversation

straight-shoota
Copy link
Member

LibC::SigsetT is a struct on some platforms and an alias to UInt32 on others. .new is only valid for the struct variant. uninitialized should work in either case.

This code is only used with -Dgc_none, so a reproduction needs to include that flag and build for a target where LibC::SigsetT = alias UInt32, such as aarch64-apple-darwin.

$ bin/crystal build .test/hello-world.cr -Dgc_none --cross-compile --target=aarch64-apple-darwin24.1.0
Showing last frame. Use --error-trace for full trace.

In src/crystal/system/unix/pthread.cr:211:28

 211 | mask = LibC::SigsetT.new
                            ^--
Error: wrong number of arguments for 'UInt32.new' (given 0, expected 1..7)

Overloads are:
 - UInt32.new(value : String, base : Int = 10, whitespace : Bool = true, underscore : Bool = false, prefix : Bool = false, strict : Bool = true, leading_zero_is_octal : Bool = false)
 - UInt32.new(value)

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime labels Nov 1, 2024
@straight-shoota straight-shoota self-assigned this Nov 1, 2024
@oprypin oprypin changed the title Fix use uninitialized LibC::SigsetT Fix: use uninitialized LibC::SigsetT Nov 1, 2024
@straight-shoota straight-shoota added this to the 1.15.0 milestone Nov 3, 2024
@straight-shoota straight-shoota merged commit 563d6d2 into crystal-lang:master Nov 4, 2024
69 checks passed
@straight-shoota straight-shoota deleted the fix/uninitialized-sigsett branch November 4, 2024 11:21
spuun added a commit to cloudamqp/homebrew-cloudamqp that referenced this pull request Nov 5, 2024
This is a workaround for a [bug in crystal](crystal-lang/crystal#15144)
spuun added a commit to cloudamqp/homebrew-cloudamqp that referenced this pull request Nov 5, 2024
This is a workaround for a [bug in crystal](crystal-lang/crystal#15144)
CTC97 pushed a commit to CTC97/crystal that referenced this pull request Nov 9, 2024
`LibC::SigsetT` is a `struct` on some platforms and an alias to `UInt32` on others. `.new` is only valid for the struct variant. `uninitialized` should work in either case.

This code is only used with `-Dgc_none`, so a reproduction needs to include that flag and build for a target where `LibC::SigsetT = alias UInt32`, such as `aarch64-apple-darwin`.
dentarg added a commit to dentarg/lavinmq that referenced this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants