sanitizers

Sample R package with C/C++ code to trigger Address and Undefined Behaviour Sanitizers

https://github.com/eddelbuettel/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
Last synced: 11 months ago · JSON representation

Repository

Sample R package with C/C++ code to trigger Address and Undefined Behaviour Sanitizers

Basic Info
  • Host: GitHub
  • Owner: eddelbuettel
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 32.2 KB
Statistics
  • Stars: 12
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 12 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog

README.md

sanitizer: Code to trigger ASAN and UBSAN reports

CI License CRAN r-universe Dependencies Last Commit

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

GitHub Events

Total
  • Watch event: 2
  • Push event: 1
Last Year
  • Watch event: 2
  • Push event: 1

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 28
  • Total Committers: 1
  • Avg Commits per committer: 28.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 190 Last month
Rankings
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Average: 47.5%
Downloads: 77.4%
Maintainers (1)
Last synced: 12 months ago

Dependencies

.github/workflows/ci.yaml actions
  • actions/checkout v3 composite
DESCRIPTION cran