Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bofObjectRunAsyncThread() crash on older GLIBC #4

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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