Skip to content

Commit 25e5c02

Browse files
Yhg1smeta-codesync[bot]
authored andcommitted
Silence UBSan warnings on Cinder's GC hooks
Summary: UBSan is picky about calling functions through technically-incompatible pointers, since this is technically undefined behaviour. It's not a useful warning in this case (we're calling it with a different pointer type, but PyMem_RawFree takes a void* anyway) and we don't want to pay the cost of an extra indirection just to avoid this technically-undefined behaviour, so just silence it. Reviewed By: alexmalyshev Differential Revision: D114423869 fbshipit-source-id: 8a664022830b89c38c932ab8f946b54bf671d8ad
1 parent 9419167 commit 25e5c02

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Python/gc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,13 @@ _Ci_PyGC_GetImpl(GCState *gc_state)
21352135

21362136
static void
21372137
_Ci_PyGCImpl_Fini(GCState *gc_state)
2138+
#if defined(__has_feature)
2139+
# if __has_feature(undefined_behavior_sanitizer)
2140+
// Silence the UBSan warning about calling PyMem_RawFree through an
2141+
// incorrect pointer type.
2142+
__attribute__((no_sanitize("function")))
2143+
# endif
2144+
#endif
21382145
{
21392146
_Ci_PyGCImplListNode *node = Ci_find_gc_impl_node(gc_state);
21402147
assert(node != NULL);

0 commit comments

Comments
 (0)