Skip to content

Commit

Permalink
Handle a failed backtrace call (fix #79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Jul 2, 2023
1 parent b131c62 commit c5e5f97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmake/cmake-d
1 change: 1 addition & 0 deletions lib/provision/androidlibrary.d
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ AndroidLibrary memoryOwner(size_t address) {
}
}

getLogger().error("Cannot find the parent library! Expect bugs!");
return null;
}

Expand Down
14 changes: 11 additions & 3 deletions lib/provision/symbols.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ private extern (C) AndroidLibrary dlopenWrapper(const char* name) {
}
try {
auto caller = rootLibrary();
auto lib = new AndroidLibrary(cast(string) name.fromStringz(), caller.hooks);
caller.loadedLibraries ~= lib;
AndroidLibrary lib;
if (caller) {
lib = new AndroidLibrary(cast(string) name.fromStringz(), caller.hooks);
caller.loadedLibraries ~= lib;
} else {
lib = new AndroidLibrary(cast(string) name.fromStringz());
}
return lib;
} catch (Throwable) {
return null;
Expand All @@ -64,7 +69,10 @@ private extern (C) void* dlsymWrapper(AndroidLibrary library, const char* symbol

private extern (C) void dlcloseWrapper(AndroidLibrary library) {
if (library) {
rootLibrary().loadedLibraries.remove!((lib) => lib == library);
auto caller = rootLibrary();
if (caller) {
rootLibrary().loadedLibraries.remove!((lib) => lib == library);
}
destroy(library);
}
}
Expand Down

0 comments on commit c5e5f97

Please sign in to comment.