This fixes UBSAN errors reported by running our testsuite, importing the
TPS demo, and running the TPS demo. I have tried, wherever possible, to
fix issues related to reported issues but not directly reported by UBSAN
because thse code paths just happened to not have been exercised in
these cases.
These fixes apply only to errors reported, and caused by, core/
The following things have been changed:
* Make sure there are no implicit sign changing casts in core.
* Explicitly type enums that are part of a public API such that users of
the API cannot pass in wrongly-sized values leading to potential stack
corruption.
* Ensure that memcpy is never called with invalid or null pointers as
this is undefined behavior, and when the engine is built with
optimizations turned on leads to memory corruption and hard to debug
crashes.
* Replace enum values only used as static values with constexpr static
const values instead. This has no runtime overhead. This makes it so
that the size of the enums is explicit.
* Make sure that nan and inf is handled consistently in String.
* Implement a _to_int template to ensure that all of the paths use the
same algorhithm, and correct the negative integer case.
* Changed the way the json serializer precision work, and added tests to
verify the new behavior. The behavior doesn't quite match master in
particulary for negative doubles as the original code tried to cast -inf
to an int. This then led to negative doubles losing all but one of
their decimal points when serializing. Behavior in GDScript remains
unchanged.
With these suppressions it is possible to import and run the TPS demo
without any thirdparty/ reported ubsan.
This is useful because it is a complex project, so it is good for
testing if new errors show up in our own code.
In my quest to make ubsan failures a build failure I've added all
current ubsan errors by type to a new suppression file which we will
then also use with CI.
The idea is to only add known ubsan errors to this file, so this is not
a blanket exclusion of thirdparty/ this means that if we get new or
unexpected ubsan in thirdparty/ builds would fail.
These misaligned accesses are shown in all of our CI hooks. It turned
out to not be difficult to fix.
It is likely that this will improve performance for aarch64.
- Change TFM and LangVersion
- Better exception throwing (CA1510, CA1512, CA1513)
- Better exception utility method definition (CA1859)
- Prefer comparing `.Count` over calling `.Any()` (CA1860)
- Prefer `.AsSpan()` over `.Substring()` (CA1846)
- Add a few more `scoped`
- Use `RuntimeHelpers.GetUninitializedObject()` instead of `FormatterServices.GetUninitializedObject()`
- Use delegate instead of delegate pointer in variant generic conversions
- Enable EnforceExtendedAnalyzerRules in source generator projects
- Disable CS8981 on structs named movable in Godot.NativeInterop
Before this commit, ccache where only used on Mac when
`OSXCROSS_ROOT` was defined. Now, it could be used even
when that envirnment variable is not defined.
Update doc/classes/TextureButton.xml
Co-authored-by: Micky <66727710+Mickeon@users.noreply.github.com>
Improve explanation of texture fallback behaviors for TextureButton
Remove a bit of incorrect information from TextureButton documentation
Most other state textures are not overlaid (only `texture_focused`)
Apply suggestions from code review