[llvm-bugs] [Bug 52218] New: Binary signature collision for different modules when collecting instrumentation profile

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 19 07:30:22 PDT 2021


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

            Bug ID: 52218
           Summary: Binary signature collision for different modules when
                    collecting instrumentation profile
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: profile
          Assignee: unassignedbugs at nondot.org
          Reporter: vlad at ispras.ru
                CC: llvm-bugs at lists.llvm.org

Below is a minimal example crafted based on a usage of trying to get coverage
data for postgresql.

$ cat src1.c
int main(void) { return 0; }
void www1(void) { }

$ cat src2.c
int main(void) { return 0; }
void www2(int *a) { *a+=10; }


dir=/tmp/profile-test

clang -O0 -g -fprofile-instr-generate -fcoverage-mapping src1.c -o src1
clang -O0 -g -fprofile-instr-generate -fcoverage-mapping src2.c -o src2

export LLVM_PROFILE_FILE="$dir/code-%m.profraw"
./src1
./src2


LLVM Profile Warning: Unable to merge profile data: source profile file is not
compatible.
LLVM Profile Error: Profile Merging of file
/tmp/profile-test/code-15822683945683506682_0.profraw failed: File exists
LLVM Profile Error: Failed to write file
"/tmp/profile-test/code-15822683945683506682_0.profraw": File exists


What happens here is the hash [1] turns out too weak. The two modules end up
having the same hash and therefore the corresponding binaries have the same
signature. This leads to the profiling library trying to merge the profile from
the second program into the one obtained from running the first one.  

This is using a recent commit 1c1406f24d8b1c8ebec76c516ea969072d24cc75 (post
llvmorg-13-init tag). Also got the same result with clang 12.0.1.

The original problem was a bit more involved: utf8_and_euc_kr.so and
utf8_and_euc_tw.so libraries get loaded from the main binary. They have the
following lists of functions defined in them.

Pg_magic_func
pg_finfo_euc_kr_to_utf8
pg_finfo_utf8_to_euc_kr
euc_kr_to_utf8
utf8_to_euc_kr

Pg_magic_func
pg_finfo_euc_tw_to_utf8
pg_finfo_utf8_to_euc_tw
euc_tw_to_utf8
utf8_to_euc_tw


[1]:
https://github.com/llvm/llvm-project/blob/1c1406f24d8b1c8ebec76c516ea969072d24cc75/compiler-rt/lib/profile/InstrProfilingMerge.c#L23-L37

-- 
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/20211019/d0b1fe0a/attachment.html>


More information about the llvm-bugs mailing list