Description
I embeb upy(HEAD: e0c6dfe) into my windows(vs2017 with Windows SDK10.0.17763.0 on windows10) application.
bool __pyDoString(const char* String) {
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
qstr src_name = 1/*MP_QSTR_*/;
mp_lexer_t *lex = mp_lexer_new_from_str_len(src_name, String, strlen(String), false);
mp_parse_tree_t pt = mp_parse(lex, MP_PARSE_FILE_INPUT);
mp_obj_t module_fun = mp_compile(&pt, src_name, MP_EMIT_OPT_NONE, false);
mp_call_function_0(module_fun);
nlr_pop();
return true;
}
else {// uncaught exception
return false;
}
return false;
}
When I invoke __pyDoString in the main loop(i.e. invoked hundreds of times per second) the assert in gc_free(...) or gc_realloc(...) below often fails(some frames will fail). ATB_GET_KIND(block) is AT_FREE.
assert(ATB_GET_KIND(block) == AT_HEAD);
When I modify some macro configs in ports/windows/mpconfigport.h, the assert in gc_realloc(...) does not failed but gc_free(...) will be still. But I don't know which switcher influent it(sorry, I am not familiar with them. I just copy some macros from ports/minimal/mpconfigport.h).
When I set MICROPY_ENABLE_GC to 0, my application could work, but its process memory keep growing. memory leak when no GC?
I bind imgui be python interfaces with upy. __pyDoString(there is a example below) is used to invoke serveral imgui's window and button interfaces.
__pyDoString("import imgui\nimgui.Begin('python imgui')\nimgui.Text('python text')\nimgui.End()");
After I commented these two asserts, an assert fails in imgui. The assert failing signifies "Mismatched Begin()/End() calls.". But as you see, the py code string in __pyDoString has matched Begin()/End(). Is the code string broken in upy VM?
And if I just run __pyDoString("print('simple words')"), the 2 asserts will often both fail too.
The interesting thing is that emscripten version of my application seems to be working well with MICROPY_ENABLE_GC (1) and the 2 asserts commented(change to print the error. the errors of gc_free and gc_realloc will often both be printed.). It is strange that the assert in imgui doesnot failed like windows version. But I think there are some potential problems still. The mpconfigport.h of emscripten is based on minimal's.