-
Notifications
You must be signed in to change notification settings - Fork 0
Runtime Library
Hugo edited this page Feb 26, 2026
·
1 revision
Instrumented binaries link ct_instrument_runtime (built from src/runtime/).
This library implements all __ct_* hooks inserted by LLVM passes.
| File | Role |
|---|---|
ct_runtime_alloc.cpp |
allocation tracking, table management, auto-free scan |
ct_runtime_bounds.cpp |
bounds violation checks and reporting |
ct_runtime_trace.cpp |
function entry/exit tracing hooks |
ct_runtime_vtable.cpp |
virtual call and vtable diagnostics |
ct_runtime_shadow.cpp |
shadow metadata tracking |
ct_runtime_state.cpp |
feature bitset + legacy globals |
ct_runtime_env.cpp |
compile-time config globals + env overrides |
ct_runtime_logging.cpp |
logger adapters/helpers |
ct_runtime_backtrace.cpp |
optional backtrace setup |
void* __ct_malloc(size_t, const char*)void* __ct_calloc(size_t, size_t, const char*)void* __ct_realloc(void*, size_t, const char*)void __ct_free(void*)void* __ct_new(size_t, const char*)void __ct_delete(void*)void* __ct_mmap(..., const char*)int __ct_munmap(void*, size_t, const char*)void* __ct_sbrk(size_t, const char*)void* __ct_brk(void*, const char*)
void __ct_check_bounds(const void* base, const void* ptr, size_t access_size, const char* site, int is_write)
void __ct_trace_enter(const char* func)void __ct_trace_exit_void(const char* func)void __ct_trace_exit_i64(const char* func, long long value)void __ct_trace_exit_ptr(const char* func, const void* value)void __ct_trace_exit_f64(const char* func, double value)void __ct_trace_exit_unknown(const char* func)
void __ct_vtable_dump(void* this_ptr, const char* site, const char* static_type)void __ct_vcall_trace(void* this_ptr, void* target, const char* site, const char* static_type)
Feature state is stored in a bitset API (ct_is_enabled, ct_set_enabled, ct_get_features).
Default enabled bits include trace, alloc, bounds, autofree, and alloc-trace.
At startup, compile-time globals injected by the compiler can disable/enable features:
__ct_config_shadow__ct_config_shadow_aggressive__ct_config_bounds_no_abort__ct_config_disable_alloc__ct_config_disable_autofree__ct_config_disable_alloc_trace__ct_config_vtable_diag
Then env vars can override behavior (see below).
ct_runtime_env.cpp reads:
CT_DISABLE_TRACECT_DISABLE_ALLOCCT_EARLY_TRACECT_DISABLE_BOUNDSCT_BOUNDS_NO_ABORTCT_SHADOWCT_SHADOW_AGGRESSIVECT_DISABLE_AUTOFREECT_DISABLE_ALLOC_TRACE
Auto-free scan env vars are documented in Auto-Free GC.
- Allocation/shadow tables use lock-protected open addressing.
- VTable diagnostics rely on platform symbol/module resolution (
dladdr, dyld, phdr fallback). - Most diagnostics are emitted through
coretrace-loggeradapters.
Start
Architecture
Instrumentation
Developer