mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix leak when load kw dict to default
This commit is contained in:
parent
0f51072065
commit
853d5be3b5
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
"--gtest_filter=requests.post_data"
|
||||
"--gtest_filter=vm.issue_keyword_mem_leak"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -1,9 +1,9 @@
|
||||
sh only_make.sh
|
||||
if [ $# == 0 ] ; then
|
||||
valgrind -s --track-origins=yes --leak-check=full --show-leak-kinds=all --exit-on-first-error=yes --error-exitcode=1 build/test/pikascript_test
|
||||
valgrind -s --track-origins=yes --leak-check=full --show-leak-kinds=all --exit-on-first-error=yes --error-exitcode=1 build/test/pikascript_test --num-callers=50
|
||||
fi
|
||||
|
||||
if [ $# == 1 ] ; then
|
||||
filter=$1
|
||||
valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all build/test/pikascript_test --gtest_filter=$filter
|
||||
valgrind -s --track-origins=yes --leak-check=full --show-leak-kinds=all build/test/pikascript_test --gtest_filter=$filter --num-callers=50
|
||||
fi
|
||||
|
@ -861,7 +861,11 @@ static char* _kw_to_default_all(FunctionArgsInfo* f,
|
||||
if (f->kw != NULL) {
|
||||
Arg* default_arg = pikaDict_getArg(f->kw, arg_name);
|
||||
if (default_arg != NULL) {
|
||||
argv[(*argc)++] = arg_copy(default_arg);
|
||||
Arg* arg_new = arg_copy(default_arg);
|
||||
if (argType_isObject(arg_getType(arg_new))) {
|
||||
obj_refcntDec(arg_getPtr(arg_new));
|
||||
}
|
||||
argv[(*argc)++] = arg_new;
|
||||
}
|
||||
}
|
||||
arg_name = strPopLastToken(f->type_list, ',');
|
||||
|
@ -2393,6 +2393,19 @@ TEST(vm, fn_star_star) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(vm, issue_keyword_mem_leak) {
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
pikaVM_runSingleFile(pikaMain,
|
||||
"test/python/issue/issue_keyword_mem_leak.py");
|
||||
PikaObj* header = (PikaObj*)obj_getPtr(pikaMain, "header");
|
||||
/* assert */
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_END
|
7
test/python/issue/issue_keyword_mem_leak.py
Normal file
7
test/python/issue/issue_keyword_mem_leak.py
Normal file
@ -0,0 +1,7 @@
|
||||
def test(headers=None):
|
||||
print("in test")
|
||||
|
||||
|
||||
header = {"a": "test"}
|
||||
|
||||
test(headers=header)
|
Loading…
x
Reference in New Issue
Block a user