Skip to content

[internal/LibFuzzer] Add option to set cwd to BUILD_DIR based on environment#5260

Open
notvictorl wants to merge 3 commits intogoogle:masterfrom
notvictorl:liuvic/cwd
Open

[internal/LibFuzzer] Add option to set cwd to BUILD_DIR based on environment#5260
notvictorl wants to merge 3 commits intogoogle:masterfrom
notvictorl:liuvic/cwd

Conversation

@notvictorl
Copy link
Copy Markdown
Collaborator

@notvictorl notvictorl commented Apr 28, 2026

libfuzzer_chrome_msan bots have errors caused by the cwd being wrong when we execute the fuzzer. We are looking to pass BUILD_DIR to cwd so that fuzzers are executed from the archive root.

Bug: https://crbug.com/507025973, https://crbug.com/326101784#comment46

  • Add optional cwd argument to LibFuzzerRunner class which passes to parent ProcessRunner class which will runsubprocess.Popen with the cwd argument.
  • When a LibFuzzerRunner is requested with get_runner() the cwd is set to BUILD_DIR if FUZZ_TARGET_CWD_IS_BUILD_DIR is true

@notvictorl notvictorl requested a review from a team as a code owner April 28, 2026 22:14
@notvictorl notvictorl marked this pull request as draft April 28, 2026 22:17
@notvictorl notvictorl marked this pull request as ready for review April 28, 2026 22:17
@notvictorl notvictorl changed the title [internal/LibFuzzer] Add option to set cwd based on environment [internal/LibFuzzer] Add option to set cwd to BUILD_DIR based on environment Apr 29, 2026
…ronment

Add optional cwd argument to LibFuzzerRunner class which passes to
parent ProcessRunner class to subprocess.Popen with cwd argument.
When a LibFuzzerRunner is requested with get_runner() the cwd can be set
to BUILD_DIR using FUZZ_TARGET_CWD_IS_BUILD_DIR boolean env var.
Copy link
Copy Markdown
Collaborator

@dylanjew dylanjew left a comment

Choose a reason for hiding this comment

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

overall looks good! Added a couple questions.

Could you also add some context to the description about why this is needed and/or attach a bug?

Comment thread src/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py
Comment thread src/clusterfuzz/_internal/system/new_process.py Outdated
Comment thread src/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py Outdated
Comment thread src/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py Outdated
@dylanjew
Copy link
Copy Markdown
Collaborator

/gcbrun

@notvictorl
Copy link
Copy Markdown
Collaborator Author

/gcbrun

1 similar comment
@dylanjew
Copy link
Copy Markdown
Collaborator

/gcbrun

Copy link
Copy Markdown
Collaborator

@dylanjew dylanjew left a comment

Choose a reason for hiding this comment

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

Thanks for updating the description!

Comment thread src/clusterfuzz/_internal/tests/core/system/new_process_test.py
@notvictorl
Copy link
Copy Markdown
Collaborator Author

/gcbrun

@notvictorl
Copy link
Copy Markdown
Collaborator Author

@ViniciustCosta friendly nudge to review

Copy link
Copy Markdown
Collaborator

@ViniciustCosta ViniciustCosta left a comment

Choose a reason for hiding this comment

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

IIUC, this will not change the behavior of jobs that do not contain that FUZZ_TARGET_CWD_IS_BUILD_DIR env var. So, lgtm to be merged

Please, notice that since we did not test it, when you set that for a job, you should monitor it closely to guarantee that all tasks are still executing properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants