Open n4skx opened 1 year ago
BlackDolphin 1.0
[Info] Allocator created successfully
[Info] Args parsed successfully
[Decrypt] false
[Info] Config parsed successfully
error: Unexpected
Unable to dump stack trace: Unexpected
Please run the example with a debug build (remove -OReleaseFast
and report the standard error messages, which will tell us more about where this unexpected error code came from.
Ok, removed every error handling and put a "try", this is the output:
Flags:
zig build-exe src/main.zig -target x86_64-linux-musl -static -fno-stack-protector -fno-stack-check -fPIC -fPIE -ofmt=elf -ODebug
Output:
/tmp # ./main
unexpected errno: 38
thread 46401 panic: reached unreachable code
Panicked during a panic. Aborting.
Aborted
Strace:
/tmp # strace ./main
execve("./main", ["./main"], [/* 17 vars */]) = 0
arch_prctl(ARCH_SET_FS, 0xb8e1010) = 0
syscall_302(0, 0x3, 0, 0x3fffd8e3890, 0x3fffd8e3890, 0xb8e1030, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = -1 (errno 38)
gettid() = 46847
write(2, "unexpected errno: ", 18unexpected errno: ) = 18
write(2, "38", 238) = 2
write(2, "\n", 1
) = 1
ioctl(2, TIOCGWINSZ, {ws_row=30, ws_col=120, ws_xpixel=640, ws_ypixel=480}) = 0
sigaltstack(NULL, {ss_sp=0xaaaaaaaaaaaaaaaa, ss_flags=SS_DISABLE|0xaaaaaaa8, ss_size=12297829382473034410}) = -1 ENOSYS (Function not implemented)
msync(0x3fffd8e2000, 4096, MS_ASYNC) = -1 ENOSYS (Function not implemented)
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGILL, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGBUS, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGFPE, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
write(2, "thread ", 7thread ) = 7
write(2, "46847", 546847) = 5
write(2, " panic: ", 8 panic: ) = 8
write(2, "reached unreachable code", 24reached unreachable code) = 24
write(2, "\n", 1
) = 1
ioctl(2, TIOCGWINSZ, {ws_row=30, ws_col=120, ws_xpixel=640, ws_ypixel=480}) = 0
sigaltstack(NULL, {ss_sp=0xaaaaaaaaaaaaaaaa, ss_flags=SS_DISABLE|0xaaaaaaa8, ss_size=12297829382473034410}) = -1 ENOSYS (Function not implemented)
msync(0x3fffd8e1000, 4096, MS_ASYNC) = -1 ENOSYS (Function not implemented)
rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGILL, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGBUS, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
rt_sigaction(SIGFPE, {SIG_DFL, [], SA_RESTORER, 0xb87f1d0}, NULL, 8) = 0
write(2, "Panicked during a panic. Abortin"..., 35Panicked during a panic. Aborting.
) = 35
rt_sigprocmask(SIG_BLOCK, ~[HUP INT], [], 8) = 0
gettid() = 46847
tkill(46847, SIGABRT) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
Aborted
Please, consider that my build system and zig version changed:
Host Name: DESKTOP-EIPC53E
OS Name: Microsoft Windows 11 Home Single Language
OS Version: 10.0.22621 N/A Build 22621
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Zig version:
0.12.0-dev.80+014d88ef6
I've adding the missing parts and updated your code so I could compile/test it. It works on my machine but I'm on Windows 10 (not Windows 11 like yourself). Could you run this code and confirm the issue you are seeing is still happening (and send the output if it is):
const builtin = @import("builtin");
const std = @import("std");
pub fn main() !void {
var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const path = if (builtin.os.tag == .windows) "C:\\temp" else "/tmp";
try createNote(.{
.allocator = arena_instance.allocator(),
.config = .{ .decrypt = false, .text = "hello" },
}, path);
try createNote(.{
.allocator = arena_instance.allocator(),
.config = .{ .decrypt = true, .text = "hello" },
}, path);
}
const Self = struct {
allocator: std.mem.Allocator,
config: struct {
decrypt: bool = false,
text: []const u8 = "hello",
} = .{},
};
pub fn createNote(self: Self, path: []const u8) !void {
const buffer = try std.fs.path.join(self.allocator, &.{path, "How_to_recover_your_files.txt"});
defer self.allocator.free(buffer);
if (!self.config.decrypt) {
var file = try std.fs.createFileAbsolute(buffer, .{});
defer file.close();
try file.writer().writeAll(self.config.text);
return;
}
try std.fs.deleteFileAbsolute(buffer);
}
The error isn't in windows itself. The problem is in embedded systems (to be more specific, ESXi 5.5). I will upload my code soon as possible.
Zig Version
0.11.0-dev.3944+2e424e019
Steps to Reproduce and Observed Behavior
Compile flags:
Target system:
Builder system:
Code:
Error
Expected Behavior
Create a file in the specified path. The error seems to happen in old linux versions i guess.