Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exceptions when trying to alter edge fog effects #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

originalfoo
Copy link

@originalfoo originalfoo commented May 25, 2020

An as-yet unidentified mod (too tired to do the digging due to some RL stuff) is causing CTD when 81 Tiles tries to update the edge fog distance in LoadingExtension.cs.

This PR wraps the relevant code in try..catch in an attempt to prevent CTD, and will notifiy users if successful.

An alternate (better?) approach might be to add new mod option to toggle whether fog distance is changed.

========== OUTPUTING STACK TRACE ==================

  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6905EA471)
0x00007FF6905EA471 (Cities) 
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6905F48F1)
0x00007FF6905F48F1 (Cities) 
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6905EB33A)
0x00007FF6905EB33A (Cities) 
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6905EFAE8)
0x00007FF6905EFAE8 (Cities) 
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6907C4207)
0x00007FF6907C4207 (Cities) 
0x000000000845283C (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Object:FindObjectsOfType (System.Type)
0x000000000845275A (Mono JIT Code) UnityEngine.Object:FindObjectOfType (System.Type)
0x0000000008519AD9 (Mono JIT Code) UnityEngine.Object:FindObjectOfType<object> ()
- 0x000000000F86140F (Mono JIT Code) EightyOne.LoadingExtension/<>c:<OnLevelLoaded>b__1_1 ()
0x000000013B40A54A (Mono JIT Code) AsyncAction:Execute ()
0x0000000028491AEB (Mono JIT Code) SimulationManager:SimulationStep ()
0x00000000283DCA9B (Mono JIT Code) SimulationManager:SimulationThread ()
0x000000000619DE8B (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FF902775CDF (mono) mono_set_defaults
0x00007FF9026C8499 (mono) mono_runtime_invoke
0x00007FF9026F38D7 (mono) mono_thread_interruption_request_flag
0x00007FF9027A8955 (mono) unity_mono_reflection_method_get_method
0x00007FF976177BD4 (KERNEL32) BaseThreadInitThunk
0x00007FF97710CE51 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

**** Crash! ****

Some as-yet unidentified mod is causing CTD when 81 Tiles tries to update the edge fog distance. Catching errors in the altered block of code enables the simulation to start in such circumstances.
@bloodypenguin
Copy link
Owner

I don't think that's gonna work this way because you wrap adding of actions in try-catch. The actions themselves will be executed in a separate thread sometime later (where try-catch has no effect)

@meredithdoto
Copy link

meredithdoto commented Apr 19, 2021

Hi. Im having similar problem. When I enable 81Tiles mod map won't load and game crashes

I tried to get help in your mod discussions section but for week nobody answered.

mods.txt
output_log.txt
error.log

@krzychu124
Copy link

@bloodypenguin you are right, it won't fix anything, because Unity FindObjectXYZ methods should not be called from thread different than the main.
Most of the times it will cause CTD and obviously "fix" with "try...catch" won't help here, because exception will come from unmanaged side of the game engine.

I see only one way to fix it: precache objects before creating an action.
I'm just curious, looking at the code, do you really need three actions?
I think that the one combined should do the trick 😉 Calling one by one will just queue 3 actions, then execute in the same order, so the result should be pretty much the same as single action with three assignments but... game reads those values from the main thread so double 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants