Properly handle exceptions in case of dynamic libraries. (#3428)
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ class OutputFiles(outputPath: String?, target: KonanTarget, produce: CompilerOut
|
||||
* Header file for dynamic library.
|
||||
*/
|
||||
val cAdapterHeader by lazy { File("${outputName}_api.h") }
|
||||
val cAdapterDef by lazy { File("${outputName}_symbols.def") }
|
||||
val cAdapterDef by lazy { File("${outputName}.def") }
|
||||
|
||||
/**
|
||||
* Main compiler's output file.
|
||||
|
||||
@@ -315,8 +315,11 @@ extern "C" bool AddressToSymbol(const void* address, char* resultBuffer, size_t
|
||||
if (theExeSymbolTable == nullptr) {
|
||||
// Note: do not protecting the lazy initialization by critical sections for simplicity;
|
||||
// this doesn't have any serious consequences.
|
||||
theExeSymbolTable = konanConstructInstance<SymbolTable>(
|
||||
GetModuleHandle(nullptr));
|
||||
HMODULE hModule = nullptr;
|
||||
int rv = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
reinterpret_cast<LPCWSTR>(&AddressToSymbol), &hModule);
|
||||
RuntimeAssert(rv != 0, "GetModuleHandleExW fails");
|
||||
theExeSymbolTable = konanConstructInstance<SymbolTable>(hModule);
|
||||
}
|
||||
return theExeSymbolTable->functionAddressToSymbol(address, resultBuffer, resultBufferSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user