Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb17594

Browse files
committed
Add macro to disable address safety instrumentation
fasthash_accum_cstring_aligned() uses a technique, found in variousstrlen() implementations, to detect a string's NUL terminator byreading a word at at time. That triggers failures when testing with"-fsanitize=address", at least with frontend code. To enable usingthis function anywhere, add a function attribute macro to disablesuch testing.Reviewed by Jeff DavisDiscussion:https://postgr.es/m/CANWCAZbwvp7oUEkbw-xP4L0_S_WNKq-J-ucP4RCNDPJnrakUPw%40mail.gmail.com
1 parent4b968e2 commitdb17594

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

‎src/include/c.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@
135135
#definepg_nodiscard
136136
#endif
137137

138+
/*
139+
* This macro will disable address safety instrumentation for a function
140+
* when running with "-fsanitize=address". Think twice before using this!
141+
*/
142+
#if defined(__clang__)||__GNUC__ >=8
143+
#definepg_attribute_no_sanitize_address() __attribute__((no_sanitize("address")))
144+
#elif__has_attribute(no_sanitize_address)
145+
/* This would work for clang, but it's deprecated. */
146+
#definepg_attribute_no_sanitize_address() __attribute__((no_sanitize_address))
147+
#else
148+
#definepg_attribute_no_sanitize_address()
149+
#endif
150+
138151
/*
139152
* Place this macro before functions that should be allowed to make misaligned
140153
* accesses. Think twice before using it on non-x86-specific code!

‎src/include/common/hashfn_unstable.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,11 @@ fasthash_accum_cstring_unaligned(fasthash_state *hs, const char *str)
213213
*
214214
* With an aligned pointer, we consume the string a word at a time.
215215
* Loading the word containing the NUL terminator cannot segfault since
216-
* allocation boundaries are suitably aligned.
216+
* allocation boundaries are suitably aligned. To keep from setting
217+
* off alarms with address sanitizers, exclude this function from
218+
* such testing.
217219
*/
220+
pg_attribute_no_sanitize_address()
218221
staticinlinesize_t
219222
fasthash_accum_cstring_aligned(fasthash_state*hs,constchar*str)
220223
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp