Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Can this code make a stack overflow?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
P_Santos

Bascom Member



Joined: 07 Jul 2011
Posts: 114

PostPosted: Thu Apr 28, 2016 2:44 pm    Post subject: Can this code make a stack overflow? Reply with quote

Hello,

Need know if this code is a problem for stack overflow?

_start:
If _counter >= 14 Then
Incr Temp
If Var1 <> 0 Then
Incr Var2
If Var3 <> 200 Then Goto _start 'jump out of a, if structure!!
End If
End If


Best regards
Pedro

(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1161
Location: France

france.gif
PostPosted: Thu Apr 28, 2016 7:06 pm    Post subject: Reply with quote

Hi,
I did'nt test it but this code will give a overflow for the variables because it seems to be a loop without exit
you dont make any control of the increasing

ex : if you use byte the var temp will go to 255 then 0 and so on

JP
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Apr 28, 2016 7:15 pm    Post subject: Reply with quote

no that can not result in a stack overflow.

a problem is something like this:

main:
gosub abc


abc:
goto main
return

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Apr 28, 2016 7:15 pm    Post subject: Reply with quote

no that can not result in a stack overflow.

a problem is something like this:

main:
gosub abc


abc:
goto main
return

_________________
Mark
Back to top
View user's profile Visit poster's website
toto







PostPosted: Fri Apr 29, 2016 12:03 am    Post subject: Reply with quote

Thank you both

Best regards
Toto
Back to top
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum