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

Provide consistent exit codes #617

Merged
merged 6 commits into from
Sep 29, 2023
Merged

Provide consistent exit codes #617

merged 6 commits into from
Sep 29, 2023

Conversation

bertschneider
Copy link
Contributor

This change uses the possibility to stop the fuzzer loop provided in the patched
libFuzzer version. Incorporating this allows the removal of the stopFuzzing
functions and general simplifications of the fuzzing process.

The core fuzzing function now returns the expected exit code and found error so
that invoking code can handle them according to its needs, e.g. exit the
process with the given code in case of CLI, and rethrow the error in case of
Jest.

@bertschneider bertschneider force-pushed the FUZZ-784_return_codes branch 3 times, most recently from 49e9448 to 5ac96ab Compare September 27, 2023 15:23
Copy link
Contributor

@oetr oetr 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 this awesome PR! It makes a large chunk of our native code much clearer.

.gitignore Outdated Show resolved Hide resolved
packages/core/core.ts Show resolved Hide resolved
packages/core/core.ts Outdated Show resolved Hide resolved
packages/core/finding.ts Outdated Show resolved Hide resolved
@bertschneider
Copy link
Contributor Author

bertschneider commented Sep 28, 2023

I incorporated the latest signal handling changes into this PR. It seems that handling SIGSEGV in the native addon only is sufficient. SIGINT still needs to be handled in JS as the fuzzer has to shut down orderly to generate coverage and print debug information.
Furthermore, I changed the sigsegv error message so that it's recognized by cifuzz.

This leaves Jazzer.js with consistent error messages, except for timeouts, where libFuzzer kills the process with a timeout crash and exit code 70, and segfaults, where the addon kills the process with exit code 139.

To test the correct debug information handling on SIGINTs I had to provide the verbose flag to the fuzzer, hence it can not be used for verbose log messages in the test helper anymore. The old test helper flag is now called logTestOutput, name suggestions are welcome 😄

Errors from within other environments, like vm, window or frame, have different
prototypes and would not match instanceof checks.
This change uses the possibility to stop the fuzzer loop provided in the patched
libFuzzer version. Incorporating this allows the removal of the stopFuzzing
functions and general simplifications of the fuzzing process.

The core fuzzing function now returns the expected exit code and found error so
that the invoking code can handle them according to its needs, e.g. exit the
process with the given code in case of CLI, and rethrow the error in case of
Jest.
Handling of SIGSEGV in the native addon only seems to be sufficient. In case of
a segfault print an error message, dump the current input and exit the
application. This should be a real rare case to begin with and continuing to
fuzz seems like a bad idea.

SIGINT still needs to be handled in JS, as the fuzzer should shut down properly
and generate coverage and debug information.
@bertschneider bertschneider enabled auto-merge (rebase) September 29, 2023 12:52
@bertschneider bertschneider merged commit d44d22e into main Sep 29, 2023
9 checks passed
@bertschneider bertschneider deleted the FUZZ-784_return_codes branch September 29, 2023 14:44
karfau pushed a commit to xmldom/xmldom that referenced this pull request Oct 28, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@jazzer.js/core](https://togithub.com/CodeIntelligenceTesting/jazzer.js)
| [`2.0.0` ->
`2.1.0`](https://renovatebot.com/diffs/npm/@jazzer.js%2fcore/2.0.0/2.1.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@jazzer.js%2fcore/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@jazzer.js%2fcore/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@jazzer.js%2fcore/2.0.0/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@jazzer.js%2fcore/2.0.0/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>CodeIntelligenceTesting/jazzer.js
(@&#8203;jazzer.js/core)</summary>

###
[`v2.1.0`](https://togithub.com/CodeIntelligenceTesting/jazzer.js/releases/tag/v2.1.0):
Release 2.1.0

[Compare
Source](https://togithub.com/CodeIntelligenceTesting/jazzer.js/compare/v2.0.0...v2.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

- **Feature**: Jest support: List fuzz test names by
[@&#8203;zgtm](https://togithub.com/zgtm) in
[CodeIntelligenceTesting/jazzer.js#606
- **Feature**: Handle real segfaults in fuzz targets by
[@&#8203;br-lewis](https://togithub.com/br-lewis) in
[CodeIntelligenceTesting/jazzer.js#602
- **Feature**: Provide consistent exit codes by
[@&#8203;bertschneider](https://togithub.com/bertschneider) in
[CodeIntelligenceTesting/jazzer.js#617
- **Bugfix**: Patch coverage of implicit else branches by
[@&#8203;bertschneider](https://togithub.com/bertschneider) in
[CodeIntelligenceTesting/jazzer.js#635

**Full Changelog**:
CodeIntelligenceTesting/jazzer.js@v2.0.0...v2.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/xmldom/xmldom).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
karfau pushed a commit to xmldom/xmldom that referenced this pull request Oct 28, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@jazzer.js/jest-runner](https://togithub.com/CodeIntelligenceTesting/jazzer.js)
| [`2.0.0` ->
`2.1.0`](https://renovatebot.com/diffs/npm/@jazzer.js%2fjest-runner/2.0.0/2.1.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@jazzer.js%2fjest-runner/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@jazzer.js%2fjest-runner/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@jazzer.js%2fjest-runner/2.0.0/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@jazzer.js%2fjest-runner/2.0.0/2.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>CodeIntelligenceTesting/jazzer.js
(@&#8203;jazzer.js/jest-runner)</summary>

###
[`v2.1.0`](https://togithub.com/CodeIntelligenceTesting/jazzer.js/releases/tag/v2.1.0):
Release 2.1.0

[Compare
Source](https://togithub.com/CodeIntelligenceTesting/jazzer.js/compare/v2.0.0...v2.1.0)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

- **Feature**: Jest support: List fuzz test names by
[@&#8203;zgtm](https://togithub.com/zgtm) in
[CodeIntelligenceTesting/jazzer.js#606
- **Feature**: Handle real segfaults in fuzz targets by
[@&#8203;br-lewis](https://togithub.com/br-lewis) in
[CodeIntelligenceTesting/jazzer.js#602
- **Feature**: Provide consistent exit codes by
[@&#8203;bertschneider](https://togithub.com/bertschneider) in
[CodeIntelligenceTesting/jazzer.js#617
- **Bugfix**: Patch coverage of implicit else branches by
[@&#8203;bertschneider](https://togithub.com/bertschneider) in
[CodeIntelligenceTesting/jazzer.js#635

**Full Changelog**:
CodeIntelligenceTesting/jazzer.js@v2.0.0...v2.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/xmldom/xmldom).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1hc3RlciJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

None yet

2 participants