Skip to content

Commit

Permalink
std.Thread: fix off-by-one in PosixThreadImpl (ziglang#18711)
Browse files Browse the repository at this point in the history
by removing ZST special case
  • Loading branch information
cflicker authored Jan 29, 2024
1 parent 7b45611 commit 9c7fa35
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/std/Thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,6 @@ const PosixThreadImpl = struct {

const Instance = struct {
fn entryFn(raw_arg: ?*anyopaque) callconv(.C) ?*anyopaque {
// @alignCast() below doesn't support zero-sized-types (ZST)
if (@sizeOf(Args) < 1) {
return callFn(f, @as(Args, undefined));
}

const args_ptr: *Args = @ptrCast(@alignCast(raw_arg));
defer allocator.destroy(args_ptr);
return callFn(f, args_ptr.*);
Expand All @@ -703,7 +698,7 @@ const PosixThreadImpl = struct {
&handle,
&attr,
Instance.entryFn,
if (@sizeOf(Args) > 1) @as(*anyopaque, @ptrCast(args_ptr)) else undefined,
@ptrCast(args_ptr),
)) {
.SUCCESS => return Impl{ .handle = handle },
.AGAIN => return error.SystemResources,
Expand Down

0 comments on commit 9c7fa35

Please sign in to comment.