PengZheng commented on code in PR #799:
URL: https://github.com/apache/celix/pull/799#discussion_r2618500374


##########
.github/workflows/fuzzing.yml:
##########
@@ -0,0 +1,59 @@
+name: Celix Fuzzing
+
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '0 3 * * *'
+
+jobs:
+  fuzz-utils:
+    runs-on: ubuntu-22.04
+    timeout-minutes: 30
+    steps:
+      - name: Checkout source code
+        uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0
+      - name: Set up Python
+        uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c 
#v4.9.1
+        with:
+          python-version: '3.x'
+      - name: Set Compiler Environment Variables
+        run: |
+          echo "CC=clang" >> $GITHUB_ENV
+          echo "CXX=clang++" >> $GITHUB_ENV
+      - name: Install Conan
+        run: pip install conan
+      - name: Cache Conan
+        uses: actions/cache@v3
+        with:
+          path: ~/.conan2/p
+          key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.py', 
'libs/utils/**') }}
+          restore-keys: |
+            ${{ runner.os }}-conan-
+      - name: Setup Conan Profile
+        run: |
+          conan profile detect 
+      - name: Conan install
+        run: conan install . --output-folder=build --build=missing -o 
"celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True"
+      - name: Conan build
+        run: conan build . --output-folder=build -o "celix/*:build_utils=True" 
-o "celix/*:enable_fuzzing=True" -o "celix/*:celix_err_buffer_size=5120"

Review Comment:
   With ASAN enabled for the clang toolchain, `test_utils` works as expected 
without `LD_PRELOAD`. 
   
   ```
   (env3) 
peng@hackerlife2:~/Downloads/git/celix_review/cmake-build-clang/libs/utils/gtest$
 readelf -d test_utils
   
   Dynamic section at offset 0x489c80 contains 38 entries:
     Tag        Type                         Name/Value
    0x0000000000000001 (NEEDED)             Shared library: 
[libclang_rt.asan-x86_64.so]
    0x0000000000000001 (NEEDED)             Shared library: [libgtest_main.so]
    0x0000000000000001 (NEEDED)             Shared library: [libzip.so.5]
    0x0000000000000001 (NEEDED)             Shared library: [libjansson.so.4]
    0x0000000000000001 (NEEDED)             Shared library: 
[libcelix_utils.so.3]
    0x0000000000000001 (NEEDED)             Shared library: [libgtest.so]
    0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
    0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
    0x000000000000001d (RUNPATH)            Library runpath: 
[/usr/lib/llvm-18/lib/clang/18/lib/linux:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib:/home/peng/.conan2/p/b/gtest070ee13ce63c1/p/lib:/home/peng/Downloads/git/celix_review/cmake-build-clang/libs/utils]
   ```
   
   `libclang_rt.asan-x86_64.so` comes as the first NEEDED entry. However for 
`celix_filter_fuzzer`, `libstdc++.so.6` comes before 
`libclang_rt.asan-x86_64.so`:
   
   ```
    readelf -d celix_filter_fuzzer 
   
   Dynamic section at offset 0xcac00 contains 35 entries:
     Tag        Type                         Name/Value
    0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
    0x0000000000000001 (NEEDED)             Shared library: 
[libclang_rt.asan-x86_64.so]
    0x0000000000000001 (NEEDED)             Shared library: [libzip.so.5]
    0x0000000000000001 (NEEDED)             Shared library: [libjansson.so.4]
    0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
    0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
    0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
    0x000000000000001d (RUNPATH)            Library runpath: 
[/usr/lib/llvm-18/lib/clang/18/lib/linux:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib]
   ```
   
   Double-check with `LD_DEBUG=libs`:
   
   ```
   LD_DEBUG=libs ./celix_filter_fuzzer 
        50646:     find library=libstdc++.so.6 [0]; searching
        50646:      search 
path=/usr/lib/llvm-18/lib/clang/18/lib/linux/glibc-hwcaps/x86-64-v4:/usr/lib/llvm-18/lib/clang/18/lib/linux/glibc-hwcaps/x86-64-v3:/usr/lib/llvm-18/lib/clang/18/lib/linux/glibc-hwcaps/x86-64-v2:/usr/lib/llvm-18/lib/clang/18/lib/linux:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib/glibc-hwcaps/x86-64-v4:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib/glibc-hwcaps/x86-64-v3:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib/glibc-hwcaps/x86-64-v2:/home/peng/.conan2/p/b/libzic7db358af7f13/p/lib:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib/glibc-hwcaps/x86-64-v4:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib/glibc-hwcaps/x86-64-v3:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib/glibc-hwcaps/x86-64-v2:/home/peng/.conan2/p/b/janssdd7698f9ed975/p/lib
               (RUNPATH from file ./celix_filter_fuzzer)
   
   ...
   ==50646==ASan runtime does not come first in initial library list; you 
should either link runtime to your application or manually preload it with 
LD_PRELOAD.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to