sanitizers
Sample R package with C/C++ code to trigger Address and Undefined Behaviour Sanitizers
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.3%) to scientific vocabulary
Repository
Sample R package with C/C++ code to trigger Address and Undefined Behaviour Sanitizers
Basic Info
Statistics
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
sanitizer: Code to trigger ASAN and UBSAN reports
Motivation
The gcc and clang compilers provide functionality to test for memory violations and other undefined behaviour; this is often referred to as "Address Sanitizer" (or ASAN) and "Undefined Behaviour Sanitizer" (UBSAN). The Writing R Extension manual describes this in some detail in Section 4.3 titled Checking Memory Access.
This feature has to be enabled in the corresponding binary, eg in R, which is somewhat involved as it also required a current compiler toolchain which is not yet widely available, or in the case of Windows, not available at all (via the common Rtools mechanism).
As an alternative, pre-built Docker containers such as Rocker's r-devel-san or the SAN builds inside multi-purpose r-debug image can be used.
This R package then provides a means of testing the compiler setup as the known code failures provides in the sample code here should be detected correctly, whereas a default build of R will let the package pass.
The code samples are based on the examples from the Address Sanitizer Wiki.
Example
We can use the Rocker Project container r-devel-san I also maintain. Launching it in, say, a checkout of this repo as
sh
docker run --rm -ti -v $PWD:/work -w /work rocker/r-devel-san bash
launches a bash shell in the current directory which should contain the checked-out repo. We can
then install this package using the sanitizer build (important: using RD aka r-devel, not R
the standard package version) via
sh
RD CMD INSTALL .
When we then launch RD we can tickle the sanitizer vioaliations by calling the respective functions:
```r
sanitizers::stackAddressSanitize() stackaddress.cpp:16:32: runtime error: index 110 out of bounds for type 'int [100]' stackaddress.cpp:16:11: runtime error: load of address 0x7ffd22bcb7b8 with insufficient space for an object of type 'int' 0x7ffd22bcb7b8: note: pointer points here fd 7f 00 00 38 f3 bd d3 0f 7f 00 00 40 b8 bc 22 fd 7f 00 00 09 69 b7 d3 0f 7f 00 00 20 d4 4f da ^ [1] -742526152 sanitizers::heapAddressSanitize() heapaddress.cpp:16:11: runtime error: load of address 0x558eda5d9a58 with insufficient space for an object of type 'int' 0x558eda5d9a58: note: pointer points here 8e 55 00 00 40 d8 5d da 8e 55 00 00 80 9a 5d da 8e 55 00 00 78 fd c7 d7 8e 55 00 00 20 fe c7 d7 ^ [1] -631384000 sanitizers::intOverflowSanitize() intoverflow.cpp:17:11: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' [1] 2147483647
```
This demonstrates that the r-devel-san container is correctly instrumented, and that we launched
the appropriate R(-devel) instance triggering the true positives manifested in this package.
Author
Dirk Eddelbuettel
License
GPL (>= 2)
Owner
- Name: Dirk Eddelbuettel
- Login: eddelbuettel
- Kind: user
- Location: Chicago, IL, USA
- Website: https://dirk.eddelbuettel.com
- Twitter: eddelbuettel
- Repositories: 512
- Profile: https://github.com/eddelbuettel
GitHub Events
Total
- Watch event: 2
- Push event: 1
Last Year
- Watch event: 2
- Push event: 1
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Dirk Eddelbuettel | e****d@d****g | 28 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: 40 minutes
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 4.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- akhikolla (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 190 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
cran.r-project.org: sanitizers
C/C++ Source Code to Trigger Address and Undefined Behaviour Sanitizers
- Homepage: https://github.com/eddelbuettel/sanitizers
- Documentation: http://cran.r-project.org/web/packages/sanitizers/sanitizers.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 0.1.1
published about 3 years ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite