Skip to content

Commit c5e5f97

Browse files
committed
Handle a failed backtrace call (fix #79)
1 parent b131c62 commit c5e5f97

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

cmake/cmake-d

lib/provision/androidlibrary.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ AndroidLibrary memoryOwner(size_t address) {
252252
}
253253
}
254254

255+
getLogger().error("Cannot find the parent library! Expect bugs!");
255256
return null;
256257
}
257258

lib/provision/symbols.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ private extern (C) AndroidLibrary dlopenWrapper(const char* name) {
4747
}
4848
try {
4949
auto caller = rootLibrary();
50-
auto lib = new AndroidLibrary(cast(string) name.fromStringz(), caller.hooks);
51-
caller.loadedLibraries ~= lib;
50+
AndroidLibrary lib;
51+
if (caller) {
52+
lib = new AndroidLibrary(cast(string) name.fromStringz(), caller.hooks);
53+
caller.loadedLibraries ~= lib;
54+
} else {
55+
lib = new AndroidLibrary(cast(string) name.fromStringz());
56+
}
5257
return lib;
5358
} catch (Throwable) {
5459
return null;
@@ -64,7 +69,10 @@ private extern (C) void* dlsymWrapper(AndroidLibrary library, const char* symbol
6469

6570
private extern (C) void dlcloseWrapper(AndroidLibrary library) {
6671
if (library) {
67-
rootLibrary().loadedLibraries.remove!((lib) => lib == library);
72+
auto caller = rootLibrary();
73+
if (caller) {
74+
rootLibrary().loadedLibraries.remove!((lib) => lib == library);
75+
}
6876
destroy(library);
6977
}
7078
}

0 commit comments

Comments
 (0)