[hatari-devel] Latest Hatari HG version gets stuck sometimes

npomarede at corp.free.fr npomarede at corp.free.fr
Fri Jul 17 00:38:06 CEST 2009


On Thu, 9 Jul 2009, npomarede at corp.free.fr wrote:

> On Thu, 9 Jul 2009, Thomas Huth wrote:
>
>> On Wed, 8 Jul 2009 23:32:19 +0200
>> Thomas Huth <huth at users.berlios.de> wrote:
>>
>>> On Wed, 8 Jul 2009 21:06:15 +0300
>>> Eero Tamminen <eerot at users.berlios.de> wrote:
>>>
>>>> Saving memory state from a freshly booted & idle GEM and then
>>>> restoring it with the --memstate option is 100% sure way to trigger
>>>> the issue for me.
>>>
>>> OK, I can reproduce the problem this way. However, I currently don't
>>> have a clue how to fix it...
>>
>> Phew, just found and fixed this bug. The problem was introduced with
>> changeset f3051bd6f969 where the place of the call to
>> Video_StartInterrupts() was changed in the VBL function.
>> After the change, the VBL function basically looked like this:
>>
>> void Video_InterruptHandler_VBL ( void )
>> {
>> 	Int_AcknowledgeInterrupt();
>> 	...
>> 	ShortCut_ActKey();
>> 	...
>> 	Video_StartInterrupts(PendingCyclesOver);
>> }
>>
>> AcknowledgeInterrupt() disabled the VBL Int in int.c.
>> ShortCut_ActKey() is where we load & save memory snapshots.
>> Video_StartInterrupts() enables the VBL Int in int.c again.
>>
>> So with that order the VBL Int was disabled in the memory snapshots.
>> As long as you used F12 or AltGr+l for loading memory snapshots,
>> this did not matter since StartInterrupts() re-launched the VBL.
>> But as soon as you used the --memstate option, the VBL was never
>> started again.
>>
>> I've fixed the problem now by moving ShortCut_ActKey down, after the
>> Video_StartInterrupts() function call (like it was before the change).
>>
>> Note that this fix only works for new memory snapshots, since the
>> disabled VBL is stored in the file of faulty snapshots.
>>
>> Thomas
>
> Well done, I didn't pay attention to the fact that snapshot was saved in
> the vbl and order mattered in that case.
>
> Nicolas

While trying to fix another demo, I tried to restore a fresh snapshot and 
was lucky enough to get the reported crash problem when restoring it :)

This is with the latest head sources, so with the sequence :

         Video_ClearOnVBL();

         Video_StartInterrupts(PendingCyclesOver);

         ShortCut_ActKey();

I get the same wrong value for LineCycle in ConvertPosition, but this is 
due to a wrong value of nHBL. My value is 53, but this is the first line 
of the VBL, it should be 0 !

Adding
 	fprintf ( stderr, "capt %d\n" , nHBL );

at the end of Video_MemorySnapShot_Capture, I can see that the restored 
value for nHBL is indeed 53. So the problem is in the saved snapshot.

Thomas, do you know how this is possible ? I thought snapshots were 
captured only during the VBL handler, which means nHBL should be 0 and 
saved this way.

In that case, this creates an approx 53*512=27136 cycles offset and all 
following calculations go wrong, leading to a crash because the assert 
will detect a <0 number of cycles when adding an int.

This case is similar to what reported Eero with his crash logs.


Nicolas



More information about the hatari-devel mailing list