forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Crash:This routine has been entered recursively (-ANSI mode)

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2097
Location: South Pole, Antarctica

PostPosted: Thu May 02, 2019 6:03 am    Post subject: Crash:This routine has been entered recursively (-ANSI mode) Reply with quote

I got this message when implemented slider %sl which calls function SliderFunction. The demo is here, but this demo works fine, itis the main code which crashes
Code:
module mod111
integer kBusySliding
real*8 SliderVariable
CONTAINS
Integer function SliderFunction ()
  if(kBusySliding.eq.1) goto 10000
  kBusySliding = 1
  a=2.3
  Do i=1,5000000
  a=log(exp(a))
  enddo
  print*, a
kBusySliding = 0
10000 continue
SliderFunction=2
end function
end module mod111
!=============================
PROGRAM aaa
use mod111
  kBusySliding = 0
  i=winio@('%60^sl', SliderVariable, 0d0, 1d0, SliderFunction)
end program

Inside this function goes some calculation but seems during mouse movement the slider calls this function hundreds times and way before the calculation inside the function SliderFunction ends. Despite that i implemented for such exact cases the measure (see the trick introducing variable kBusySliding) to prevent any new computations before previous ones complete (and may cause problems due to that), this time the crash happens exactly on the first line of function SliderFunction before doing anything

Questions:
1) How to get rid of this crash? Though i admit that though the compiler is strict and absolutely right, but in this specific case i do not care about possible problems with the recursion, i just do not want it to crash. I will prevent potential collisions myself with kBusySliding trickery which worked perfectly for decades
2) What means -ANSI mode warning in this case ? Good that such warning exists though i do not find it enough verbose to tell me more hints. With -ANSI this program even does not compile, so what for this -ANSI warning was made?

This demo example above works OK both with 64 and 32bits.


Last edited by DanRRight on Thu May 02, 2019 11:02 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6067
Location: Salford, UK

PostPosted: Thu May 02, 2019 8:36 am    Post subject: Reply with quote

Dan

You may need to use a recent version of the ClearWin+ library in order to avoid the recursive element.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2097
Location: South Pole, Antarctica

PostPosted: Thu May 02, 2019 11:01 pm    Post subject: Reply with quote

OOps, i missed your PM. Will try new library, thanks
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2097
Location: South Pole, Antarctica

PostPosted: Fri May 03, 2019 12:54 pm    Post subject: Reply with quote

Still crashing. But sometimes not. Demo above also works fine. I do not know what's to do. Interesting is that using the wheel %dd with %^rd which calls the same function works no problem
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6067
Location: Salford, UK

PostPosted: Fri May 03, 2019 1:26 pm    Post subject: Reply with quote

I would need a sample program that demonstrates the failure before I could comment.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2097
Location: South Pole, Antarctica

PostPosted: Thu Sep 05, 2019 7:28 pm    Post subject: Reply with quote

Was not possible again to extract the demo and keep the bug. It took me a day and the extraction grew and grew till eventually to become not manageable. Plus the bug in demo disappeared.

This will be the lesson to all and myself: over time i added and added and added features and now even simple plotting program became unmanageable. Needs way way too much time to keep it working. Programming has to be like in Lego: small simplest possible block not dependent on one giant module far away. All initiations have to be just nearby.

So my question is : how to trick the compiler and make it to miss this error? Nothing bad will happen. The place where this happen is related to realtime mouse position control in the callback mouse_pos which is called thousands time when mouse moved
Code:
i=winio@('%^og[...]', lx, ly, mouse_pos)

I speculate that some calls are not yet finished while next ones already happening so the mouse_pos could be called recursively. Usually before i included special variable into the first line of mouse_pos which made such congestions not happening by exiting immediately if previous mouse_pos was still running. May be i am wrong but looks like FTN95 became way too picky and now such congested calls become an error just by calling the mouse_pos before it succeed doing any executable statements if previous instance is still running. I have not changed anything in this part during last few years but this part of program started crashing.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6067
Location: Salford, UK

PostPosted: Fri Sep 06, 2019 7:48 am    Post subject: Reply with quote

If a routine is being entered recursively against your wishes then you could put a SAVEd logical variable at the start of it. Set this .TRUE. on the first entry and exit immediately on reentry so that the routine is only executed at the first level.

SUBROUTINE sub(....)
LOGICAL,SAVE:: active
!!DATA statement to initialise active to .FALSE.
IF(active) RETURN
active = .TRUE.
!! Body of subroutine
active = .FALSE.
END SUBROUTINE
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2047
Location: Yateley, Hants, UK

PostPosted: Fri Sep 06, 2019 8:05 am    Post subject: Reply with quote

Or if you don't like SAVE, put it in a COMMON block.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ 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


Powered by phpBB © 2001, 2005 phpBB Group