Repository navigation
regression: compiling a x86-windows app with threads with a 64-bit compiler #19619
Copy link
Copy link
Closed
Labels
arch-x8632-bit x8632-bit x86bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Zig Version
0.12.0-dev.3634+3d1652070
Steps to Reproduce and Observed Behavior
> zig build -freference-trace --summary all -Dtarget=x86-windows
install
└─ install zls
└─ zig build-exe zls Debug x86-windows 2 errors
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: error: @fieldParentPtr increases pointer alignment
const closure: *@This() = @fieldParentPtr("run_node", run_node);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: '*align(4) Thread.Pool.spawn__anon_10636.Closure' has alignment '4'
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: '*Thread.Pool.spawn__anon_10636.Closure' has alignment '8'
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: use @alignCast to assert pointer alignment
referenced by:
spawn__anon_10636.Closure: /home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:88:58
runFn: /home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:29
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: error: @fieldParentPtr increases pointer alignment
const closure: *@This() = @fieldParentPtr("run_node", run_node);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: '*align(4) Thread.Pool.spawn__anon_10640.Closure' has alignment '4'
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: '*Thread.Pool.spawn__anon_10640.Closure' has alignment '8'
/home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:39: note: use @alignCast to assert pointer alignment
referenced by:
spawn__anon_10640.Closure: /home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:88:58
runFn: /home/rad/lab/zig/build/stage4/lib/zig/std/Thread/Pool.zig:92:29
error: the following command failed with 2 compilation errors:
/home/rad/lab/zig/build/stage4/bin/zig build-exe -freference-trace=256 -ODebug -target x86-windows -mcpu baseline --dep exe_options --dep tracy --dep known-folders --dep zls -Mroot=/home/rad/lab/zls/npdm/src/main.zig -Mexe_options=/home/rad/lab/zls/npdm/zig-cache/c/cdb97d55e32f50fc9169d1029ec866c5/options.zig -ODebug -target x86-windows -mcpu baseline --dep options -Mtracy=/home/rad/lab/zls/npdm/src/tracy.zig -Mknown-folders=/home/rad/.cache/zig/p/12201314cffeb40c5e4e3da166217d2c74628c74486414aaf97422bcd2279915b9fd/known-folders.zig --dep known-folders --dep diffz --dep tracy --dep build_options --dep version_data -Mzls=/home/rad/lab/zls/npdm/src/zls.zig -Moptions=/home/rad/lab/zls/npdm/zig-cache/c/afa1e7d8563bc1d60b4c78e42a5d2105/options.zig -Mdiffz=/home/rad/.cache/zig/p/12200d71e4b7029ea56a429e24260c6c0e85a3069b0d4ba85eace21a0fd75910aa64/DiffMatchPatch.zig -Mbuild_options=/home/rad/lab/zls/npdm/zig-cache/c/657d1a35550280ee156902394a1ec894/options.zig -Mversion_data=/home/rad/lab/zls/npdm/zig-cache/o/e184a1362fefa6803c3727e5faace999/version_data_master_19824.zig --cache-dir /home/rad/lab/zls/npdm/zig-cache --global-cache-dir /home/rad/.cache/zig --name zls --listen=-
Expected Behavior
It used to work afaik.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arch-x8632-bit x8632-bit x86bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Activity
rohlem commentedon Apr 11, 2024
If the pointer logic is sound (which it presumably is), the code now needs to assert the required alignment via
@alignCast.(EDIT: Meaning we forgot to update
stdin this place.)Vexu commentedon Apr 12, 2024
This was an intentional change in #19470
nektro commentedon Apr 12, 2024
those errors and notes are all in the standard library.
my confusion is how is a
*Thread.Pool.spawn__anon_10636.Closurehave an alignment of 8 on 32bit ?techatrix commentedon Apr 12, 2024
Here is a code snippet that triggers the compile error:
This doesn't happen if
valueis justconst value: u64 = 0;Disable the `x86-windows` target