about summary refs log tree commit diff
path: root/tests/ui/sanitizer
AgeCommit message (Collapse)AuthorLines
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-0/+2
2025-08-21-Zsanitize and -Zsanitizer-cfi-normalize-integers flags are now target ↵Andrew Zhogin-24/+36
modifiers with custom consistency check function
2025-08-18Remove the no_sanitize attribute in favor of sanitizeBastian Kersting-30/+1
This removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2025-08-18Implement the #[sanitize(..)] attributeBastian Kersting-3/+32
This change implements the #[sanitize(..)] attribute, which opts to replace the currently unstable #[no_sanitize]. Essentially the new attribute works similar as #[no_sanitize], just with more flexible options regarding where it is applied. E.g. it is possible to turn a certain sanitizer either on or off: `#[sanitize(address = "on|off")]` This attribute now also applies to more places, e.g. it is possible to turn off a sanitizer for an entire module or impl block: ```rust \#[sanitize(address = "off")] mod foo { fn unsanitized(..) {} #[sanitize(address = "on")] fn sanitized(..) {} } \#[sanitize(thread = "off")] impl MyTrait for () { ... } ``` This attribute is enabled behind the unstable `sanitize` feature.
2025-07-23Add `ignore-backends` annotations in failing GCC backend ui testsGuillaume Gomez-0/+14
2025-07-19tests: Require `run-fail` ui tests to have an exit code (`SIGABRT` not ok)Martin Nordholts-5/+5
And introduce two new directives for ui tests: * `run-crash` * `run-fail-or-crash` Normally a `run-fail` ui test like tests that panic shall not be terminated by a signal like `SIGABRT`. So begin having that as a hard requirement. Some of our current tests do terminate by a signal/crash however. Introduce and use `run-crash` for those tests. Note that Windows crashes are not handled by signals but by certain high bits set on the process exit code. Example exit code for crash on Windows: `0xc000001d`. Because of this, we define "crash" on all platforms as "not exit with success and not exit with a regular failure code in the range 1..=127". Some tests behave differently on different targets: * Targets without unwind support will abort (crash) instead of exit with failure code 101 after panicking. As a special case, allow crashes for `run-fail` tests for such targets. * Different sanitizer implementations handle detected memory problems differently. Some abort (crash) the process while others exit with failure code 1. Introduce and use `run-fail-or-crash` for such tests.
2025-07-04Workaround a MemorySanitizer test issueScott McMurray-2/+8
2025-07-01Detect more cases of unused_parens around typesBenjamin Schulz-2/+2
2025-06-23compiletest: Improve diagnostics for line annotation mismatchesVadim Petrochenkov-1/+1
2025-06-16Change __rust_no_alloc_shim_is_unstable to be a functionDaniel Paoliello-0/+1
2025-04-29Require sanitizers be enabled for asan_odr_windows.rsDaniel Paoliello-0/+2
2025-04-11Auto merge of #139578 - ferrocene:pa-compiletest-edition, r=jieyouxubors-2/+4
Fix breakage when running compiletest with `--test-args=--edition=2015` Compiletest has an `--edition` flag to change the default edition tests are run with. Unfortunately no test suite successfully executes when that flag is passed. If the edition is set to something greater than 2015 the breakage is expected, since the test suite currently supports only edition 2015 (Ferrous Systems will open an MCP about fixing that soonish). Surprisingly, the test suite is also broken if `--edition=2015` is passed to compiletest. This PR focuses on fixing the latter. This PR fixes the two categories of failures happening when `--edition=2015` is passed: * Some edition-specific tests set their edition through `//@ compile-flags` instead of `//@ edition`. Compiletest doesn't parse the compile flags, so it would see no `//@ edition` and add another `--edition` flag, leading to a rustc error. * Compiletest would add the edition after `//@ compile-flags`, while some tests depend on flags passed to `//@ compile-flags` being the last flags in the rustc invocation. Note that for the first category, I opted to manually go and replace all `//@ compile-flags` setting an edition with an explicit `//@ edition`. We could've changed compiletest to instead check whether an edition was set in `//@ compile-flags`, but I thought it was better to enforce a consistent way to set the edition in tests. I also added the edition to the stamp, so that changing `--edition` results in tests being re-executed. r? `@jieyouxu`
2025-04-10Remove unnecessary `mut`.Mara Bos-1/+1
The value is moved in pin!().
2025-04-10replace `//@ compile-flags: --edition` with `//@ edition`Pietro Albini-2/+4
2025-04-05KCFI: Add KCFI arity indicator supportRamon de C Valle-0/+28
Adds KCFI arity indicator support to the Rust compiler (see rust-lang/rust#138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
2025-04-03compiletest: Require `//~` annotations even if `error-pattern` is specifiedVadim Petrochenkov-2/+5
2025-03-25compiletest: Support matching on diagnostics without a spanVadim Petrochenkov-0/+17
2025-02-24tests: use minicore moreDavid Wood-6/+6
minicore makes it much easier to add new language items to all of the existing `no_core` tests.
2025-02-06remove `feature(trait_upcasting)` from tests and bless themWaffle Lapkin-1/+0
2025-01-27Locate asan-odr-win with other sanitizer testsTomasz Miąsko-0/+29
2025-01-21remove support for the #[start] attributeRalf Jung-10/+10
2024-12-13Stabilize async closuresMichael Goulet-1/+0
2024-12-05Stabilize noop_wakerEric Holk-1/+0
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2024-11-23remove remaining references to `Reveal`lcnr-1/+1
2024-11-22Stabilize the 2024 editionEric Huss-1/+1
2024-10-19Warn on redundant `--cfg` directive when revisions are usedclubby789-6/+6
2024-10-10UI tests: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-1/+1
2024-08-21Rollup merge of #129179 - compiler-errors:cfi-erase-transparent, r=davidtwcoMatthias Krüger-0/+18
CFI: Erase regions when projecting ADT to its transparent non-1zst field The output from `FieldDef::ty` (or `TyCtxt::type_of`) may have free regions (well, `'static`) -- erase it. Fixes #129169 Fixes #123685
2024-08-18stabilize raw_ref_opRalf Jung-1/+0
2024-08-16CFI: Erase regions when projecting ADT to its transparent non-1zst fieldMichael Goulet-0/+18
2024-08-12CFI: Move CFI ui tests to cfi directoryRamon de C Valle-1/+1
Moves the CFI ui tests to the cfi directory and removes the cfi prefix from tests file names similarly to how the cfi codegen tests are organized.
2024-08-02Use ParamEnv::reveal_all in CFIMichael Goulet-0/+44
2024-07-29Rollup merge of #127882 - compiler-errors:cfi-sized-self-gat, r=oli-obkMatthias Krüger-0/+38
Don't elaborate associated types with Sized bounds in `trait_object_ty` in cfi The elaboration mechanism introduced in #123005 didn't filter for associated types with `Self: Sized` bounds, which since #112319 has excluded them from the object type. Fixes #127881 cc `@maurer` `@rcvalle`
2024-07-17Don't elaborate associated types with Sized bounds in trait_object_ty in cfiMichael Goulet-0/+38
2024-07-17CFI: Support provided methods on traitsMatthew Maurer-0/+6
Provided methods currently don't get type erasure performed on them because they are not in an `impl` block. If we are instantiating a method that is an associated item, but *not* in an impl block, treat it as a provided method instead.
2024-05-15Sort mutually-exclusive pairs, update fixed testsDavid Koloski-10/+2
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-2/+2
And suggest adding the `#[coroutine]` to the closure
2024-04-09Rollup merge of #123649 - maurer:kcfi-v0, r=compiler-errorsMatthias Krüger-0/+30
KCFI: Use legal charset in shim encoding To separate `ReifyReason::FnPtr` from `ReifyReason::VTable`, we hyphenated the shims. Hyphens are not actually legal, but underscores are, so use those instead. r? `@compiler-errors`
2024-04-08KCFI: Use legal charset in shim encodingMatthew Maurer-0/+30
To separate `ReifyReason::FnPtr` from `ReifyReason::VTable`, we hyphenated the shims. Hyphens are not actually legal, but underscores are, so use those instead.
2024-04-08CFI: Fix ICE in KCFI non-associated function pointersMatthew Maurer-2/+6
We oddly weren't testing the more usual case of casting non-methods to function pointers. The KCFI shim insertion logic would ICE on these due to asking for an irrefutable associated item if we cast a function to a function pointer without needing a traditional shim.
2024-04-07Remove useless configs in testsUrgau-2/+2
Since they are never set and don't have impact on the test. Or for the cfg-panic tests are already tested with check-cfg.
2024-04-04CFI: Add test for `call_once` addr takenMatthew Maurer-0/+11
One of the proposed ways to reduce the non-passed argument erasure would cause this test to fail. Adding this now ensures that any attempt to reduce non-passed argument erasure won't make the same mistake.
2024-04-04Auto merge of #123052 - maurer:addr-taken, r=compiler-errorsbors-8/+38
CFI: Support function pointers for trait methods Adds support for both CFI and KCFI for function pointers to trait methods by attaching both concrete and abstract types to functions. KCFI does this through generation of a `ReifyShim` on any function pointer for a method that could go into a vtable, and keeping this separate from `ReifyShim`s that are *intended* for vtable us by setting a `ReifyReason` on them. CFI does this by setting both the concrete and abstract type on every instance. This should land after #123024 or a similar PR, as it diverges the implementation of CFI vs KCFI. r? `@compiler-errors`
2024-04-02CFI: Support function pointers for trait methodsMatthew Maurer-8/+38
Adds support for both CFI and KCFI for attaching concrete and abstract types to functions. KCFI does this through generation of `ReifyShim` on any function pointer that could go in a vtable, and checking the `ReifyReason` when emitting the instance. CFI does this by attaching both the concrete and abstract type to every instance. TypeID codegen tests are switched to be anchored on the left rather than the right in order to allow emission of additional type attachments. Fixes #115953
2024-04-02CFI: Support non-general coroutinesMatthew Maurer-2/+39
Previously, we assumed all `ty::Coroutine` were general coroutines and attempted to generalize them through the `Coroutine` trait. Select appropriate traits for each kind of coroutine.
2024-03-30CFI: Rewrite closure and coroutine instances to their trait methodMatthew Maurer-23/+116
Similar to methods on a trait object, the most common way to indirectly call a closure or coroutine is through the vtable on the appropriate trait. This uses the same approach as we use for trait methods, after backing out the trait arguments from the type.
2024-03-30CFI: Only encode Coroutine Parent ArgsMatthew Maurer-0/+30
Fixes #122705
2024-03-30Rollup merge of #123200 - maurer:kcfi-abort, r=compiler-errorsMatthias Krüger-0/+5
KCFI: Require -C panic=abort While the KCFI scheme is not incompatible with unwinding, LLVM's `invoke` instruction does not currently support KCFI bundles. While it likely will in the near future, we won't be able to assume that in Rust for a while. We encountered this problem while [turning on closure support](https://github.com/rust-lang/rust/pull/123106#issuecomment-2027436640). r? ``@workingjubilee``
2024-03-30Auto merge of #123012 - maurer:cfi-supertraits, r=compiler-errorsbors-0/+73
CFI: Support calling methods on supertraits Automatically adjust `Virtual` calls to supertrait functions to use the supertrait's trait object type as the receiver rather than the child trait. cc `@compiler-errors` - this is the next usage of `trait_object_ty` I intend to have, so I thought it might be relevant while reviewing the existing one.
2024-03-29CFI: Encode Virtual calls as calls through the defining traitMatthew Maurer-0/+73
For example, if `trait Foo: Bar`, and we try to call a method from `Bar` on `dyn Foo`, encode the callsite as passing a `dyn Bar`, not a `dyn Foo`.