CCS: Uninitialized variable when reading -Wl,--build-id if algorithm is not sha1

Issue #604 resolved
Colin MacLean created an issue

The GNU build id is read into a temporary buffer that is uninitialized. While this buffer is overwritten using the documented default of sha1, the buffer doesn’t become correctly zero-padded if a shorter build id algorithm is used. This results in the segment failing validation due to the presence of garbage values. Some compilers appear to override the default algorithm of sha1, which makes this bug more severe.

Comments (5)

  1. Paul Hargrove

    Below is a minimal reproducer using the in-repo hello_upcxx.cpp and a 32-bit build-id. The more likely case of -Wl,--build-id=md5 leads to a similar failure.

    [hargrove@login15.frontier ~]$ upcxx -network=udp -g -Wl,--build-id=0xcafef00d upcxx/test/hello_upcxx.cpp
    [hargrove@login15.frontier ~]$ upcxx-run -localhost -n2 ./a.out
    *** FATAL ERROR (proc 0):
    //////////////////////////////////////////////////////////////////////
    UPC++ fatal error:
     on process 0 (login15)
     at /tmp/BUILDROOT/upcxx-2023.3.0-frontier-gnu/bld/upcxx_install/upcxx-2023.3.0/src/./ccs.cpp:1128
     in function: static void upcxx::detail::segmap_cache::verify_all()
    
    Primary segment verification failed. If setting breakpoints, please see debugging.md.
    
    To have UPC++ freeze during these errors so you can attach a debugger,
    rerun the program with GASNET_FREEZE_ON_ERROR=1 in the environment.
    //////////////////////////////////////////////////////////////////////
    
    *** FATAL ERROR (proc 1):
    //////////////////////////////////////////////////////////////////////
    UPC++ fatal error:
     on process 1 (login15)
     at /tmp/BUILDROOT/upcxx-2023.3.0-frontier-gnu/bld/upcxx_install/upcxx-2023.3.0/src/./ccs.cpp:1128
     in function: static void upcxx::detail::segmap_cache::verify_all()
    
    Primary segment verification failed. If setting breakpoints, please see debugging.md.
    
    To have UPC++ freeze during these errors so you can attach a debugger,
    rerun the program with GASNET_FREEZE_ON_ERROR=1 in the environment.
    //////////////////////////////////////////////////////////////////////
    
    *** NOTICE (proc 1): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
    *** Caught a fatal signal (proc 1): SIGABRT(6)
    *** NOTICE (proc 0): Before reporting bugs, run with GASNET_BACKTRACE=1 in the environment to generate a backtrace.
    *** Caught a fatal signal (proc 0): SIGABRT(6)
    
  2. Colin MacLean reporter

    The workaround if build-id is needed and the compiler overrides the ld default is to explicitly use -Wl,--build-id=sha1.

  3. Log in to comment