Skip to content

Commit

Permalink
Merge pull request #4 from fermat-prime/main
Browse files Browse the repository at this point in the history
Fixes bofObjectRunAsyncThread() crash on older GLIBC
  • Loading branch information
michal-z authored May 16, 2024
2 parents 4412fc5 + a06214d commit b6f92df
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bof-launcher/src/bof_launcher.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,7 @@ const gstate = struct {
var func_lookup: std.StringHashMap(usize) = undefined;

var libc: if (@import("builtin").os.tag == .linux) ?std.DynLib else void = null;
var libpthread: if (@import("builtin").os.tag == .linux) ?std.DynLib else void = null;
var pthread_create: *const fn (
noalias newthread: *pthread_t,
noalias attr: ?*anyopaque,
Expand Down Expand Up @@ -1878,10 +1879,10 @@ fn initLauncher() !void {
}

if (@import("builtin").os.tag == .linux) {
gstate.libc = try std.DynLib.open("libc.so.6");
gstate.libpthread = try std.DynLib.open("libpthread.so.0");

gstate.pthread_create = gstate.libc.?.lookup(@TypeOf(gstate.pthread_create), "pthread_create").?;
gstate.pthread_detach = gstate.libc.?.lookup(@TypeOf(gstate.pthread_detach), "pthread_detach").?;
gstate.pthread_create = gstate.libpthread.?.lookup(@TypeOf(gstate.pthread_create), "pthread_create").?;
gstate.pthread_detach = gstate.libpthread.?.lookup(@TypeOf(gstate.pthread_detach), "pthread_detach").?;
}

gstate.is_valid = true;
Expand Down Expand Up @@ -1909,6 +1910,10 @@ export fn bofLauncherRelease() callconv(.C) void {
gstate.libc.?.close();
gstate.libc = null;
}
if (gstate.libpthread != null) {
gstate.libpthread.?.close();
gstate.libpthread = null;
}
}

gstate.bof_pool.deinit(gstate.allocator.?);
Expand Down

0 comments on commit b6f92df

Please sign in to comment.