Skip to content

Commit 61b3e5e

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 f2f04ce commit 61b3e5e

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
@@ -2253,6 +2253,13 @@ _Ci_PyGC_GetImpl(GCState *gc_state)
22532253

22542254
static void
22552255
_Ci_PyGCImpl_Fini(GCState *gc_state)
2256+
#if defined(__has_feature)
2257+
# if __has_feature(undefined_behavior_sanitizer)
2258+
// Silence the UBSan warning about calling PyMem_RawFree through an
2259+
// incorrect pointer type.
2260+
__attribute__((no_sanitize("function")))
2261+
# endif
2262+
#endif
22562263
{
22572264
_Ci_PyGCImplListNode *node = Ci_find_gc_impl_node(gc_state);
22582265
assert(node != NULL);

0 commit comments

Comments
 (0)