**REPORTED** Game crash related to teleporting while in a bed

Yjay

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Multi
Operating System
Windows 10
Terraria Version
1.4.0.4
Controls Used
Keyboard/Mouse
Hello!

Recently, while playing with a cousin, we managed to find a strange crash related to beds and Return potions. Credit goes to them for the original (and completely accidental) discovery.

Steps to Replicate:
0.) Be in Multiplayer.
1.) Set spawn at a bed.
2.) Sleep in the bed.
3.) Unset spawn while still in bed.
4.) Use a Potion of Return. (You should be teleported to the same bed, without using up the potion, but it still makes the sound and gives off particles.)
5.) Use a Magic Mirror. (Edit: It seems as if waiting will also lead to crash, without a need for the mirror.)
6.) Game crash!

Link to video with the crash:

Full Crashlog:
5/27/2020 4:32:04 PM
System.InvalidOperationException: Nullable object must have a value.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Nullable`1.get_Value()
at Terraria.NetMessage.SendData(Int32 msgType, Int32 remoteClient, Int32 ignoreClient, NetworkText text, Int32 number, Single number2, Single number3, Single number4, Int32 number5, Int32 number6, Int32 number7)
at Terraria.Main.TrySyncingMyPlayer()
at Terraria.Main.DoUpdate(GameTime gameTime)
at Terraria.Main.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)



Replicated on two Windows 10 computers (Cousin and myself), but I'm curious to see if others can get the same thing to happen as well.

Happy crashing!
 
Last edited:
Doesn't the Potion of Return take you to your spawnpoint? Since you un-set the bed as your spawnpoint, that shouldn't happen, unless that bed happens to be at world spawn.. which you wouldn't do because there's no point, so this line of thinking can actually be disregarded.
 
Doesn't the Potion of Return take you to your spawnpoint? Since you un-set the bed as your spawnpoint, that shouldn't happen, unless that bed happens to be at world spawn.. which you wouldn't do because there's no point, so this line of thinking can actually be disregarded.
The more I look at this bug, the weirder it gets. The bed here is far from the spawnpoint; I've tested with various types of beds in various parts of the world, and it still occurs consistently in each circumstance.
 
Last edited:
I just tested this out a tiny bit, and found that step 4 can only be a Potion of Return, not a Recall Potion or Magic Mirror. However, there was something else I noticed - you don't even need to do step 5 to crash the game, just let it sit for several more seconds, and it will automatically crash on its own, with the same crash log.
 
I just tested this out a tiny bit, and found that step 4 can only be a Potion of Return, not a Recall Potion or Magic Mirror. However, there was something else I noticed - you don't even need to do step 5 to crash the game, just let it sit for several more seconds, and it will automatically crash on its own, with the same crash log.
Good to know! I had that happen once with testing, where it crashed by itself; using a magic mirror seems to lead to an instant crash.

I'll update the post to clarify it's specifically a Potion of Return, as just saying "return" can be a bit ambiguous.
 
Okay, more info - using a Recall Potion in step 5 instead of a Magic Mirror will crash the game. However, if you use another Potion of Return in step 5, it will not crash, and will successfully teleport you back to the original world spawn point. Going through the return portal does not crash either, and it seems to put the game back into a stable state as well.
 
Thanks for the report and the detailed steps! Made it very easy to investigate :)
So... turns out there's alot more to this bug than I originally thought, beyond game crashes. I'm still investigating, and will update you later today when I finish a video containing some of the weirder side-effects I've discovered.
 
Alright, so here goes.

Further science has yielded that any object the player can sit / rest on causes a glitch if a Potion of Return is used while on it.

Logically, the first thing I thought to try this with were toilets. Combined with excessive free time, I put together a short video of my more interesting findings. (Plaintext explanations are also included below.)



New steps:
1.) Sit on an object (Edit: Any object, from toilets to benches to Chippy's Couch can cause this.)
2.) Use a Potion of Return
3.) Weird stuff happens (see below for examples)


List of things I tested: (THESE ALL YIELDED THE SAME CRASHLOG, AND ARE NOT INDIVIDUAL BUGS. Merely interesting side effects of the glitch above.)
> Bosses can no longer target you properly
> Pylons don't work
> Using the Rod of Discord crashes the game
> Having Town NPC's come on screen crashes the game
> Zombies start moonwalking in the sky, and jump mid-air.
> Demon Eyes are drunk. Very, very drunk.
> The Zapinator doesn't work. (Isn't it ironic the "glitch gun" doesn't work with the bug active?)
> You can't pick up items
> Using a Summon staff crashes the game (Likely related to the town NPC crash)
> Activating the glitch near a pylon crashes the game
> Drinking a potion of return stops the glitch without crashing (Originally discovered by CongratsIsTrash)
> Using the Magic Conch crashes the game
> Having pre-summons when activating the glitch causes an immediate crash (sometimes)
> Drinking lemonade crashes the game
> Confetti Guns do not work, but are not consumed either, much like the Return potion.
> All enemies instantly despawn, and no new enemies seem to spawn.
> Dart traps don't work.

Let me know if there's anything which is unclear, or needs further elaboration.

EDIT: So, after a bit more observation, I have a technical-ish explanation of why I think this happens.

Upon activating the glitch, the game thinks that the player went to wherever their spawn point is. In the case of the video above at the point with the Eye of Cthulhu, it was at the bed near the toilet. But, if my spawn is at the center of the world, bosses spawn and attack that spawnpoint. That would also explain why monsters despawn if you activate the glitch far from a spawnpoint- the game thinks the player is at the spawn, while the camera and the physical sprites stay in the same place.

This de-sync of player position vs. where the game thinks the player is likely causes the side effects above; and when the game attempts to do something like determine the position of a minion summon, it leads to a crash.
 
Last edited:
Wanna hear another crazy thing that happened to me after doing it? Basically, I did the crash, then I reopened the game and went into the same world that I did the crash in, and there was a bunny gliding through the air towards the end point of its "walking," except it was not animating at all. After landing on the ground, it began acting normally. What seems to make this special is that it happened after I crashed and reentered the game.

EDIT: In the "Eye of Cthulhu being drunk" example in the video, it almost looked like it was targeting the place where you activated the glitch.

EDIT 2: I totally want to try this glitch on Wall of Flesh, absolute mayhem must ensue, or I will be disappointed :naughty:
 
Last edited:
Wanna hear another crazy thing that happened to me after doing it? Basically, I did the crash, then I reopened the game and went into the same world that I did the crash in, and there was a bunny gliding through the air towards the end point of its "walking," except it was not animating at all. After landing on the ground, it began acting normally. What seems to make this special is that it happened after I crashed and reentered the game.

EDIT: In the "Eye of Cthulhu being drunk" example in the video, it almost looked like it was targeting the place where you activated the glitch.

EDIT 2: I totally want to try this glitch on Wall of Flesh, absolute mayhem must ensue, or I will be disappointed :naughty:
I noticed the weirdness with the Eye as well. When I reloaded and tried it again, it started attacking the spawnpoint- while I was still at the Ocean.
 
I noticed the weirdness with the Eye as well. When I reloaded and tried it again, it started attacking the spawnpoint- while I was still at the Ocean.

Oh man, that’s super broken, I definitely wanna try out this glitch some more tomorrow, but I’ve gotta get some sleep... and not use a Potion of Return while in my bed.
 
Ok, so I have only done the glitch a couple times, and I’ve already noticed that if the place where you did the glitch goes offscreen, it will always crash immediately. This seems to be why using Magic Mirror, Rod of Discord, and Magic Conch crashes. (EDIT: I'm definitely wrong with my assumption on this one)

First world wouldn’t load, moving onto a second one.

Tried doing the glitch then summoning Wall of Flesh, game instantly crashed as soon as Wall of Flesh appeared. So, tried it the other way around, and Wall of Flesh worked. Well, he wasn’t firing lasers or burping leeches, but unfortunately his eyes didn’t spazz out and the wall itself didn’t start going backwards or anything. :( Anyway, I dashed into the Hungry with Solar Flare armor, and the game instantly crashed.

Tried doing the glitch and then spawning Eater of Worlds. “Where is the boss?” I use a Potion of Return to cancel the glitch and... Eater of Worlds spawned at spawn! Of course he ran away, but I had a hellavator, so I followed him, and learned something new completely unrelated to the glitch: if Eater of Worlds reaches the Underworld, he instantly despawns, even if you’re onscreen.

Also noticed: it seems like having the solar flare explosions trigger instantly crashes the game, likely because it doesn’t know where to spawn the explosion. This is obviously why dashing into the Hungry crashed. Tried taking off a piece of the Solar Flare armor after doing the glitch, that crashed too.

Okay, so I tried Eater of Worlds again, but this time I made my spawn a Corruption, took off a piece of Solar Flare armor before doing the glitch, and built the glitch machine within screen distance of spawn. Eater of Worlds somehow actually goes for my current position instead of my spawn! However, every time he gets close to me, his head detaches from the rest of the worm, like, pretty far off. As he burrows back into the ground, his head reconnects. Having a Corruption at spawn also made me realize other things. A: enemy spawn distances after doing the glitch are based on your spawn, so you can have enemies spawn on screen if you’re far enough from spawn. Conversely, if you’re far enough from spawn, no enemies can spawn because your area is outside the enemy despawn zone. This seems to be why doing the glitch for you would sometimes instantly despawn all enemies. B: Eater of Souls is drunk too. Eater of Soul vs. Demon Eye drunk fight when?

This might just be Part 1, who knows.

TL;DR This game has committed broke.
 
Last edited:
PART 2 INCOMING

King Slime is nothing special, except for the fact that he targets spawn and his teleports and jump are super desynced. However, I was able to have the glitch machine go offscreen without crashing, so I'm wondering if that's another issue with Solar Flare armor? Anyway, I got on a mount, and the game instantly crashed with that too. Probably related to how using summoning weapons crashes.

I remembered that I had a Mechanical Skull in my Void Vault, so I tried Skeletron Prime too, and... Skeletron Prime was everywhere, he was constantly switching between targeting me and my spawn, when he was spinning he looked like someone getting juked in slow motion, his melee arms seemed to consistently target spawn, while his ranged arms seemed to consistently target me. It's a shame the game crashed out of the blue long before dawn, I would've loved to see Dungeon Guardian Prime.

So I managed to get the Guide to respawn (is he not the first NPC anymore?), and fought Wall of Flesh again, but this time without Solar Flare armor and closer to the spawn. And guess what? I got the eyes to spazz! :) It was a tiny spazz, they just would occasionally fall behind the wall and then snap back into place, but it counts in my book. Wall of Flesh still didn't shoot lasers or burp leeches either. I tried going behind the Wall too, and when the tongue grabbed me, the game crashed.

Minor note, fishing poles don't crash, neither when casting them, nor when reeling in a catch.

Oh man, I just encountered the "third of the world disappears" bug, and I was scared for my worlds, until I realized it was only affecting the world I did the glitch in, and that it disappears once the glitch ends (by leaving or using another Potion of Return).

TL;DR Come on man, this isn't that long, go read it
 
Last edited:
I just came back to this thread and saw the edit on the post with the second video, and thinking about that player vs game desync can basically explain (almost) all of the side effects listed:

  • Bosses don't target you properly because their AI thinks you're at your spawn, and so it targets spawn
  • Pylons don't work because unless their's a pylon near spawn, the game doesn't think you're near a pylon
  • RoD probably crashes because the player-game desync results in the game trying to teleport you to 2 different places at once, which sounds like a big no-no
  • Monsters acting drunk is likely a side effect of their AIs snapping back and forth between attacking the player and attacking spawn
  • My best explanation for why Zapinator doesn't work is that maybe the projectiles are being spawned at the player, but the game doesn't like this and wants them to spawn at spawn, so it compromises by not spawning anything?
  • Items can't be picked up because the game thinks you're at spawn, and so will only pick up items near spawn
  • Summon weapons and mounts crash because the game breaks over where to spawn the minion/mount
  • Drink another Potion of Return stops the glitch because you're no longer sitting and the Potion of Return functions properly, causing the player and game positions to sync up again
  • The crash from drinking Lemonade (and other drinks) probably has to do with the drinking animation trying to play in two places at once, maybe?
  • My best explanation for Confetti Gun not working is the same as Zapinator
  • Enemies instantly despawn when far away because their position is outside the active zone of the spawn, and enemies outside this zone instantly despawn
  • "Dart traps don't work" could mean several situations, but the one I'm thinking you mean is natural dart traps underground with a pressure plate, which probably don't function because the position desync prevents pressure plates from triggering
 
Yes, from what I can tell, the bug at heart is "if you set your spawn with a bed, and then un-set it, potion of return takes you to the bed still instead of spawn." Certain parts of the game figured it out, aaand the Potion of Return did not.
 
Yes, from what I can tell, the bug at heart is "if you set your spawn with a bed, and then un-set it, potion of return takes you to the bed still instead of spawn." Certain parts of the game figured it out, aaand the Potion of Return did not.
It's as simple as using a Return potion while "sitting" on any object. No need for a bed! Though resting in a bed does work, as does sitting on the Terra Toilet, etc.
 
Back
Top Bottom