Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GetRunfilesDir() to be able to reliably determine prelude location under various invocation scenarios #1207

Merged
merged 19 commits into from
May 2, 2022

Conversation

pk19604014
Copy link
Contributor

@pk19604014 pk19604014 commented Apr 22, 2022

One of the scenarios used by the fuzzing framework is to place the binary and its runfiles into a folder, resulting in a directory layout like this:

[temp dir]
fuzzer
fuzzer.runfiles/

Tested:

bazel test -c opt executable_semantics/fuzzing:executable_semantics_fuzzer
bazel build -c opt executable_semantics/fuzzing:executable_semantics_fuzzer + run the binary from various locations

@pk19604014 pk19604014 requested a review from a team as a code owner April 22, 2022 16:03
@pk19604014 pk19604014 changed the title Fuzzer runfiles Added runfiles_util to be able to determine prelude location under various invocation scenarios (DRAFT PR) Apr 22, 2022
@pk19604014 pk19604014 marked this pull request as draft April 22, 2022 16:05
@pk19604014 pk19604014 changed the title Added runfiles_util to be able to determine prelude location under various invocation scenarios (DRAFT PR) Added runfiles_util to be able to determine prelude location under various invocation scenarios Apr 22, 2022
@pk19604014 pk19604014 changed the title Added runfiles_util to be able to determine prelude location under various invocation scenarios Added runfiles_util to be able to reliably determine prelude location under various invocation scenarios Apr 22, 2022
@pk19604014 pk19604014 marked this pull request as ready for review April 22, 2022 17:51
@pk19604014 pk19604014 requested a review from jonmeow April 22, 2022 17:52
common/runfiles_util.cpp Outdated Show resolved Hide resolved
common/BUILD Outdated Show resolved Hide resolved
@pk19604014 pk19604014 changed the title Added runfiles_util to be able to reliably determine prelude location under various invocation scenarios Added GetRunfilesDir() to be able to reliably determine prelude location under various invocation scenarios Apr 22, 2022
@pk19604014 pk19604014 requested a review from jonmeow April 22, 2022 19:24
@jonmeow
Copy link
Contributor

jonmeow commented Apr 22, 2022

Now that I've had some time to check this: can you please provide a repro to show what this change is fixing? That should help me review this.

@pk19604014
Copy link
Contributor Author

Now that I've had some time to check this: can you please provide a repro to show what this change is fixing? That should help me review this.

$ bazel build -c opt executable_semantics/fuzzing:executable_semantics_fuzzer
$ cd bazel-bin/executable_semantics/fuzzing/
$ ./executable_semantics_fuzzer
...
#0 0x55b9116a4c41 in __sanitizer_print_stack_trace /tmp/llvm-20220302-9880-1faggz0/llvm-project-13.0.1.src/compiler-rt/lib/asan/asan_stack.cpp:87:3
#1 0x55b9115ec5b8 in fuzzer::PrintStackTrace() cxa_noexception.cpp
#2 0x55b9115d05f3 in fuzzer::Fuzzer::CrashCallback() cxa_noexception.cpp
#3 0x7f42da5bf1ff (/lib/x86_64-linux-gnu/libpthread.so.0+0x131ff)
#4 0x7f42da2698a0 in __libc_signal_restore_set signal/../sysdeps/unix/sysv/linux/internal-signals.h:105:3
#5 0x7f42da2698a0 in raise signal/../sysdeps/unix/sysv/linux/raise.c:47:3
#6 0x7f42da253545 in abort stdlib/abort.c:79:7
#7 0x55b9116de5b9 in Carbon::Internal::operator|(Carbon::Internal::ExitingStream::Helper, Carbon::Internal::ExitingStream&) /proc/self/cwd/./common/check_internal.h:59:5
#8 0x55b911770500 in Carbon::AddPrelude(std::__1::basic_string_view<char, std::__1::char_traits >, Carbon::Arena*, std::__1::vector<Carbon::Declaration*, std::__1::allocatorCarbon::Declaration* >) (/usr/local/google/home/pkobyakov/.cache/bazel/_bazel_pkobyakov/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-opt/bin/executable_semantics/fuzzing/executable_semantics_fuzzer+0x374500)
#9 0x55b9116d8b90 in Carbon::ParseAndExecute(Carbon::Fuzzing::CompilationUnit const&) /proc/self/cwd/executable_semantics/fuzzing/executable_semantics_fuzzer.cpp:28:3
#10 0x55b9116dadaa in TestOneProtoInput /proc/self/cwd/executable_semantics/fuzzing/executable_semantics_fuzzer.cpp:42:3
#11 0x55b9116dadaa in LLVMFuzzerTestOneInput /proc/self/cwd/executable_semantics/fuzzing/executable_semantics_fuzzer.cpp:41:1
#12 0x55b9115d1e73 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const
, unsigned long) cxa_noexception.cpp
#13 0x55b9115d34d4 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocatorfuzzer::SizedFile >&) cxa_noexception.cpp
#14 0x55b9115d3969 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocatorfuzzer::SizedFile >&) cxa_noexception.cpp
#15 0x55b9115c2b7e in fuzzer::FuzzerDriver(int*, char***, int ()(unsigned char const, unsigned long)) cxa_noexception.cpp
#16 0x55b9115ecd72 in main /tmp/llvm-20220302-9880-1faggz0/llvm-project-13.0.1.src/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
#17 0x7f42da2547fc in __libc_start_main csu/../csu/libc-start.c:332:16
#18 0x55b9115999e9 in _start (/usr/local/google/home/pkobyakov/.cache/bazel/_bazel_pkobyakov/0c0c6d5ac7dde4460fd40f446af91e37/execroot/carbon/bazel-out/k8-opt/bin/executable_semantics/fuzzing/executable_semantics_fuzzer+0x19d9e9)

(missing prelude crash)

@pk19604014 pk19604014 requested a review from jonmeow April 22, 2022 22:02
@pk19604014 pk19604014 requested review from jonmeow April 26, 2022 13:56
Copy link
Contributor

@jonmeow jonmeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to update the PR title/description before committing, as it's no longer GetRunfilesDir.

@pk19604014 pk19604014 merged commit 1cf0e18 into carbon-language:trunk May 2, 2022
@pk19604014 pk19604014 deleted the fuzzer_runfiles branch May 2, 2022 14:36
@chandlerc chandlerc added the explorer Action items related to Carbon explorer code label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
explorer Action items related to Carbon explorer code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants