The Binding of Isaac: Rebirth

The Binding of Isaac: Rebirth

98 ratings
Isaac.Spawn() Crash Fix
2
   
Award
Favorite
Favorited
Unfavorite
Tags: Lua
File Size
Posted
3.041 KB
Jun 22, 2024 @ 3:40am
1 Change Note ( view )

Subscribe to download
Isaac.Spawn() Crash Fix

Description
What?

Most mods use a function named Isaac.Spawn() to spawn just about everything in the game (visual effects, familiars, pickups, etc.). However, this function has a very small chance (1 in 4294967296) to Crash the game if the randomly generated seed happens to be 0.

Since it's unlikely that every mod that uses Isaac.Spawn() will update their code to account for this possibility, I created this mod to patch the problem directly.

Which Versions Are Affected?

The issue affects all versions of the game, including REPENTOGON, although it is likely that the issue will be fixed in their next update. While Repentance may eventually receive a patch, this issue also affects Afterbirth+, which is unlikely to receive one. Therefore, this mod will remain available to protect Afterbirth+ users.

Regarding Performance Concerns

While it is true that the necessary checks to avoid this edge case add some overhead, in practice this "slowdown" is irrelevant. The most time-consuming part of the function is not the checks, but the actual spawning of the entity, and the difference is significant. Even when the function is called frequently enough to potentially skip frames (around 1000 spawns in a single frame), the added delay cannot be noticed in terms of milliseconds.
16 Comments
little horn Apr 24 @ 9:44am 
this sounds overpowerd for weak pcs
10/10
Guantol  [author] Nov 23, 2024 @ 3:35pm 
@Roak Yes, it's still present.
Roak Nov 23, 2024 @ 3:08pm 
does this issue still occur in rep+?
Guantol  [author] Sep 15, 2024 @ 6:03pm 
@Hamburger:
Fun fact: this can also happen in non modded isaac. Specifically everytime an ember effect is spawned whilst in burning basement there is a chance it crashes the game.
Hamburger Sep 15, 2024 @ 3:37pm 
im not gonna install this, because I wanna have fun knowing that there's a 0.00000000023283064365386962890625% chance that the game randomly decides to kill itself after an item is spawned through a mod.
Kamil Jun 30, 2024 @ 4:44pm 
kto pubi boberki :steamsalty:
Guantol  [author] Jun 29, 2024 @ 3:20am 
@Fred RNGesus wasn't on your side.
Former President, George W. Bush Jun 28, 2024 @ 7:48pm 
dude I uninstalled this and my next run this exact crash happens
Guantol  [author] Jun 26, 2024 @ 2:06pm 
@ZilusLules
No, that's not what I meant.

In the modding API there is a function named Isaac.Spawn() which is what allows any mod to spawn an entity
In this game most things are entities: Players, Familiars, Pickups (Coins, Collectibles, Chests, Keys, Bombs, etc.), Enemies, Bosses, Visual Effects, etc.

Whenever a mod tries to spawn one of these in the game they most likely will use the Isaac.Spawn() function (As it was the recommended function in the Documentation, until I discovered the crash).

However this function has a very rare chance of setting the entity's RNG seed to 0, which crashes the game.

So actually this helps if you are using any mod that spawns anything in the game (which will most likely be most mods).
ZilusLules Jun 26, 2024 @ 1:49pm 
So you're saying that this helps in this type of situation:

Plays with mods and paused, leaves to continue the run on the later, goes back and the game crashes when i press "continue"