1
0
Fork 0
godot/core/math
HP van Braam 240f510fa7 Core ubsan fixes
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.
2024-12-18 14:31:12 +01:00
..
SCsub SCons: Add unobtrusive type hints in SCons files 2024-09-25 09:34:35 -05:00
a_star.compat.inc add partial path return option for astar 2024-04-03 22:27:33 -07:00
a_star.cpp Get rid of easily removable uses of const_cast 2024-12-01 17:50:13 -08:00
a_star.h Get rid of easily removable uses of const_cast 2024-12-01 17:50:13 -08:00
a_star_grid_2d.compat.inc add partial path return option for astar 2024-04-03 22:27:33 -07:00
a_star_grid_2d.cpp fix astar partial path destination can be solid/disabled 2024-09-12 20:09:41 -07:00
a_star_grid_2d.h fix astar partial path destination can be solid/disabled 2024-09-12 20:09:41 -07:00
aabb.cpp Fix AABB Ray intersection - return inside 2024-05-09 20:41:19 +01:00
aabb.h Simplify and fix Rect2/AABB get_support function 2024-08-19 23:55:31 -07:00
audio_frame.h
basis.cpp Fix incorrect name of Basis global scale getter 2024-04-16 04:26:52 -07:00
basis.h Set clang-format `RemoveSemicolon` rule to `true` 2024-10-25 13:49:43 -04:00
bvh.h Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 -06:00
bvh_abb.h Fix some uses of float and real_t in core/math 2024-03-29 16:44:12 -07:00
bvh_cull.inc
bvh_debug.inc Fix some uses of float and real_t in core/math 2024-03-29 16:44:12 -07:00
bvh_integrity.inc
bvh_logic.inc Style: Add 19.1.0 LLVM options to `.clang-format` 2024-11-22 09:24:32 -06:00
bvh_misc.inc Style: Add 19.1.0 LLVM options to `.clang-format` 2024-11-22 09:24:32 -06:00
bvh_pair.inc Core ubsan fixes 2024-12-18 14:31:12 +01:00
bvh_public.inc
bvh_refit.inc
bvh_split.inc Fix some uses of float and real_t in core/math 2024-03-29 16:44:12 -07:00
bvh_structs.inc Style: Add 19.1.0 LLVM options to `.clang-format` 2024-11-22 09:24:32 -06:00
bvh_tree.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
color.cpp Optimize `Color::find_named_color()` 2024-05-23 15:19:19 +03:00
color.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
color_names.inc Optimize `Color::find_named_color()` 2024-05-23 15:19:19 +03:00
convex_hull.cpp [Codestyle] Merge identical code piece. 2024-12-11 00:48:00 +08:00
convex_hull.h
delaunay_2d.h
delaunay_3d.h [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
disjoint_set.h Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 -06:00
dynamic_bvh.cpp
dynamic_bvh.h Use `Vector*` component-wise `min/max/clamp` functions where applicable 2024-03-20 13:47:42 +01:00
expression.cpp Core: Fix `JSON.{from,to}_native()` issues 2024-11-29 12:43:06 +03:00
expression.h Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 -06:00
face3.cpp
face3.h Core: Replace `_NO_DISCARD_` macro with attribute 2024-04-12 16:40:01 -05:00
geometry_2d.cpp Set clang-format `RemoveSemicolon` rule to `true` 2024-10-25 13:49:43 -04:00
geometry_2d.h Expose `Geometry2D.bresenham_line()` method 2024-10-25 10:27:55 +03:00
geometry_3d.cpp
geometry_3d.h Fix some uses of float and real_t in core/math 2024-03-29 16:44:12 -07:00
math_defs.h
math_fieldwise.cpp
math_fieldwise.h
math_funcs.cpp
math_funcs.h Add modf function and fix snap behavior 2024-08-30 17:49:57 +03:00
plane.cpp
plane.h Set clang-format `RemoveSemicolon` rule to `true` 2024-10-25 13:49:43 -04:00
projection.cpp Fix stringification of Projection 2024-11-25 21:10:32 +01:00
projection.h Core: Replace `_NO_DISCARD_` macro with attribute 2024-04-12 16:40:01 -05:00
quaternion.cpp
quaternion.h Core: Replace `_NO_DISCARD_` macro with attribute 2024-04-12 16:40:01 -05:00
quick_hull.cpp [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
quick_hull.h
random_number_generator.cpp
random_number_generator.h
random_pcg.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
random_pcg.h Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 -06:00
rect2.cpp Always add decimal when printing float 2024-10-23 15:00:21 +02:00
rect2.h Simplify and fix Rect2/AABB get_support function 2024-08-19 23:55:31 -07:00
rect2i.cpp
rect2i.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00
static_raycaster.cpp
static_raycaster.h Fix `builtin_embree=no` build linking the wrong version of Embree 2024-05-08 00:40:45 +02:00
transform_2d.cpp
transform_2d.h Style: Add `WARNING:` as new comment admonition 2024-09-25 09:44:42 -05:00
transform_3d.cpp
transform_3d.h Core: Replace `_NO_DISCARD_` macro with attribute 2024-04-12 16:40:01 -05:00
transform_interpolator.cpp Fixed Timestep Interpolation (3D) 2024-07-07 22:15:23 +02:00
transform_interpolator.h Fixed Timestep Interpolation (3D) 2024-07-07 22:15:23 +02:00
triangle_mesh.cpp [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
triangle_mesh.h
triangulate.cpp
triangulate.h
vector2.cpp Always add decimal when printing float 2024-10-23 15:00:21 +02:00
vector2.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00
vector2i.cpp [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
vector2i.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00
vector3.cpp Always add decimal when printing float 2024-10-23 15:00:21 +02:00
vector3.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00
vector3i.cpp [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
vector3i.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00
vector4.cpp Fix stringification of Vector4 2024-11-22 21:44:30 +01:00
vector4.h Rename Vector4.components -> coord 2024-09-26 14:02:00 +02:00
vector4i.cpp [Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)` 2024-05-02 10:31:13 +02:00
vector4i.h Merge pull request #90582 from Repiteo/core/remove-macro-_NO_DISCARD_ 2024-06-25 10:01:39 +02:00