-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
build.yml: added sanitized build with UndefinedBehaviorSanitizer #3659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
|
This could be combined with the existing ASAN build. |
|
Example of one of the |
|
|
The specific warning you point out above relates to the use of the #if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint32_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 4); \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 16); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 24); \
(s)->p++; \
} while (0)
#else
#define out_uint32_le(s, v) do \
{ \
S_CHECK_REM_OUT((s), 4); \
*((unsigned int*)((s)->p)) = (v); \
(s)->p += 4; \
} while (0)
#endifOn x86_64, The macro is used fairly extensively:- There are two qualifications to this approach:
#include <stdint.h>
#include <stdio.h>
int main()
{
const uint32_t val = 0x58524450;
char *p;
union
{
unsigned char buff[100];
unsigned int i;
} target;
// Write a 32-bit word with MOV
*(uint32_t*)&target.buff[1] = val;
// Write a 32-bit word as bytes
p = &target.buff[5];
*p++ = (unsigned char)(val >> 0);
*p++ = (unsigned char)(val >> 8);
*p++ = (unsigned char)(val >> 16);
*p++ = (unsigned char)(val >> 24);
int i;
for (i = 1 ; i < 9 ; ++i)
{
printf("[%d] = %02x\n", i, target.buff[i]);
}
}I built it with gcc 14.2.0 using Although I've specified two separate code segments to write the target word as an unaligned access and separately as bytes, the compiler has emitted a single unaligned mov instruction for all 8 bytes! What are your thoughts on this? We may need some wider discussions. |
I have no thoughts on that. I rarely (never?) had to deal with alignment stuff so it goes way over my head. It should probably done outside of this PR and the current state should be merged. Thanks for the great analysis. I will give it a proper read later and possibly learn something from it. Also as mentioned it might be worth looking at the |
No description provided.