From fef8a582dda61929ea85cb6e690a7e564cd0330d Mon Sep 17 00:00:00 2001 From: MrBruh <4706866+cybersecurity@users.noreply.github.com> Date: Sun, 27 Sep 2026 19:56:32 +1300 Subject: [PATCH] Fix release build crash on level load --- source/objects/objects.c | 12 +++++++++++- source/physics/collision_debug.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/objects/objects.c b/source/objects/objects.c index 58f0809d..e467bdf6 100644 --- a/source/objects/objects.c +++ b/source/objects/objects.c @@ -1765,10 +1765,20 @@ void object_reconnect_to_map( } else { +#ifdef HALO_LINUX + /* location may point here after the if below: declared inside it, + the location would be read after its lifetime ended, which an + optimising compiler is free to break (release builds crashed placing + objects at level start, reading a stack slot reused meanwhile) */ + struct location bounding_sphere_location; + +#endif if (!location) { +#ifndef HALO_LINUX struct location bounding_sphere_location; - +#endif + scenario_location_from_point(&bounding_sphere_location, &object->object.bounding_sphere_center); location = &bounding_sphere_location; diff --git a/source/physics/collision_debug.c b/source/physics/collision_debug.c index 8af414e1..ee323c2f 100644 --- a/source/physics/collision_debug.c +++ b/source/physics/collision_debug.c @@ -320,6 +320,11 @@ void collision_debug_render( real_matrix4x3 const *matrix = NULL; struct collision_surface const *surface = NULL; char textstring[2048]; +#ifdef HALO_LINUX + /* matrix points into it after the else if below, so it + has to outlive that block (see object_reconnect_to_map) */ + struct collision_model_instance instance; +#endif render_debug_vector(TRUE, &point, &vector, collision.t, global_real_argb_red); render_debug_point(TRUE, &collision.point, 0.125f, global_real_argb_red); @@ -331,7 +336,9 @@ void collision_debug_render( } else if (collision.type == _collision_result_object && collision.node_index != NONE) { +#ifndef HALO_LINUX struct collision_model_instance instance; +#endif if (collision_model_instance_new(&instance, collision.object_index)) {