Voodooprojects

Chameleon => Bug Reports => Topic started by: madwolf on September 11, 2009, 11:38:13 AM

Title: "header read size 0" bug and FIX :-)
Post by: madwolf on September 11, 2009, 11:38:13 AM
Hello,
I found a bug and fixed it myself, hope you don't mind ;-) but it would be cool if you included the fix for the future releases of Chameleon.
When waking from hibernation some people (including me) experienced messages "header read size 0" and incorrect sleepimage signature. Well it seems that Chameleon was unable to read any file over 4gb in size. So for anyone with 4gb or more memory waking from hibernation didn't work.
There was a bug in libsaio/hfs.c that treated every fileLength as 32bit (long). Attached to my post there is the fixed compiled boot file from Chameleon RC3 and fixed hfs.c (in function ReadFile, the fileLength variable for HFS+ files was cast to long instead of long long).
Works great now :-)
If you're going to incorporate the fix you can give credits to "radekg" :P I rarely use the nick madwolf. Bye.
Title: Re: "header read size 0" bug and FIX :-)
Post by: zef on September 12, 2009, 10:46:28 AM
Hi radekg!

Many thx for the patch, we will review it and hopefully add your changes for a next release! :)

Bye,
zef
Title: Re: "header read size 0" bug and FIX :-)
Post by: Bit Shoveler on September 25, 2009, 08:29:19 AM
Thanks radekg, good catch!

first post :)
Title: Re: "header read size 0" bug and FIX :-)
Post by: zef on October 12, 2009, 10:10:54 AM
@radekg:

Thx for the fix! :) Btw, I used an (uint64_t) cast for the fileLength type instead.
Title: Re: "header read size 0" bug and FIX :-)
Post by: CharredPC on December 12, 2009, 08:38:57 PM
Radekg: 

Since the Chameleon team can't / won't address it, I was wondering if I could get some support on your patch. It's not working for me (either your file or their latest release that includes it). Are you running SL or 10.5.x? Is a 64-bit OS needed to use this? I run retail 10.5.8 and deep sleep (hibernation) works great if I yank out one of my 2GB RAM sticks. Leaving both in (4GB total) it locks up while trying to boot, only giving the single line:

Loaded HFS+ file: [System/Library/CoreServices/System Version.plist]

Any thoughts or ideas?
Title: Re: "header read size 0" bug and FIX :-)
Post by: zef on December 12, 2009, 09:32:35 PM
Since the Chameleon team can't / won't address it, I was wondering if I could get some support on your patch.

I think your issue has nothing to do with the patch posted here. If you take a look at the sources, you will see that there's more changes have been made regarding the sleepimage restoration. I'm trying to setup a test system to learn more about the bug.
Title: Re: "header read size 0" bug and FIX :-)
Post by: CharredPC on December 12, 2009, 10:27:28 PM
Zef:

Thanks for looking into this. I assumed it was this patch as it didn't work originally, and it was reported as included into RC4, which now also doesn't work. Let me know if you need anything tested.
Title: Re: "header read size 0" bug and FIX :-)
Post by: Apex on February 01, 2010, 10:50:40 AM
I am using RC4 which includes your patch. But i am having the lockup issue. The System hangs with the "Loading HFS+ File .... SystemVersion.plist" line after the boot device is selected.
All i can say is, wake-from-disk worked ONE time when i had two harddrives in my system. But i had to remove one harddrive and it stopped working. I am using SL and the 32bit Kernel.

Maybe someone gets a idea why it worked when i had two harddrives.

I'll try to include your patch into PCEFI 10.5 and see how that works.
Title: Re: "header read size 0" bug and FIX :-)
Post by: Apex on February 01, 2010, 11:38:28 AM
Update:

I added this (small) patch to Chameleon RC3. After that, i had the exact same lockup issue. So the lockup is somehow related to this patch. The System freezes after the line "Loading HFS+ File SystemVersion.plist"
Title: Re: "header read size 0" bug and FIX :-)
Post by: MacWen on March 20, 2010, 08:30:18 PM
Hi All,

I fixed another bug (details below) in hfs.c causing (at least on my system) a freeze. I attached an updated boot binary (based on RC4) and the modified source for the VooDoo team.

