8248524: [JVMCI] Memory corruption / segfault during NumPy installation

Reviewed-by: kvn
This commit is contained in:
Tom Rodriguez 2020-07-15 12:17:19 -07:00
parent e07ad838b5
commit 8cfc7e39df
2 changed files with 2 additions and 16 deletions

View File

@ -621,26 +621,13 @@ const char* JVMCIEnv::as_utf8_string(JVMCIObject str) {
} else { } else {
JNIAccessMark jni(this); JNIAccessMark jni(this);
int length = jni()->GetStringLength(str.as_jstring()); int length = jni()->GetStringLength(str.as_jstring());
char* result = NEW_RESOURCE_ARRAY(char, length + 1); int utf8_length = jni()->GetStringUTFLength(str.as_jstring());
char* result = NEW_RESOURCE_ARRAY(char, utf8_length + 1);
jni()->GetStringUTFRegion(str.as_jstring(), 0, length, result); jni()->GetStringUTFRegion(str.as_jstring(), 0, length, result);
return result; return result;
} }
} }
char* JVMCIEnv::as_utf8_string(JVMCIObject str, char* buf, int buflen) {
if (is_hotspot()) {
return java_lang_String::as_utf8_string(HotSpotJVMCI::resolve(str), buf, buflen);
} else {
JNIAccessMark jni(this);
int length = jni()->GetStringLength(str.as_jstring());
if (length >= buflen) {
length = buflen;
}
jni()->GetStringUTFRegion(str.as_jstring(), 0, length, buf);
return buf;
}
}
#define DO_THROW(name) \ #define DO_THROW(name) \
void JVMCIEnv::throw_##name(const char* msg) { \ void JVMCIEnv::throw_##name(const char* msg) { \
if (is_hotspot()) { \ if (is_hotspot()) { \

View File

@ -261,7 +261,6 @@ public:
JVMCIObject create_box(BasicType type, jvalue* value, JVMCI_TRAPS); JVMCIObject create_box(BasicType type, jvalue* value, JVMCI_TRAPS);
const char* as_utf8_string(JVMCIObject str); const char* as_utf8_string(JVMCIObject str);
char* as_utf8_string(JVMCIObject str, char* buf, int buflen);
JVMCIObject create_string(Symbol* str, JVMCI_TRAPS) { JVMCIObject create_string(Symbol* str, JVMCI_TRAPS) {
JVMCIObject s = create_string(str->as_C_string(), JVMCI_CHECK_(JVMCIObject())); JVMCIObject s = create_string(str->as_C_string(), JVMCI_CHECK_(JVMCIObject()));