“08941eda5d0c007051abdb6dd0a5f45cd94a433a”上不存在“paddle/phi/kernels/funcs/reduce_function.h”
提交 0008f1fc 编写于 作者: I iignatyev

8029070: memory leak in jmm_SetVMGlobal

Reviewed-by: kvn, dholmes
上级 3f11cd3e
...@@ -759,8 +759,6 @@ bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { ...@@ -759,8 +759,6 @@ bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) {
return true; return true;
} }
// Contract: Flag will make private copy of the incoming value.
// Outgoing value is always malloc-ed, and caller MUST call free.
bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) {
Flag* result = Flag::find_flag(name, len); Flag* result = Flag::find_flag(name, len);
if (result == NULL) return false; if (result == NULL) return false;
...@@ -784,7 +782,6 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Fl ...@@ -784,7 +782,6 @@ bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Fl
return true; return true;
} }
// Contract: Flag will make private copy of the incoming value.
void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { void CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) {
Flag* faddr = address_of_flag(flag); Flag* faddr = address_of_flag(flag);
guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type"); guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
......
...@@ -390,6 +390,8 @@ class CommandLineFlags { ...@@ -390,6 +390,8 @@ class CommandLineFlags {
static bool ccstrAt(char* name, size_t len, ccstr* value); static bool ccstrAt(char* name, size_t len, ccstr* value);
static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); } static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); }
// Contract: Flag will make private copy of the incoming value.
// Outgoing value is always malloc-ed, and caller MUST call free.
static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin); static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin);
static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); } static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
......
...@@ -201,6 +201,7 @@ class CommandLineFlagsEx : CommandLineFlags { ...@@ -201,6 +201,7 @@ class CommandLineFlagsEx : CommandLineFlags {
static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin); static void uintxAtPut(CommandLineFlagWithType flag, uintx value, Flag::Flags origin);
static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin); static void uint64_tAtPut(CommandLineFlagWithType flag, uint64_t value, Flag::Flags origin);
static void doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin); static void doubleAtPut(CommandLineFlagWithType flag, double value, Flag::Flags origin);
// Contract: Flag will make private copy of the incoming value
static void ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin); static void ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin);
static bool is_default(CommandLineFlag flag); static bool is_default(CommandLineFlag flag);
......
...@@ -1824,7 +1824,7 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value ...@@ -1824,7 +1824,7 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value
"This flag is not writeable."); "This flag is not writeable.");
} }
bool succeed; bool succeed = false;
if (flag->is_bool()) { if (flag->is_bool()) {
bool bvalue = (new_value.z == JNI_TRUE ? true : false); bool bvalue = (new_value.z == JNI_TRUE ? true : false);
succeed = CommandLineFlags::boolAtPut(name, &bvalue, Flag::MANAGEMENT); succeed = CommandLineFlags::boolAtPut(name, &bvalue, Flag::MANAGEMENT);
...@@ -1856,6 +1856,9 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value ...@@ -1856,6 +1856,9 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value
} }
ccstr svalue = java_lang_String::as_utf8_string(str); ccstr svalue = java_lang_String::as_utf8_string(str);
succeed = CommandLineFlags::ccstrAtPut(name, &svalue, Flag::MANAGEMENT); succeed = CommandLineFlags::ccstrAtPut(name, &svalue, Flag::MANAGEMENT);
if (succeed) {
FREE_C_HEAP_ARRAY(char, svalue, mtInternal);
}
} }
assert(succeed, "Setting flag should succeed"); assert(succeed, "Setting flag should succeed");
JVM_END JVM_END
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册