-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
arch-riscv6464-bit RISC-V64-bit RISC-Vbackend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.upstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.
Milestone
Description
Zig Version
0.14.0-dev.367+a57479afc
Steps to Reproduce and Observed Behavior
- Clone my (embarrassingly incomplete) kernel:
$ git clone -b erroneous-error https://git.sr.ht/~gcoakes/kernel- Ensure
qemu-system-riscv64is installed and available within your PATH environment variable:
$ which qemu-system-riscv64- Run it using
ReleaseSmalloptimization mode (pressCTRL+a, xto exit after it fails):
$ zig build run -Doptimize=ReleaseSmall
...
[ info] (default) 8273 + 49 > 8712
panic: failed to parse root task executable: ElfOutOfBounds
0: 0x000000008020311e
1: 0x000a7d7b20656369- Observe an error printed in the last step and observe the impossibility of the conditional that produces that error (src/bootstrap/Elf.zig#L324):
std.log.info("{} + {} > {}", .{ names_section.offset, names_section.size, data.len });
if (names_section.offset + names_section.size > data.len)
return error.ElfOutOfBounds;The log statement in that function prints: 8273 + 49 > 8712
Note that the specific error which is returned seems to be that of the last defined return location within that function. If I comment out the conditional/return statement from above, it then starts returning the next last defined return error.
I apologize for not being able to minimize this further.
Expected Behavior
The run command is expected to exit without any errors being printed. This can be observed by running the same command with either -Doptimize=ReleaseSafe or no optimization hint (Debug mode):
$ zig build run -Doptimize=ReleaseSafe
...
[ info] (default) 20280 + 174 > 21616Metadata
Metadata
Assignees
Labels
arch-riscv6464-bit RISC-V64-bit RISC-Vbackend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.upstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.