Bug details: hfs.c, ReadExtent line 892 (see attached modified version, line is commented with // MacWen: ...). The multiplication of GetExtentSize(..) and gBlockSize can cause an overflow. In my case GetExtentSize(..) returned 0x0010.0000 and gBlockSize returned 0x0000.1000 causing a 32 bit overflow (both return long). Casting at least one of them to (long long) turns it into a 64 bit multiplication and voila: a valid readSize.

Happy 4Gb hibernation to you all!

MacWen

 
 
Title: Re: "header read size 0" bug and FIX :-)
Post by: zef on March 21, 2010, 01:25:29 PM
I fixed another bug (details below) in hfs.c causing (at least on my system) a freeze. I attached an updated boot binary (based on RC4) and the modified source for the VooDoo team.

Hi MacWen,

Thanks for the fix, great finding! :)

Just committed to the trunk as well:

http://forge.voodooprojects.org/p/chameleon/source/commit/136/

Bye,
zef
Title: Re: "header read size 0" bug and FIX :-)
Post by: Apex on March 27, 2010, 12:55:39 PM
@ MacWen

Your patch fixed my wake-from-disk-problems. I now can wake-from-disk without problems :)

(i have 4GB Ram)
Title: Re: "header read size 0" bug and FIX :-)
Post by: Goten on April 06, 2010, 10:55:17 PM
hi
please can you explain me how do I use the fix to make works hibernation on my hp-dv5 with 4gb.
I downloaded the boot file and I have replaced the old one, but the message about incorrect image signature still appears.
What's wrong?
How should I use the hfs.c file? Should I copy it to somewhere in my disc?

thanks in advance
 
Title: Re: "header read size 0" bug and FIX :-)
Post by: MacWen on April 07, 2010, 08:23:43 AM
Hi Goten,

My fix addresses the hanging issue as described by Apex above. Your problem "incorrect image signature" is not related to my fix, sorry.

MacWen
Title: Re: "header read size 0" bug and FIX :-)
Post by: Goten on April 17, 2010, 01:46:50 PM
Hi, just a question for those who have hibernation full working.
Normal sleep on my laptop works fine, the problem is the hibernation. even when I set hibernatemode to hibernation only (mode 1) my system continues to go in normal sleep instead of safe sleep and after reboot i get the "header read size 0 & incorrect image signature". But I think that is not a chameleon problem (i use rc5pre8) but the system that doesn't create properly the sleepimage file. In fact when the system goes to hibernation, in theory the disc should load a little time to write the ram status into sleepimage, and then shutdown. This not happens to me. System goes alway in normal sleep, no hard disk load e then perhaps the 4gb sleepimage file in var/vm is actually a fake.

Can you confirm that hard disk load before going to safe sleep?
What do you think about my considerations?

thanks to all
Title: Re: "header read size 0" bug and FIX :-)
Post by: Goten on April 22, 2010, 01:05:35 PM
Ok. I fixed my problem about deep sleep just reinstalling the snow leopard retail and using the boot by MacWen. Now everything works perfectly.
Just only little issue: the system doesn't wake up from normal sleep when is set hibernatemode 3.
The system hangs after resume and then i have to force shutdown. the strange thing is that after restart the system wake normally from the sleepimage that it has created before going to sleep. then the problem is only the wake from normal sleep in mode 3.
No problems instead if i use the hibernate mode to 0 or 1 (only sleep and only hibernation works good)

any ideas?

thanks
Title: Re: "header read size 0" bug and FIX :-)
Post by: imlennox on May 19, 2010, 09:04:53 PM
@ MacWen

This works perfect !!!! I've been suffering from hibernation and RC4's freezing and this solved both at the same time. AWESOME!! Thank you!!!
Title: Re: "header read size 0" bug and FIX :-)
Post by: kismitt on October 15, 2010, 08:40:02 PM
Where do I find the patch?  I'm having the same problem with 4GB of memory.  I can wake up from sleep, but once I reboot the computer I'm stuck at "System/Library/CoreServices/SystemVersion.plist".  It was working perfectly until I upgraded my memory to 4GB.  Currently, running RC4 with 10.6.4