{"id":16572077,"url":"https://github.com/eddelbuettel/sanitizers","last_synced_at":"2025-07-22T17:03:13.264Z","repository":{"id":19215986,"uuid":"22450030","full_name":"eddelbuettel/sanitizers","owner":"eddelbuettel","description":"Sample R package with C/C++ code to trigger Address and Undefined Behaviour Sanitizers ","archived":false,"fork":false,"pushed_at":"2024-11-16T17:26:08.000Z","size":33,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-20T09:47:41.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddelbuettel.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-07-31T00:27:30.000Z","updated_at":"2025-06-18T13:04:44.000Z","dependencies_parsed_at":"2024-06-05T02:27:24.265Z","dependency_job_id":"4a4a89ea-1672-4feb-859a-bff9db28a233","html_url":"https://github.com/eddelbuettel/sanitizers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eddelbuettel/sanitizers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fsanitizers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fsanitizers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fsanitizers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fsanitizers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddelbuettel","download_url":"https://codeload.github.com/eddelbuettel/sanitizers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Fsanitizers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266522240,"owners_count":23942612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T21:26:16.045Z","updated_at":"2025-07-22T17:03:13.225Z","avatar_url":"https://github.com/eddelbuettel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## sanitizer: Code to trigger ASAN and UBSAN reports\n\n[![CI](https://github.com/eddelbuettel/sanitizers/workflows/ci/badge.svg)](https://github.com/eddelbuettel/sanitizers/actions?query=workflow%3Aci)\n[![License](https://eddelbuettel.github.io/badges/GPL2+.svg)](https://www.gnu.org/licenses/gpl-2.0.html)\n[![CRAN](https://www.r-pkg.org/badges/version/sanitizers)](https://cran.r-project.org/package=sanitizers)\n[![r-universe](https://eddelbuettel.r-universe.dev/badges/sanitizers)](https://eddelbuettel.r-universe.dev/sanitizers)\n[![Dependencies](https://tinyverse.netlify.app/badge/sanitizers)](https://cran.r-project.org/package=sanitizers)\n[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/sanitizers)](https://github.com/eddelbuettel/sanitizers)\n\n### Motivation\n\nThe gcc and clang compilers provide functionality to test for memory violations and other undefined behaviour; this is often\nreferred to as \"Address Sanitizer\" (or ASAN) and \"Undefined Behaviour Sanitizer\" (UBSAN).  The [Writing R Extension\nmanual](https://cran.r-project.org/doc/manuals/r-release/R-exts.html) describes this in some detail in Section 4.3 titled\n[Checking Memory Access](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Checking-memory-access).\n\nThis feature has to be enabled in the corresponding binary, eg in R, which is somewhat involved as it also required a current\ncompiler toolchain which is not yet widely available, or in the case of Windows, not available at all (via the common Rtools\nmechanism).\n\nAs an alternative, pre-built Docker containers such as [Rocker's r-devel-san](https://hub.docker.com/r/rocker/r-devel-san) or the\nSAN builds inside multi-purpose [r-debug](https://hub.docker.com/r/wch1/r-debug/) image can be used.\n\nThis R package then provides a means of testing the compiler setup as the known code failures provides in the sample code here\nshould be detected correctly, whereas a default build of R will let the package pass.\n\nThe code samples are based on the examples from the [Address Sanitizer Wiki](https://github.com/google/sanitizers/wiki).\n\n### Example\n\nWe can use the [Rocker Project](https://rocker-project.org/) container [r-devel-san](https://hub.docker.com/r/rocker/r-devel-san)\nI also maintain.  Launching it in, say, a checkout of this repo as \n\n```sh\ndocker run --rm -ti -v $PWD:/work -w /work rocker/r-devel-san bash\n```\n\nlaunches a `bash` shell in the current directory which should contain the checked-out repo. We can\nthen install this package _using the sanitizer build_ (important: using `RD` aka r-devel, not `R`\nthe standard package version) via\n\n```sh\nRD CMD INSTALL .\n```\n\nWhen we then launch `RD` we can tickle the sanitizer vioaliations by calling the respective functions:\n\n```r\n\u003e sanitizers::stackAddressSanitize()\nstack_address.cpp:16:32: runtime error: index 110 out of bounds for type 'int [100]'\nstack_address.cpp:16:11: runtime error: load of address 0x7ffd22bcb7b8 with insufficient space for an object of type 'int'\n0x7ffd22bcb7b8: note: pointer points here\n 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\n              ^ \n[1] -742526152\n\u003e sanitizers::heapAddressSanitize()\nheap_address.cpp:16:11: runtime error: load of address 0x558eda5d9a58 with insufficient space for an object of type 'int'\n0x558eda5d9a58: note: pointer points here\n 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\n              ^ \n[1] -631384000\n\u003e sanitizers::intOverflowSanitize()\nint_overflow.cpp:17:11: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'\n[1] 2147483647\n\u003e \n```\n\nThis demonstrates that the `r-devel-san` container is correctly instrumented, and that we launched\nthe appropriate R(-devel) instance triggering the true positives manifested in this package.\n\n### Author\n\nDirk Eddelbuettel\n\n### License\n\nGPL (\u003e= 2)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Fsanitizers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddelbuettel%2Fsanitizers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Fsanitizers/lists"}