summaryrefslogtreecommitdiff
path: root/internal/sanitizers.h
AgeCommit message (Collapse)Author
2025-03-16Make ASAN default option string built-in librubyNobuyoshi Nakada
The content depends on ruby internal, not responsibility of the caller. Revive `RUBY_GLOBAL_SETUP` macro to define the hook function. Notes: Merged: https://github.com/ruby/ruby/pull/12933
2024-12-19Prefix asan_poison_object with rbPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12385
2024-12-19Export asan_poison_objectPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/12385
2024-12-19Make asan_poison_object poison the whole slotPeter Zhu
This change poisons the whole slot of the object rather than just the flags. This allows ASAN to find any reads/writes into the slot after it has been freed. Notes: Merged: https://github.com/ruby/ruby/pull/12385
2024-12-16Detect ASAN when using older GCC versionsAlan Wu
Newer GCCs have __has_feature and older ones have __SANITIZE_ADDRESS__[1]. Relevant since ASAN with GCC 11 on the popular Ubuntu Jammy failed to build previously. [1]: https://gcc.gnu.org/onlinedocs/gcc-4.8.0/cpp/Common-Predefined-Macros.html
2024-12-04Fix ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS for MSANPeter Zhu
There's no case for when RUBY_MSAN_ENABLED, so the macro ends up doing nothing when it should instead have __attribute__((__no_sanitize__("memory"))). Notes: Merged: https://github.com/ruby/ruby/pull/12219
2024-10-08Fix extra semicolon outside of a function in `NO_SANITIZE`Nobuyoshi Nakada
``` internal/sanitizers.h:57:26: error: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] 57 | COMPILER_WARNING_PUSH; \ | ^ ``` and so many. Remove semicolons following pragma, and repeat the given declaration at the end to consume a semicolon following the macro call. As many `NO_SANITIZE` calls including bigdecimal that is a gem have a trailing semicolon, it was not able to move the semicolon inside `NO_SANITIZE`.
2024-09-23Unpoison page->freelist before trying to assert on itKJ Tsanaktsidis
Otherwise trying to deref the pointer can cause an ASAN crash, even though the only reason we're dereferencing it is so that we can assert on it. Notes: Merged: https://github.com/ruby/ruby/pull/11660
2024-03-19[DOC] Unify Doxygen formats (#10285)Takashi Kokubun
2024-02-22Extract imemo functions from gc.c into imemo.cPeter Zhu
2024-01-19Mark asan fake stacks during machine stack markingKJ Tsanaktsidis
ASAN leaves a pointer to the fake frame on the stack; we can use the __asan_addr_is_in_fake_stack API to work out the extent of the fake stack and thus mark any VALUEs contained therein. [Bug #20001]
2024-01-19Define special macros for asan/msan being enabledKJ Tsanaktsidis
__has_feature is a clang-ism, and GCC has a different way to tell if sanitizers are enabled. For this reason, I don't want to spray __has_feature all over the codebase for other places where conditional compilation based on sanitizers is required. [Bug #20001]
2024-01-19Make stack bounds detection work with ASANKJ Tsanaktsidis
Where a local variable is used as part of the stack bounds detection, it has to actually be on the stack. ASAN can put local variable on "fake stacks", however, with addresses in different memory mappings. This completely destroys the stack bounds calculation, and can lead to e.g. things not getting GC marked on the machine stack or stackoverflow checks that always fail. The __asan_addr_is_in_fake_stack helper can be used to get the _real_ stack address of such variables, and thus perform the stack size calculation properly [Bug #20001]
2024-01-12Revert "Make stack bounds detection work with ASAN"KJ Tsanaktsidis
This reverts commit 6185cfdf38e26026c6d38220eeca48689e54cdcf.
2024-01-12Revert "Define special macros for asan/msan being enabled"KJ Tsanaktsidis
This reverts commit bdafad879093ef16a9a649154c4b2e4ebf492656.
2024-01-12Revert "Mark asan fake stacks during machine stack marking"KJ Tsanaktsidis
This reverts commit d10bc3a2b8300cffc383e10c3730871e851be24c.
2024-01-12Mark asan fake stacks during machine stack markingKJ Tsanaktsidis
ASAN leaves a pointer to the fake frame on the stack; we can use the __asan_addr_is_in_fake_stack API to work out the extent of the fake stack and thus mark any VALUEs contained therein. [Bug #20001]
2024-01-12Define special macros for asan/msan being enabledKJ Tsanaktsidis
__has_feature is a clang-ism, and GCC has a different way to tell if sanitizers are enabled. For this reason, I don't want to spray __has_feature all over the codebase for other places where conditional compilation based on sanitizers is required. [Bug #20001]
2024-01-12Make stack bounds detection work with ASANKJ Tsanaktsidis
Where a local variable is used as part of the stack bounds detection, it has to actually be on the stack. ASAN can put local variable on "fake stacks", however, with addresses in different memory mappings. This completely destroys the stack bounds calculation, and can lead to e.g. things not getting GC marked on the machine stack or stackoverflow checks that always fail. The __asan_addr_is_in_fake_stack helper can be used to get the _real_ stack address of such variables, and thus perform the stack size calculation properly [Bug #20001]
2023-03-06Remove obsoleted MJIT_HEADER macroTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7461
2021-09-10internal/*.h: skip doxygen卜部昌平
These contents are purely implementation details, not worth appearing in CAPI documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s/RUBY3/RBIMPL/g卜部昌平
Devs do not love "3". The only exception is RUBY3_KEYWORDS in parse.y, which seems unrelated to our interests. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-21__GNUC__ is too lax卜部昌平
Ditto for 4b853932eaa7fa4acf8a0f0c9b7c695bb4f5e76d
2020-04-13add #include guard hack卜部昌平
According to MSVC manual (*1), cl.exe can skip including a header file when that: - contains #pragma once, or - starts with #ifndef, or - starts with #if ! defined. GCC has a similar trick (*2), but it acts more stricter (e. g. there must be _no tokens_ outside of #ifndef...#endif). Sun C lacked #pragma once for a looong time. Oracle Developer Studio 12.5 finally implemented it, but we cannot assume such recent version. This changeset modifies header files so that each of them include strictly one #ifndef...#endif. I believe this is the most portable way to trigger compiler optimizations. [Bug #16770] *1: https://docs.microsoft.com/en-us/cpp/preprocessor/once *2: https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html Notes: Merged: https://github.com/ruby/ruby/pull/3023
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <[email protected]>
2019-12-29Fixed an unavailable sanitizer featureNobuyoshi Nakada
2019-12-26internal/sanitizers.h rework卜部昌平
Rearrange macro orders for better readability. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26split internal.h into files卜部昌平
One day, I could not resist the way it was written. I finally started to make the code clean. This changeset is the beginning of a series of housekeeping commits. It is a simple refactoring; split internal.h into files, so that we can divide and concur in the upcoming commits. No lines of codes are either added or removed, except the obvious file headers/footers. The generated binary is identical to the one before. Notes: Merged: https://github.com/ruby/ruby/pull/2711