Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 93c356f

Browse files
committed
mg: use no_sanitize_address for magic_get strEQc checks
we prefer the speed advantage of strEQc (wordwise memcmp), and the strings (mg_ptr) can never cross a page boundary, so we are safe. mg is allocated by Newxz(), i.e. an arena
1 parent da27909 commit 93c356f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mg.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ Perl__get_encoding(pTHX)
830830
#include <starlet.h>
831831
#endif
832832

833+
/* the strEQc checks below are not asan safe. ignore it.
834+
we don't cross pages. */
835+
#if defined(USE_SANITIZE_ADDRESS)
836+
# if defined(__clang__) && defined(__has_feature) && __has_feature(address_sanitizer)
837+
__attribute__((no_address_safety_analysis))
838+
# elif defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 409
839+
__attribute__((no_sanitize_address))
840+
# endif
841+
#endif
833842
int
834843
Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
835844
{

0 commit comments

Comments
 (0)