Search Issue Tracker
Fixed
Fixed in 6000.2.0a8, 7000.0.0a27
Votes
14
Found in
2021.3.42f1
2022.3.41f1
6000.0.14f1
6000.1.0a7
6000.2.0a1
7000.0.0a1
Issue ID
UUM-77728
Regression
No
Crash on UnityMain when opening the Player after building it
Reproduction steps:
1. Open the attached “repro-project“
2. Open the “Assets/SampleScene.unity“ scene
3. Build And Run
4. Observe the Player crashing
Reproducible with: 2021.3.42f1, 2022.3.41f1, 6000.0.14f1
Reproduced on: Windows 10
Not reproducible on: No other environment tested
Note: Player logs mention a corrupted file: "The file 'C:/Users/<…>/UnityProjects/My project (4)/New folder/My project (4)_Data/level0' is corrupted! Remove it and launch unity again! [Position out of bounds!]"
Comments (3)
-
AndrewSkow
Mar 13, 2025 19:20
Thanks AlexVanovix for the additional details. You are correct that this behaviors seems to entirely related to trying to serialize data that is inside a namespace called "System." That is accepted in the Editor but not compatible with the Player hence the crash. We are discussing how best to handle that case to try to avoid crashes. But we wanted to confirm the nature of the bug because it should be relatively easy to workaround it, e.g. by not using "System." for the namespace of classes or structs that you want to serialize.
-
vangogih
Aug 07, 2024 13:10
Some extra details from my side.
Unity crashes only when you try to Instantiate an object with problem script. If you will add this component via AddComponent<T> the crash won't appear.
Providing prefab with component and loading it from Resources also trigger the crash.After importing project to VS and run I got the stacktrace, I hope it helps:
UnityPlayer.dll!DebugStringToFilePostprocessedStacktrace(struct DebugStringToFileData const &)
UnityPlayer.dll!DebugStringToFile(struct DebugStringToFileData const &)
UnityPlayer.dll!CachedReader::OutOfBoundsError(unsigned __int64,unsigned __int64)
UnityPlayer.dll!CachedReader::UpdateReadCache(void *,unsigned __int64)
UnityPlayer.dll!StreamedBinaryRead::TransferSTLStyleArray<struct ArrayOfManagedObjectsTransferer>(struct ArrayOfManagedObjectsTransferer &,enum TransferMetaFlags)
UnityPlayer.dll!Transfer_ManagedObject<StreamedBinaryRead,1>()
UnityPlayer.dll!TransferField_LinearCollection<class SafeBinaryRead>(struct SerializationCommandArguments const &,struct RuntimeSerializationCommandInfo &)
UnityPlayer.dll!ExecuteSerializationCommands<class ConfigSettingsRead>(struct dynamic_array<struct SerializationCommand,0> const &,class ConfigSettingsRead &,class GeneralMonoObject const &)
UnityPlayer.dll!TransferScriptingObject<class StreamedBinaryRead>(class StreamedBinaryRead &,class ScriptingObjectPtr,class ScriptingClassPtr,struct SerializationCache::Data * &)
UnityPlayer.dll!TransferScriptingObject<class StreamedBinaryRead>(class StreamedBinaryRead &,class ScriptingObjectPtr,class ScriptingClassPtr,struct MonoScriptCache const *)
UnityPlayer.dll!SerializableManagedRefTransfer::TransferScriptingObjectWithSerializedRefSupport<class StreamedBinaryRead>(class Object *,class SerializableManagedRef &,class StreamedBinaryRead &)
UnityPlayer.dll!SerializableManagedRefTransfer::Transfer(class Object *,class SerializableManagedRef &,class StreamedBinaryRead &,bool)
UnityPlayer.dll!MonoBehaviour::VirtualRedirectTransfer(class StreamedBinaryRead &)
UnityPlayer.dll!SerializedFile::ReadObject(__int64,enum ObjectCreationMode,bool,class TypeTree const * *,bool *,class Object &,class CacheReaderBase *)
UnityPlayer.dll!SerializedFile::ReadObject(__int64,enum ObjectCreationMode,bool,class TypeTree const * *,bool *,class Object &)
UnityPlayer.dll!PersistentManager::ReadAndActivateObjectThreaded(int,struct SerializedObjectIdentifier const &,class SerializedFile *,bool,bool,enum PersistentManager::LockFlags)
UnityPlayer.dll!PersistentManager::LoadFileCompletelyThreaded(class core::basic_string_ref<char>,__int64 *,int *,int,enum PersistentManager::LoadFlags,class LoadProgress &,enum PersistentManager::LockFlags)
UnityPlayer.dll!LoadSceneOperation::Perform(void)
UnityPlayer.dll!PreloadManager::ProcessSingleOperation(void)
UnityPlayer.dll!PreloadManager::Run(void)
UnityPlayer.dll!PreloadManager::Run(void *)
UnityPlayer.dll!Thread::RunThreadWrapper(void *)
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart() -
AlexVanovix
Aug 07, 2024 10:30
I need to clarify some additional points about the bug that were not included in the description (the information was mentioned but got lost after testers reviewed it):
1. The bug only manifested itself when the namespace of the class with [Serializable] attribute included System. That is, if the namespace was structured like this: namespace System.AnyNameSpace {}
2. This issue occurred only if a class within that namespace was used in a List<MyAnySubSystemNamespaceConcreteClass> SerializableField. In our case, this was a ScriptableObject that used one of such lists.
3. Unity worked perfectly in the Editor, loading all necessary information from the SO. However, once the application was built, it crashed immediately.
4. You can find a project example with instructions here: https://github.com/AlexVanovix/serializationissuedemo. The instructions for running and reproducing the error are also provided there.
5. The bug was found in version 2022.3.38f1, but Unity team`s testers were able to reproduce it in other LTS versions as well.
6. Rider 2023.3.4 was used as the IDE, which did not highlight any code issue. We did not check for warnings in Visual Studio.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Resolution Note:
Fix support for serializing user defined classes and other types that are inside a namespace called "System".