[fpc-devel] Need patch for bugs : 0011503 / 0009472
Vincent Snijders
vsnijders at quicknet.nl
Thu Jun 19 14:44:18 CEST 2008
Michael Van Canneyt schreef:
>
> On Thu, 19 Jun 2008, Boian Mitov wrote:
>
>> Here is a code sniped that sows just one example of the problem:
>>
>> This is a very simple example of how important the order really is:
>> We have even more crucial problems related with this. This is just a simple
>> one:
>>
>> destructor TALBasicAudioOut.Destroy();
>> var
>> WriteLock : IOWLockSection;
>>
>> begin
>> WriteLock := FLock.StopLock();
>>
>> FInputPin.Free();
>> FEnablePin.Free();
>> FMasterPumping.Free();
>> WriteLock := NIL;
>> FLock.Free();
>> inherited;
>> end;
>>
>> You can see that the WriteLock MUST be released before the FLock.Free();,
>
> Maybe Jonas or Florian can comment on this.
When you said function blocks, it made me think of nested procedures.
So I think you write it like:
destructor TALBasicAudioOut.Destroy();
procedure DoWriteProtectedThings;
var
WriteLock : IOWLockSection;
begin
WriteLock := FLock.StopLock();
FInputPin.Free();
FEnablePin.Free();
FMasterPumping.Free();
end;
begin
DoWriteProtectedThings;
FLock.Free();
inherited;
end;
Then you have made it clear that after WriteLock has to be cleared
before freeing the lock. Of course it still fails if a periodic mark and
sweep would be used by the compiler.
Vincent
More information about the fpc-devel
mailing list