This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new 4206f16 [CORE] Use new for singleton to prevent de-alloc order issues
(#133)
4206f16 is described below
commit 4206f16e539e60d0955423aa042f3c64d8489da4
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed Oct 15 14:08:50 2025 -0400
[CORE] Use new for singleton to prevent de-alloc order issues (#133)
This PR updates the logic to use new for singleton to prevent potential
de-alloc order issues during program shutdown
---
src/ffi/object.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ffi/object.cc b/src/ffi/object.cc
index b58231a..df668d2 100644
--- a/src/ffi/object.cc
+++ b/src/ffi/object.cc
@@ -306,8 +306,12 @@ class TypeTable {
}
static TypeTable* Global() {
- static TypeTable inst;
- return &inst;
+ // deliberately create a new instance via raw new
+ // to ensure table lives longer in case unloading
+ // still need the table info
+ // memory will be recycled by the OS at program exit
+ static TypeTable* inst = new TypeTable();
+ return inst;
}
private: