Mysterious crashes in rust algos

Mysterious crashes in rust algos
0

#1

Hi there! I created a Rust algo, and when I play it locally or in the playground, it doesn’t crash. It also doesn’t crash most of the time in matches. However, today I found out this weird crash. When I open up the replays in the playground (which are attached below), I noticed that in the second last frame, my health was dropped by 31. Has anyone face the same issue?

I’ve checked most of my code and I don’t think it should crash. Since we can’t access crash logs, what are some ways to debug this?

Thanks in advance!

https://terminal.c1games.com/watch/4169524
https://terminal.c1games.com/watch/4169483


#2

Hi @steven, Given you crashed the turn after the opponent removed one of their walls, I’m betting the crash is due to the same double-removal bug I’ve seen with my rust algos.

The short explanation is it’s a problem with the engine allowing a bad game state and the rust code raises an error when it decodes that bad game state:

That same thread has a code fix you can make to avoid the bad game state without crashing.


#3

Ah I see. Actually I just saw your question/post and added the fix. It seems like it’s not crashing now. Thanks!


#4

Hi, can you help me with this game crash? It behaves exactly as the previous ones.

https://terminal.c1games.com/watch/4229003

I tried to check the replay but I can’t find anything. I’ve applied your patch, and also did the same thing to wall units, i.e.

diff --git a/algo/src/map.rs b/algo/src/map.rs
index d1e259d..321991c 100644
--- a/algo/src/map.rs
+++ b/algo/src/map.rs
@@ -94,15 +94,14 @@ impl Map {
                 for unit_data in unit_data_vec {
                     let slot: &mut Option<Unit<FirewallUnitType>> = walls.get_mut(unit_data.coords())
                         .ok_or(MapParseError::UnitInIllegalPosition(unit_data.coords()))?;
-                    if slot.is_some() {
-                        return Err(MapParseError::MultipleWallsSamePosition(unit_data.coords()));
+                    if !slot.is_some() {
+                        *slot = Some(Unit {
+                            unit_type,
+                            stability: unit_data.stability(),
+                            id: Some(unit_data.unit_id().clone()),
+                            owner: player
+                        });
                     }
-                    *slot = Some(Unit {
-                        unit_type,
-                        stability: unit_data.stability(),
-                        id: Some(unit_data.unit_id().clone()),
-                        owner: player
-                    });
                 }
             }

Thanks!


#5

Hi @steven,

Since it’s a turn zero crash I’d bet it has nothing to do with your code and is the same trouble others have been talking about in that spontaneous crash thread.

Hopefully they’ll have that sorted out on their end!