[llvm-bugs] [Bug 48694] New: llvm-prof merge produces invalid output when compiled as 32 bit

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 7 19:58:45 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48694

            Bug ID: 48694
           Summary: llvm-prof merge produces invalid output when compiled
                    as 32 bit
           Product: libraries
           Version: 11.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: cfsteefel at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24364
  --> https://bugs.llvm.org/attachment.cgi?id=24364&action=edit
The hexdump -d output of the malformed merged profile data

While attempting to test fuzzing, it was discovered that llvm-profdata was
producing bad output, which was unreadable by llvm-cov.

The following is a minimal example:
fuzz.c:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int test_func( const uint8_t * data, size_t size ) {

    uint8_t ret = 0;
    // Do some arbitrary operations
    if (size > 100 && size < 200) {
        uint8_t d = data[ size ];
        uint8_t e = d*256/13;
        ret = d | e;
    } else {
        ret = size;
    }
    return ret;
}

int LLVMFuzzerInitialize() {
   return 0;
}

int LLVMFuzzerTestOneInput( const uint8_t * data, size_t size ) {
   if ( size < 1 )
      return 0;

   test_func( data, size );

   return 0;
}

Then, compiled with:
clang -fprofile-instr-generate -fcoverage-mapping -fsanitize=fuzzer fuzz.c
Then, run as ./a.out -runs=100
Then, running llvm-profdata merge -sparse default.profraw -o default.profdata
&& llvm-cov show a.out -instr-profile=default.profdata presents the failure
"Failed to load coverage: Malformed coverage data".

The bug was not reproducible when using a 64 bit clang to compile the above
program in 32 bit with `-m32` and running 64 bit llvm-profdata and llvm-cov on
a stock fedora docker container.

The output contained in the default.profdata file appears to be different from
that of a 64 bit version, such that the value of the HashOffset in the header
is different (740 instead of 744), and the file appears to be 4 bytes shorter
in total. (the hexdump of the output is attached.

The versions of clang, llvm-prof, and llvm-cov are all version 11, and compiled
fully in 32 bit mode in the failing case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210108/7795bddd/attachment.html>


More information about the llvm-bugs mailing list