[Gambas-user] wait and stack overflow
olinux
olinux at ...289...
Sat Oct 28 11:06:41 CEST 2006
I have a possible start of answer...
here is the complete code:
public sub launchrst(......)
for i= 0 to fildir.count-1
prc=exec ["gtar", "-xvf","fichier source","-C", repdest,fichierextract[i]] for read as "rest"
while prc.state = 1
wait
wend
next
endsub
public sub rest_Read()
dim sline as string
line input #last, sline
.....
....
print sline <================here is the start of answer
end
if i put a print in the read subroutine, all work fine
if i don't put a print here, stack overflow is generated about 1200 read events
this work with print to the console or print to a file opened.
an idee ??????
regards
Olivier Coquet
olinux a écrit :
> here is the precise exemple:
>
> for i= 0 to fildir.count-1
> prc=exec ["gtar", "-xvf","fichier source","-C", repdest,fichierextract[i]] for read as "rest"
>
> while prc.state = 1
> wait
> wend
> next
>
>
>
> version gambas 1.9.44
>
>
> regards
> Olivier Coquet
>
>
>
> Benoit Minisini a écrit :
>
>> On Friday 27 October 2006 21:18, Rob wrote:
>>
>>
>>> On Friday 27 October 2006 14:11, olinux wrote:
>>>
>>>
>>>> Is somebody can explain me why:
>>>> while toto<>0
>>>> wait
>>>> whend
>>>> generate a stack overflow ????
>>>>
>>>>
>>> Because it's an infinite loop and every time the "wait" executes,
>>> the interpreter adds a context to the stack. So if it's in some
>>> event handler that gets called during the wait, e.g. in a timer,
>>> you end up with 25,000 copies of that event handler on the
>>> stack.
>>>
>>> Can't really be any more specific without seeing the project.
>>>
>>> Rob
>>>
>>>
>>>
>> This loop works without any problem, unless there *is* an infinite recursion.
>> That means that WAIT calls an event handler that calls your loop again. Just
>> trace your program to detect it.
>>
>> If this is not the case, then it is a bug in the interpreter. Just tell your
>> version of gambas you use then.
>>
>> Regards,
>>
>>
>>
>
>
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.17/505 - Release Date: 27/10/2006
More information about the User
mailing list