Add fork+exec support, update Indexing.md, and handle "-mrelocation-model pic" flag#578
Merged
kumarak merged 1 commit intotrailofbits:mainfrom Oct 6, 2025
Merged
Add fork+exec support, update Indexing.md, and handle "-mrelocation-model pic" flag#578kumarak merged 1 commit intotrailofbits:mainfrom
kumarak merged 1 commit intotrailofbits:mainfrom
Conversation
Contributor
Author
|
Test1: //cat sample2.c
#include <stdio.h>
// 1. Function to add two numbers
int add(int a, int b) {
return a + b;
}
// 2. Function to find the maximum of two numbers
int max(int a, int b) {
return (a > b) ? a : b;
}
// 3. Function to check if a number is even
int is_even(int n) {
return (n % 2 == 0);
}
// 4. Function to print a message
void print_hello() {
printf("Hello, World!\n");
}
// 5. Function to calculate factorial (non-recursive)
int factorial(int n) {
int result = 1;
for (int i = 2; i <= n; i++)
result *= i;
return result;
}
// Example usage
int main() {
printf("Add: %d\n", add(5, 3));
printf("Max: %d\n", max(10, 20));
printf("Is 4 even? %d\n", is_even(4));
print_hello();
printf("Factorial of 5: %d\n", factorial(5));
return 0;
}reproc fails inside docker: (install) root@b5158c58ce21:~/install# mx-index --target compile_commands.json --db sample2.db --reproc_mode
E20250510 02:38:48.142114 6108 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /usr/bin/clang -c -g -O0 -o sample2 sample2.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:38:48.148221 6104 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /usr/lib/llvm-20/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir sample2- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/root/install -fcoverage-compilation-dir=/root/install -resource-dir /usr/lib/llvm-20/lib/clang/20 -internal-isystem /usr/lib/llvm-20/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c -o /tmp/sample2-0daee7.o sample2.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
(install) root@b5158c58ce21:~/install# ls -alSh sample2.db
-rw-r--r--. 1 root root 3.3M May 10 02:38 sample2.dbfork+exec works (install) root@b5158c58ce21:~/install# mx-index --target compile_commands.json --db sample2.db --fork_mode
(install) root@b5158c58ce21:~/install# ls -alSh sample2.db
-rw-r--r--. 1 root root 3.4M May 10 02:38 sample2.db
(install) root@b5158c58ce21:~/install# mx-list-functions --db sample2.db
1152921504606847044 2305843009214745037 9281918834641469440 add def
1152921504606847044 2305843009214745038 9281918834642518016 max def
1152921504606847044 2305843009214745039 9281918834643566592 is_even def
1152921504606847044 2305843009214745040 9281918834644615168 print_hello def
1152921504606847044 2305843009214745041 9281918834645663744 factorial def
1152921504606847044 2305843009214745042 9281918834646712320 main defTest2: Real world application
Failure logs inside docker: E20250510 02:30:01.870612 5690 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -D_FILE_OFFSET_BITS=64 -o CMakeFiles/example64.dir/test/example.c.o -c /root/OGHarn/demos/zlib/lib/test/example.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.875167 5691 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -D_FILE_OFFSET_BITS=64 -o CMakeFiles/minigzip64.dir/test/minigzip.c.o -c /root/OGHarn/demos/zlib/lib/test/minigzip.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.883198 5709 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/zutil.c.o -c /root/OGHarn/demos/zlib/lib/zutil.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.891896 5704 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/minigzip.dir/test/minigzip.c.o -c /root/OGHarn/demos/zlib/lib/test/minigzip.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.899298 5706 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/example.dir/test/example.c.o -c /root/OGHarn/demos/zlib/lib/test/example.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.907377 5708 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/zutil.c.o -c /root/OGHarn/demos/zlib/lib/zutil.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.915544 5692 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/uncompr.c.o -c /root/OGHarn/demos/zlib/lib/uncompr.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.924079 5693 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/inflate.c.o -c /root/OGHarn/demos/zlib/lib/inflate.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.931890 5703 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/crc32.c.o -c /root/OGHarn/demos/zlib/lib/crc32.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.939175 5697 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/deflate.c.o -c /root/OGHarn/demos/zlib/lib/deflate.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.953272 5700 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/inftrees.c.o -c /root/OGHarn/demos/zlib/lib/inftrees.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.953497 5705 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/compress.c.o -c /root/OGHarn/demos/zlib/lib/compress.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.969448 5695 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/gzread.c.o -c /root/OGHarn/demos/zlib/lib/gzread.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.969564 5696 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/gzlib.c.o -c /root/OGHarn/demos/zlib/lib/gzlib.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.977866 5702 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/infback.c.o -c /root/OGHarn/demos/zlib/lib/infback.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.987006 5698 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/gzwrite.c.o -c /root/OGHarn/demos/zlib/lib/gzwrite.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:01.996883 5694 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/trees.c.o -c /root/OGHarn/demos/zlib/lib/trees.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.005138 5701 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/gzclose.c.o -c /root/OGHarn/demos/zlib/lib/gzclose.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.013847 5690 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/uncompr.c.o -c /root/OGHarn/demos/zlib/lib/uncompr.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.022713 5699 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/inffast.c.o -c /root/OGHarn/demos/zlib/lib/inffast.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.030362 5697 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/gzclose.c.o -c /root/OGHarn/demos/zlib/lib/gzclose.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.039072 5705 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/crc32.c.o -c /root/OGHarn/demos/zlib/lib/crc32.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.046243 5691 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/trees.c.o -c /root/OGHarn/demos/zlib/lib/trees.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.054956 5709 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/inffast.c.o -c /root/OGHarn/demos/zlib/lib/inffast.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.063756 5692 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/gzwrite.c.o -c /root/OGHarn/demos/zlib/lib/gzwrite.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.071182 5703 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/gzlib.c.o -c /root/OGHarn/demos/zlib/lib/gzlib.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.082054 5707 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -o CMakeFiles/zlibstatic.dir/adler32.c.o -c /root/OGHarn/demos/zlib/lib/adler32.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.090376 5708 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/inflate.c.o -c /root/OGHarn/demos/zlib/lib/inflate.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.100734 5700 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/deflate.c.o -c /root/OGHarn/demos/zlib/lib/deflate.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.109674 5693 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/gzread.c.o -c /root/OGHarn/demos/zlib/lib/gzread.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.118412 5704 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/inftrees.c.o -c /root/OGHarn/demos/zlib/lib/inftrees.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.127548 5695 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/compress.c.o -c /root/OGHarn/demos/zlib/lib/compress.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.138734 5706 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/infback.c.o -c /root/OGHarn/demos/zlib/lib/infback.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
E20250510 02:30:02.148285 5696 Importer.cpp:693] Error invoking original compiler to find version information: Invalid argument; original command was: /root/AFLplusplus/afl-clang-fast -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/root/OGHarn/demos/zlib/lib -fPIC -o CMakeFiles/zlib.dir/adler32.c.o -c /root/OGHarn/demos/zlib/lib/adler32.c. Perhaps try --env /path/to/file to specify a file containing environment variables, to help me find the compiler executable
|
Contributor
|
LGTM! |
Contributor
|
Ping @kumarak. I no longer have reviewer privileges here 😭. |
Contributor
Author
kumarak
approved these changes
Oct 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for the
--fork_modeflag inmx-index, which provides a fallback mechanism when--reproc_modefails, particularly useful in Docker environments. This change addresses and resolves issue #577.Usage
mx-index --target compile_commands.jsonIndexing can now be run with either of the following modes:
reproc:mx-index --target compile_commands.json --reproc_mode --db sample.dbfork+execas a fallback:mx-index --target compile_commands.json --fork_mode --db sample.dbAdditional Fix
While generating
compile_commands.jsonwithclang, the flag-mrelocation-model picalso included and cause error. This error occurs because thepicpart is mistakenly treated as a filename, resulting in errors like:Unable to find file picAn internal workaround has been added to handle this, although using
gccto generate the file avoids this issue entirely.