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

Crash clicking "Optimize" #3822

Closed
lpgagnon opened this issue Dec 16, 2023 · 9 comments · Fixed by #3889
Closed

Crash clicking "Optimize" #3822

lpgagnon opened this issue Dec 16, 2023 · 9 comments · Fixed by #3889

Comments

@lpgagnon
Copy link

first attempt to use the optimizer in post-hotfix Jordan did not go well. Getting a reproducible crash; journal attached.

context: vessel just reached LEO; plotted maneuver for transfer to Mercury intercept, saved, clicked Optimize to see what it would do. crash to desktop, with principia assertion failure:

F1215 20:25:12.957080 3736604672 interface_body.hpp:565] Unexpected extension 992685744

restarted game, loaded same save, click Optimize: same result, 100% reproducible, making a journal easy to produce.

journal & log files, 29MB zip

@pleroy
Copy link
Member

pleroy commented Dec 16, 2023

On the face of it, it looks like it's accessing some random piece of memory. I could imagine a confusion regarding passing values vs. references across the C#/C++ boundary, but then it works on Windows. I wonder if it is specific to macOS. @rnlahaye Have you ever tried pressing the Optimize button?

@rnlahaye
Copy link
Contributor

I have not tried it yet. I will do so and see what happens.

@rnlahaye
Copy link
Contributor

Tried it; no crashes.

@lpgagnon
Copy link
Author

fwiw, it wasn't a one-off; different vessel, different target (earth->moon), same crash.

new journal, maybe having two to compare will help

it does have the look of random data, the "extension" keeps changing.
F1216 20:05:32.158290 3166703616 interface_body.hpp:565] Unexpected extension -91866624
F1216 19:59:21.077450 3993833472 interface_body.hpp:565] Unexpected extension 465795056

@pleroy
Copy link
Member

pleroy commented Feb 11, 2024

@rnlahaye This is going to be a strange request: how do you build Principia on macOS? @eggrobin recently purchased a mac mini 2023 with an M2 for other reasons, and when trying for 10 minutes to build Principia on that machine we have tons of errors related to ARM vs. Intel inconsistencies. If you have a recipe that works, we'd appreciate if you could share it. (In case you wonder, for releasing we build on Azure pipelines where the underlying machine is an x64.)

@lpgagnon What machine do you have? Is it ARM-based? It doesn't seem impossible that the bug would actually depend on the hardware/ABI.

@rnlahaye
Copy link
Contributor

You need to update your fork of Abseil to include this commit (otherwise you encounter this bug).

@lpgagnon
Copy link
Author

@lpgagnon What machine do you have? Is it ARM-based? It doesn't seem impossible that the bug would actually depend on the hardware/ABI.

M2 2022 macbook air

@pleroy
Copy link
Member

pleroy commented Feb 11, 2024

Thank you for helping us help you help us all... 🟠🔵

We reproduced the bug on an M2. It happens that NavigationFrameParameters is a class in the C# code, but is passed to C++ as if it was a vanilla struct, without a marshaller, by value and not by reference. How/why this ever works is now the mysterious part. We believe that a marshaller is needed for interchange. This will require some surgery in the hairy code that generates C#/C++ interface code from protocol buffer reflection 🤪.

@pleroy
Copy link
Member

pleroy commented Mar 5, 2024

Still not working:

[EXC 21:43:34.589] MarshalDirectiveException: Type principia.ksp_plugin_adapter.NavigationFrameParameters which is passed to unmanaged code must have a StructLayout attribute.
	principia.ksp_plugin_adapter.PrincipiaPluginAdapter.RenderGuidance (Vessel active_vessel) (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	principia.ksp_plugin_adapter.PrincipiaPluginAdapter.RenderNavball (Vessel active_vessel) (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	principia.ksp_plugin_adapter.PrincipiaPluginAdapter.LateUpdate () (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
[EXC 21:43:34.620] MarshalDirectiveException: Type principia.ksp_plugin_adapter.NavigationFrameParameters which is passed to unmanaged code must have a StructLayout attribute.
	principia.ksp_plugin_adapter.FlightPlanner.UpdateVesselAndBurnEditors () (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	principia.ksp_plugin_adapter.FlightPlanner.RenderWindowContents (System.Int32 window_id) (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	principia.ksp_plugin_adapter.SupervisedWindowRenderer.RenderWindow (System.Int32 window_id) (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	principia.ksp_plugin_adapter.BaseWindowRenderer.RenderWindowAndRecordTooltip (System.Int32 window_id) (at <079070d7a7c74e4d9b99ab1fac6b7ef0>:0)
	UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at <58f888e0d56a4620958c8e58a768c70d>:0)
	UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at <58f888e0d56a4620958c8e58a768c70d>:0)

Presumably the structs that contain a NavigationFrameParameters should be classes and have a marshaler. This includes Burn and NavigationManoeuvre.

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 a pull request may close this issue.

3 participants