overdue-scratch

Author Topic: Hibernation "fix"  (Read 3468 times)

0 Members and 1 Guest are viewing this topic.

mr_w

  • Entrant
  • Posts: 3
Hibernation "fix"
« on: August 08, 2011, 01:54:10 AM »
Hi guys, I'm here to discuss this ridicolous part of code that is broken by design.

Consider current code of resume.c:

Code: [Select]
allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095);

mem_base = getmemorylimit() - allocSize;//TODO: lower this

printf("mem_base %x\n", mem_base);
// Rek : hibernate fix
if (!((long long)mem_base+allocSize<1024*bootInfo->extmem+0x100000))
{
printf ("Not enough space to restore image. Press any key to proceed with normal boot.\n");
getchar();
return;
}

What does it do?

First, ! (negation) of < makes things more obfuscated than needed. Why not just asking for >= ??

Then, look at this:

mem_base+allocSize<1024*bootInfo->extmem+0x100000

where mem_base is getmemorylimit() - allocSize

if we substitute for mem_base

getmemorylimit() - allocSize + allocSize < 1024*bootInfo->extmem+0x100000

Therefore -allocSize + allocSize makes 0

which ends up with (getmemorylimit() < 1024*bootInfo->extmem+0x100000)

[ notice how we lost allocSize completely, so it doesn't depend on it ]

and this is true in theory, but in practice sometimes fail (my box has 16G of ram).



Please comment on this nonsense, and help understand what feelings did the original author wanted to express??



Slice

  • VoodooLabs
  • Posts: 52
Re: Hibernation "fix"
« Reply #1 on: August 10, 2011, 07:19:47 PM »
I just comment out this part of codes and had working hibernate. But without secure memory settings.
My patches isn't accepted into trunk.

mr_w

  • Entrant
  • Posts: 3
Re: Hibernation "fix"
« Reply #2 on: August 10, 2011, 07:29:22 PM »
Slice,

I have my hibernate working too, but just cutting (and pasting) makes very good spaghetti style code (such as Chameleon is, to some extent). Therefore my request for discussion :)

meklort

  • VoodooLabs
  • Posts: 65
Re: Hibernation "fix"
« Reply #3 on: August 13, 2011, 06:46:04 PM »
I just comment out this part of codes and had working hibernate. But without secure memory settings.
My patches isn't accepted into trunk.

Slice (actually, this goes for anyone), If you want a change in trunk, you have a few options:
1) Create an issue report with the problem + enough information for the developers to verify + fix.
2) Create a diff with the latest revision + submit it. The best way to do this is to use the Issue tracker *or* irc.
3) Right now trunk is under a feature freeze to get it ready for release. What that means is that the project admins (that'd be myself, cosmo1t, zef and Kabyl, currently the most active admins are cosmo1t and myself) want to verify that commits are primarily for bugfixes or to prepare for a release. If you have a *bugfix* patch, we request that you let us know before you commit so that we can either look it over before it goes in trunk to make sure it is something that we feel can go into the trunk. Once the 2.0 release is done, features can be committed to trunk, however we'd still request that we are at least notified before hand. Odds are, if the commit is a small change, we won't review it until after it's in trunk. However, if you are planning on committing large changes, we'd like to review it before hand.

I currently have yet to see a patchfile from you with a request for it to go into trunk. Yes, I have seen you commit to your branch, however I'm not about to comb through it and decide what parts should be merged to trunk. If you want a change in a branch to be merged into trunk, do #2 above. Odds are that I am *not* going to go combing branch commits to look for things that I feel should go in trunk.
return c ? c : !c;

mr_w

  • Entrant
  • Posts: 3
Re: Hibernation "fix"
« Reply #4 on: August 13, 2011, 09:46:03 PM »
@meklort

How does one get commit rights?

cosmo1t

  • VoodooLabs
  • Posts: 25
Re: Hibernation "fix"
« Reply #5 on: August 13, 2011, 11:41:26 PM »
Hi. thats what meklort is saying..

You can have your own branch, no prob. but if you have changes from your branch which you'd like to have merged to the trunk, you must post a ticket w/ a diff to the issue tracker, and at that point message cosmo1t or meklort or zef or kabyl on irc, and we'll look @ the ticket w/ the diff.

We are working on a 2.0 release and in order to accomodate future requests/diffs/issues, we're asking you follow meklorts post on how to request/gain these permissions. The easiest thing to start with, is join irc and message one of us.

Thanks
cosmo