Search Issue Tracker
Fixed in 2022.3.8f1, 2023.1.10f1, 2024.1.0a1
IL2CPP Player crashes when there aren't enough Thread Static Slots
There are currently no reproduction steps
Reproducible with: 2022.2.12f1
Reproducible on: Windows 10
1. What happened:
I've been debugging a crash issue for our game that occurs on IL2CPP on Windows and to cut a long winding road short I've discovered that the solution to the problem is to double the size of `kMaxThreadStaticSlots` in `Thread.cpp` from 2048 to 4096. This seems to allow our game to successfully run.
2. How can we reproduce it using the example you attached:
I spoke to Joshua Peterson and he requested I submit a bug report. The project is too big to submit here. Contact us if you require the project to repro, but it is an accepted short-coming if not a bug.
Joshua Peterson wrote:
Thanks for raising this issue! The problem here is that the libil2cpp runtime can hold thread static data for a limited number of types, currently 2048. So far this is the first case we know of where this limitation is a problem. We certainly could look to grow that limitation as necessary, but that comes with some performance costs (hence the hard-coded limitation).
I'm curious about the conditions under which this happens in your case. You mentioned full generic sharing in the subject of this message, does that setting impact this problem?
Regarding a solution, you can locally modify the code to increase this value to 4096. The result will be an increase in memory usage, but that will only be the additional 2048 entries times the size of a pointer, so 2048 * 8 bytes on 64-bit architectures. You can make this change in the code that ships with the Unity editor. Is that something you can scale across your developers, so they all have access to it, at least temporarily?
Longer term, we need to either increase this limit or come up with a solution to grow it that has good performance characteristics. For this, can you submit a bug report? That will be the best way for us to track the issue and provide feedback to you about it.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- PlayerLoop.SetPlayerLoop() function is ignored when playing game in Player
- Lighting data is carried over from one Scene to another when changing Scenes in the Play Mode
- The <sprite> tag inserted image from a Sprite Asset into the UI Builder Button disappears when the Inlined Style Text Shadow Horizontal or Vertical Offset is set to be more than 0 px
- Build fails when building with ILCPP Scripting Backend and ARMv7 as the Target Architecture
- Textures turn black in Player when they are referenced by a script instance