🐛 try fixing segfault in module_test.nas

This commit is contained in:
ValKmjolnir
2023-12-06 21:02:56 +08:00
parent 65dbe51c05
commit 2a36db1cf5
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -47,6 +47,9 @@ struct ghost_obj {
var test_string = nil;
};
// if the dynamic library is closed, the pointer of this function will be unsafe
// make sure gc deletes the object before closing the dynamic library
// or just do not close the dynamic library...
void ghost_for_test_destructor(void* ptr) {
std::cout << "ghost_for_test::destructor (0x";
std::cout << std::hex << reinterpret_cast<u64>(ptr) << std::dec << ") {\n";
@@ -69,7 +72,7 @@ var create_new_ghost(var* args, usize size, gc* ngc) {
var res = ngc->alloc(vm_type::vm_ghost);
res.ghost().set(
ghost_for_test,
nullptr,
ghost_for_test_destructor,
ghost_for_test_gc_marker,
new ghost_obj
);