Skip to content
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

Build errors with GCC + ASAN/UBSAN #3813

Open
ravyu-jump opened this issue Dec 30, 2024 · 1 comment
Open

Build errors with GCC + ASAN/UBSAN #3813

ravyu-jump opened this issue Dec 30, 2024 · 1 comment

Comments

@ravyu-jump
Copy link
Contributor

Building with GCC + ASAN / UBSAN appears to treat certain checks as errors.

With ASAN, we have -Werror=stringop-truncation errors like so:

src/app/fdctl/config.c: In function 'fdctl_cfg_from_env':
src/app/fdctl/config.c:473:5: error: '__builtin_strncpy' output may be truncated copying 15 bytes from a string of length 255 [-Werror=stringop-truncation]
  473 |     strncpy( config->tiles.net.interface,
      |     ^
src/app/fdctl/config.c:490:3: error: '__builtin_strncpy' output may be truncated copying 39 bytes from a string of length 64 [-Werror=stringop-truncation]
  490 |   strncpy( config->hostname, utsname.nodename, sizeof(config->hostname) );
      |   ^
cc1: all warnings being treated as errors
make: *** [config/everything.mk:308: build/test-vectors/obj/app/fdctl/config.o] Error 1

UBSAN sees sign-conversion and stringop-overflow checks triggered like so:

src/ballet/base58/../../util/spad/../bits/fd_bits.h:681:50: error: writing 4 bytes into a region of size 0 [-Werror=stringop-overflow=]
  681 |   (__extension__({ T _fd_store_tmp = (val); (T *)memcpy( (T *)(dst), &_fd_store_tmp, sizeof(T) ); }))
      |                                                  ^~~~~~
src/ballet/base58/fd_base58_tmpl.c:380:5: note: in expansion of macro 'FD_STORE'
  380 |     FD_STORE( uint, &out_as_uint[ i ], fd_uint_bswap( (uint)binary[ i ] ) );
      |     ^~~~~~~~
src/ballet/pack/fd_pack.c: In function 'fd_pack_clear_all':
src/ballet/pack/fd_pack.c:817:21: error: conversion to 'ulong' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
  817 |       ulong __idx = (idx);                                                                     \
      |                     ^
src/ballet/pack/fd_pack.c:1783:38: note: in expansion of macro 'ACCT_IDX_TO_PTR'
 1783 |       fd_acct_addr_t penalty_acct = *ACCT_IDX_TO_PTR( FD_ORD_TXN_ROOT_PENALTY_ACCT_IDX( del->root ) );
      |                                      ^~~~~~~~~~~~~~~
src/ballet/pack/fd_pack.c: In function 'fd_pack_delete_transaction':
src/ballet/pack/fd_pack.c:817:21: error: conversion to 'ulong' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Werror=sign-conversion]
  817 |       ulong __idx = (idx);                                                                     \
      |                     ^
src/ballet/pack/fd_pack.c:1834:38: note: in expansion of macro 'ACCT_IDX_TO_PTR'
 1834 |       fd_acct_addr_t penalty_acct = *ACCT_IDX_TO_PTR( FD_ORD_TXN_ROOT_PENALTY_ACCT_IDX( root_idx ) );

@ravyu-jump ravyu-jump changed the title build errors with GCC + ASAN/UBSAN Build errors with GCC + ASAN/UBSAN Dec 30, 2024
@ripatel-fd
Copy link
Contributor

I looked at a couple of them and they seem to be compiler bugs.

It seems like GCC warnings change unpredictably with every major release and certain compile flags.
stringop-overflow, stringop-truncation, and maybe-uninitialized produce frequent false positives.

Maybe we should move these unreliable checks to with-extra-brutality.mk so they are not enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants