Ofunniku / dwarftherapist

Automatically exported from code.google.com/p/dwarftherapist
Other
0 stars 0 forks source link

[Linux] [64-bit] DF crashes when labor changes require equipment change #277

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using the mapping posted by Serjndestroy at 
http://code.google.com/p/dwarftherapist/wiki/LinuxVersion, I was able to 
compile and run Dwarf Therapist on 64-bit Ubuntu 10.04 ("Lucid Lynx") and read 
my dwarves' info. I can also make changes to their professions and write those 
changes back, *most* of the time. However, if I change a profession that 
requires the dwarf to change his equipped items (such as mining or woodcutting) 
and then commit, Dwarf Fortress crashes (segmentation fault) the instant I 
unpause the game.

I've tested this on 32-bit Linux using the exact same versions of DF, DT, and 
the memory mapping file, and the crash doesn't happen there. But on 64-bit 
Linux, I get a crash every time I change mining or woodcutting.

What steps will reproduce the problem?
1. Run DF and Dwarf Therapist on 64-bit Linux.
2. Load an existing fort or embark on a new fort. Bring more picks than dwarves 
with ranks in mining, so that there will be at least one unclaimed pick to 
start with.
3. Pause DF, read dwarves into DT.
4. In DT, give the mining job to a dwarf who doesn't have any ranks in mining.
5. Unpause DF. DF immediately segfaults.

I'll attach a DT run.log file of a session showing the segfault.

Original issue reported on code.google.com by robin.m...@gmail.com on 21 Jul 2010 at 7:10

GoogleCodeExporter commented 9 years ago
Here are two run.log files, one from 32-bit Ubuntu Lucid and one from 64-bit 
Ubuntu Lucid. Both are running on the same physical hardware (the 32-bit Ubuntu 
is inside a virtual machine). Both are running the official SDL Linux version 
of DF downloaded from the Bay 12 front page, and in both I did the same set of 
steps:

1) Embark on a new fort.
2) Pause DF, run DT.
3) In DT, choose a dwarf with neither Carpentry nor Wood Cutting. Give him 
Carpentry.
4) Commit pending changes in DT.
5) Unpause DF.
6) Pause DF again.
7) Give the same dwarf Wood Cutting.
8) Commit pending changes in DT.
9) Unpause DF.

At this point, I had no problems on 32-bit DF. 64-bit DF, however, segfaulted 
on me immediately.

Original comment by robin.m...@gmail.com on 21 Jul 2010 at 7:26

Attachments:

GoogleCodeExporter commented 9 years ago
Oops, I put the wrong log files up. Real ones coming in a couple minutes.

Original comment by robin.m...@gmail.com on 21 Jul 2010 at 7:32

GoogleCodeExporter commented 9 years ago
Okay, here are the correct log files. Looking through with a side-by-side 
difference viewer (vimdiff), I don't see any significant difference in what 
Dwarf Therapist is trying to do. However, DF kept running just fine on 32-bit 
Linux when I did this sequence of steps, but the EXACT same sequence of steps 
on 64-bit Linux caused a crash. Same memory mapping file, same version of DF, 
same save file... I eliminated every difference I could find, but one segfaults 
and the other doesn't.

Hope you have better luck than I did at figuring out why this is crashing.

Original comment by robin.m...@gmail.com on 21 Jul 2010 at 7:45

Attachments:

GoogleCodeExporter commented 9 years ago
By compiling Dwarf Therapist as a 32-bit application (which I did by adding 
-m32 to the CFLAGS, CPPFLAGS, and LFLAGS in the Makefile, and also replacing 
-L/usr/lib with -L/usr/lib32 in the Makefile's LIBS variable), this crash has 
stopped happening.

I'm guessing there are places in the Dwarf Therapist code that assume that 
"int" is a 32-bit value, which isn't true in 64-bit land. So they end up 
writing more than they should into Dwarf Fortress's memory, and changing the 
value of some pointer DF uses. Hence the segfault the instant DF unpauses.

At any rate, while the bug is not gone, I've found a workaround that makes DT 
useable for me, so I'm happy. Hopefully this bug report will allow other 64-bit 
Linux users to use DT as well.

Original comment by robin.m...@gmail.com on 27 Jul 2010 at 3:47

GoogleCodeExporter commented 9 years ago

Original comment by treyst...@gmail.com on 13 Oct 2010 at 4:41

GoogleCodeExporter commented 9 years ago
Hey, i could reproduce the bug, and it is indeed a problem with the word size 
on 64bit systems. The ptrace call that is used to write data back to the DF 
memory writes 8 bytes on x86-64, but the code assumed 4 bytes everywhere.

I'm pretty sure it killed my last fortress, because DF segfaulted when saving, 
which pissed me of pretty bad, because that was an awesome location, and I 
guess i can't recreate it anymore... Well, at least it pissed me of so much 
that I stopped playing DF and fiddling around with DT, and I've fixed the bug. 
It's in the attached patch, please test it on a 32bit system, but it seems 
pretty straight forward.

Cheers, Andreas

Original comment by ANeumann...@googlemail.com on 21 Nov 2010 at 7:11

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ehler...@gmail.com on 23 Nov 2010 at 12:05

GoogleCodeExporter commented 9 years ago
Accepted the change, doesn't seem to cause issue on 32-bit systems. Still need 
to verify on a 64-bit system and start 64-bit distribution.  The changeset 
30211af284cc has these changes. 

Original comment by ehler...@gmail.com on 24 Nov 2010 at 12:38