Skip to content

Improve sanitizer usage #2988

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

Merged
merged 2 commits into from
Oct 20, 2020
Merged

Conversation

keith
Copy link
Member

@keith keith commented Oct 20, 2020

This makes a few small improvements to using sanitizers:

  1. Include the valid values in --help.

Before:

--sanitize <sanitize>  Turn on runtime checks for erroneous behavior

After:

--sanitize <sanitize>  Turn on runtime checks for erroneous behavior,
                       possible values: address, thread, undefined, scudo
  1. Improve error for invalid values.

Before:

error: unknown value 'invalid' for argument --sanitize; use --help to print usage

After:

error: The value 'invalid' is invalid for '--sanitize <sanitize>': valid sanitizers: address, thread, undefined, scudo
  1. Allow underlying values as arguments.

Before:

error: unknown value 'tsan' for argument --sanitize; use --help to print usage

After:

Works!

Fixes:

This makes a few small improvements to using sanitizers:

1. Include the valid values in `--help`.

Before:

```
--sanitize <sanitize>  Turn on runtime checks for erroneous behavior
```

After:

```
--sanitize <sanitize>  Turn on runtime checks for erroneous behavior,
                       possible values: address, thread, undefined, scudo
```

2. Improve error for invalid values.

Before:

```
error: unknown value 'invalid' for argument --sanitize; use --help to print usage
```

After:

```
error: The value 'invalid' is invalid for '--sanitize <sanitize>': valid sanitizers: address, thread, undefined, scudo
```

3. Allow underlying values as arguments.

Before:

```
error: unknown value 'tsan' for argument --sanitize; use --help to print usage
```

After:

Works!

Fixes:

- https://bugs.swift.org/browse/SR-12545
- https://bugs.swift.org/browse/SR-12546
Copy link
Contributor

@mattt mattt left a comment

Choose a reason for hiding this comment

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

Nice work, @keith! I think this goes a long way to improving the usability of sanitizers with SPM.

@abertelrud
Copy link
Contributor

Thanks @keith, these are great fixes and improvements!

@abertelrud
Copy link
Contributor

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

@keith Tests all pass, ok to merge this? Thanks again!

@keith
Copy link
Member Author

keith commented Oct 20, 2020

Ok with me! Thanks!

@abertelrud abertelrud merged commit 2e2e993 into swiftlang:main Oct 20, 2020
@keith keith deleted the ks/improve-sanitizer-usage branch October 20, 2020 23:30
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.

4 participants