Mac and certain Ubuntu Crashing with my mods

Started by Kiame, November 29, 2017, 03:04:03 AM

Previous topic - Next topic

Kiame

Wanted to know if anyone might have some insight into what could be cause at least two of my mods causing Macs and certain Ubuntu installs to crash when the game is loading.

The two mods are Change Dresser and Textile Storage

I've tried to reproduce the issue on an old laptop where i installed Ubuntu and was able to load the mods without an issue; i do not have a mac. Users have said on macs they just had Change Dresser enabled and it caused the crash. Change Dresser was working for them in A17.

My first thought was windows new lines in the xml files so i went through and made sure they were using only linux line endings \n but that did not fix it.

Thanks!

Kiame

So working on another project it was discovered i was compiling in C# 7 instead of C# 5. I was using "?." as I love it... Asking any Mac users who were having problems with ChangeDresser to try it again and see if it works now that i've gone to C# 5.

Kiame

Update on this issue. Changing to C# 5.0 didnt appear to fix anything. The games will crash. Some can make it further into the load process though. No logs are created.

kaptain_kavern

The only Linux/Mac user specific bug I've encountered was related to the capitalization of files name. Putting a capital letter as the first letter for all my XML files fixed it by then.

Sorry if it doesn't help that much. It was my only experience related to something similar.

Good bug hunting :p

2.71828

I just tried the new version on 64 bit Linux (Arch Linux, to be precise), but Rimworld still crashed as soon as I closed the error log that appears just after Rimworld is done loading up. Rimworld starts up without any problems if I leave your mod out (while having almost 200 other mods active...). I'm sorry your fix didn't work, but I'm glad that you're trying to fix it.

On another note, as you wrote that your mod works for you with your old laptop running Ubuntu: Is that a 32 bit system? Could this be somehow tied to 64 bit Linux instead of Linux in general? I'm just asking since Rimworld B18 doesn't seem to work with 64 bit Linux in general at the moment (although it normally still starts up and you can play for a few seconds or longer; see here), so I thought these problems might be related. Maybe it's a Unity/Rimworld bug or something?

Kiame

I think I found the problem.


    [HarmonyPatch(typeof(Window), "PreClose")]
    static class Patch_Window_PreClose
    {
        // Before closing any window
        static void Postfix(Window __instance)
        {
            Type type = __instance.GetType();
            if (type == typeof(Dialog_Trade))
            {
                TradeUtil.ReclaimApparel();
            }
        }
    }


I was using this method to tell me when a trade window closes. For some still unknown reason this harmony patch will cause Mac and Linux games to crash hard. Even just a stubbed version - no code in the method - will cause the crash. As soon as I removed this method it works.

As a work around I went to:

    [HarmonyPatch(typeof(Dialog_Trade), "Close")]
    static class Patch_Window_PreClose
    {
        static void Postfix(bool doCloseSound)
        {
            TradeUtil.ReclaimApparel();
        }
    }


No more crashes. Only problem is this does not catch the case where the user uses "esc" to close the trade window.

2.71828

Do you think this is a bug in Harmony? I certainly don't want to tell you how to develop your mod, especially because I'm no programmer, but maybe you should post a bug report on Github for this? I don't think that you should have to work around this if it works as is on Windows. After all, Harmony is supposed to work on Linux and Mac as well as on Windows, so I'd bet Andreas Pardeike would appreciate a bug report.

Thank you for fixing this for now, though. As I have written in another thread: No crashes on startup anymore!

Kiame

That is a good point. I was thinking it was a difference with how mono executes/compiles on Mac/Linux. It wouldn't hurt to file a bug report though.

lashtear

Sorry for thread necromancy, but I've encountered similar issues with other mods using Harmony to patching things and then crashing on Linux.

I found http://www.mono-project.com/docs/debug+profile/debug/#debugging-with-gdb to be quite helpful for getting slightly more useful data out of gdb in these situations.  No logs are generated because the mono vm itself crashes hard, often with SIGILL.

I recommend attaching to the already-started process with gdb (e.g. gdb /path/to/executable pidnumber) or launching from within gdb.  For example, on debian/ubuntu/etc systems with the pidof command:


$ p=$(pidof RimWorldLinux.x86_64); gdb /proc/$p/exe $p


will launch you into an interactive debugging session on the currently running game (and freeze it).  To continue, then do:


(gdb) handle SIGXCPU SIG33 SIG35 SIG36 SIGPWR SIGSEGV nostop noprint pass
(gdb) cont


and the game will proceed until you crash/exit/etc.  The page I linked points out some handy gdb scripts for using the existing mono function for stack introspection: mono_mpip(void*).  Using their example gdb script for unwinding the stack and showing recognizable mono frames,


define mono_backtrace
select-frame 0
set $i = 0
while ($i < $arg0)
   set $foo = (char*) mono_pmip ($pc)
   if ($foo)
     printf "#%d  %p in%s\n", $i, $pc, $foo
   else
     frame
   end
   up-silently
   set $i = $i + 1
end
end


Then we can do things like


Thread 1 "RimWorldLinux.x" received signal SIGILL, Illegal instruction.
0x00000000404cf233 in ?? ()
(gdb) bt
#0  0x00000000404cf233 in  ()
#1  0x00007fffbc035f75 in  ()
#2  0x00007ffeeecdca00 in  ()
#3  0x00000000404cf220 in  ()
#4  0x00007fffffffa860 in  ()
#5  0x0000000040811454 in  ()
#6  0x00007fff3f726ee0 in  ()
#7  0x000000004063745e in  ()
#8  0x00007fff3c402708 in  ()
#9  0x00007fff4cd1f3c0 in  ()
#10 0x00000000026dbcb1 in  ()
#11 0x00007ffff7fcba60 in  ()
#12 0x00007fff42383200 in  ()
#13 0x0000000040810eb1 in  ()
#14 0x0000000000000000 in  ()
(gdb) mono_backtrace 14
#0  0x00000000404cf233 in ?? ()
#1  0x7fffbc035f75 in (wrapper dynamic-method) Verse.AI.MentalState:PostStart_Patch1 (object,string) + 0x15 (0x7fffbc035f60 0x7fffbc035f7a) [0x7fffefba4d48 - Unity Root Domain]
#2  0x00007ffeeecdca00 in ?? ()
#3  0x404cf220 in Verse.AI.MentalState:PostStart (string) + 0x0 (0x404cf220 0x404cf229) [0x7fffefba4d48 - Unity Root Domain]
#4  0x00007fffffffa860 in ?? ()
#5  0x40811454 in Verse.AI.MentalStateHandler:TryStartMentalState (Verse.MentalStateDef,string,bool,bool,Verse.Pawn) + 0x4b4 (0x40810fa0 0x4081175f) [0x7fffefba4d48 - Unity Root Domain]
#6  0x00007fff3f726ee0 in ?? ()
#7  0x4063745e in Verse.Game:GetComponent<object> () + 0xae (0x406373b0 0x406374ec) [0x7fffefba4d48 - Unity Root Domain]
#8  0x00007fff3c402708 in ?? ()
#9  0x00007fff4cd1f3c0 in ?? ()
#10 0x00000000026dbcb1 in ?? ()
#11 0x00007ffff7fcba60 in ?? ()
#12 0x00007fff42383200 in ?? ()
#13  0x40810eb1 in RimWorld.LordToil_PanicFlee:Init () + 0xb1 (0x40810e00 0x40810ee2) [0x7fffefba4d48 - Unity Root Domain]


I suspect this is a problem with Harmony, how Harmony is being used, Mono, or all of the above.

Roolo

I also had this problem with RunAndGun when I tried patching the MentalState.PostStart method, and solved it like you did, by looking for another class to inject to. The hint given by lashtear helped me finding the patch that caused the crash, so thanks for that lashtear.

Like in your case, the method I patched was a virtual method implemented by a subclass. Apparently, patching such methods can cause crashes on certain Unix systems. I'll report this to the creator of Harmony.