mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
8010389: After fix for 7107135 a failed dlopen() call results in a VM crash
Call dlerror() in VM thread as necessary. Reviewed-by: coleenp, dholmes
This commit is contained in:
parent
661b263eb2
commit
ba67f14480
3 changed files with 65 additions and 14 deletions
|
@ -1811,13 +1811,15 @@ bool os::Linux::_stack_is_executable = false;
|
|||
class VM_LinuxDllLoad: public VM_Operation {
|
||||
private:
|
||||
const char *_filename;
|
||||
char *_ebuf;
|
||||
int _ebuflen;
|
||||
void *_lib;
|
||||
public:
|
||||
VM_LinuxDllLoad(const char *fn) :
|
||||
_filename(fn), _lib(NULL) {}
|
||||
VM_LinuxDllLoad(const char *fn, char *ebuf, int ebuflen) :
|
||||
_filename(fn), _ebuf(ebuf), _ebuflen(ebuflen), _lib(NULL) {}
|
||||
VMOp_Type type() const { return VMOp_LinuxDllLoad; }
|
||||
void doit() {
|
||||
_lib = os::Linux::dll_load_inner(_filename);
|
||||
_lib = os::Linux::dll_load_in_vmthread(_filename, _ebuf, _ebuflen);
|
||||
os::Linux::_stack_is_executable = true;
|
||||
}
|
||||
void* loaded_library() { return _lib; }
|
||||
|
@ -1865,13 +1867,13 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
|||
// This is for the case where the DLL has an static
|
||||
// constructor function that executes JNI code. We cannot
|
||||
// load such DLLs in the VMThread.
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
result = os::Linux::dlopen_helper(filename, ebuf, ebuflen);
|
||||
}
|
||||
|
||||
ThreadInVMfromNative tiv(jt);
|
||||
debug_only(VMNativeEntryWrapper vew;)
|
||||
|
||||
VM_LinuxDllLoad op(filename);
|
||||
VM_LinuxDllLoad op(filename, ebuf, ebuflen);
|
||||
VMThread::execute(&op);
|
||||
if (LoadExecStackDllInVMThread) {
|
||||
result = op.loaded_library();
|
||||
|
@ -1883,7 +1885,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
|||
}
|
||||
|
||||
if (!load_attempted) {
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
result = os::Linux::dlopen_helper(filename, ebuf, ebuflen);
|
||||
}
|
||||
|
||||
if (result != NULL) {
|
||||
|
@ -1892,11 +1894,6 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
|||
}
|
||||
|
||||
Elf32_Ehdr elf_head;
|
||||
|
||||
// Read system error message into ebuf
|
||||
// It may or may not be overwritten below
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen-1);
|
||||
ebuf[ebuflen-1]='\0';
|
||||
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
||||
char* diag_msg_buf=ebuf+strlen(ebuf);
|
||||
|
||||
|
@ -2039,10 +2036,19 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void * os::Linux::dll_load_inner(const char *filename) {
|
||||
void * os::Linux::dlopen_helper(const char *filename, char *ebuf, int ebuflen) {
|
||||
void * result = ::dlopen(filename, RTLD_LAZY);
|
||||
if (result == NULL) {
|
||||
::strncpy(ebuf, ::dlerror(), ebuflen - 1);
|
||||
ebuf[ebuflen-1] = '\0';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void * os::Linux::dll_load_in_vmthread(const char *filename, char *ebuf, int ebuflen) {
|
||||
void * result = NULL;
|
||||
if (LoadExecStackDllInVMThread) {
|
||||
result = ::dlopen(filename, RTLD_LAZY);
|
||||
result = dlopen_helper(filename, ebuf, ebuflen);
|
||||
}
|
||||
|
||||
// Since 7019808, libjvm.so is linked with -noexecstack. If the VM loads a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue