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 

How to debug a ClearWin+ call?

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



Joined: 05 Jul 2006
Posts: 197

PostPosted: Sat Jul 24, 2021 8:59 pm    Post subject: How to debug a ClearWin+ call? Reply with quote

I have a large program running with ClearWin+ that seems to run ok until I quit the program, and then I receive the following error message:

Quote:
The instruction at address 1008d26b attempted to write to location f0f0f0f0

1008d253 increment_var(void)#70 [+0018]
1004ef76 call_function(<ptr>(func()ÄreturningÄint),<ptr>char,<ptr>void,enumÄlogical,enum [+0193]
100386f6 __yield_program_control [+0013]
1005de20 __temporary_yield [+0016]
100cc7d3 __winio [+203b]
GUI!WINDOW_END - in file gui.f95 at line 690 [+002c]
CPT_INTERFACE!TITLE_PAGE - in file cpt_interface.f95 at line 166 [+051d]
MAIN - in file cpt.f95 at line 29 [+0035]


I am compiling using /FULL_DEBUG /BOUNDS_CHECK /DCLVAR and /CHECK_WINIO, but get a similar error message without those options. The last line of my code that is mentioned in the above (i.e., in file gui.f95 at line 690) is the following:

Code:
iw = winio$('')


which I use simply to end a sequence of winio@ calls. My code is about 100,000 lines, but I get this error even if I just start up the program, which generates a window with a few menu items, and then immediately exit.

I have little clue how to proceed further with identifying this problem. Any advice on how to try to locate the problem would be greatly appreciated.


Last edited by simon on Sun Jul 25, 2021 11:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Sat Jul 24, 2021 9:38 pm    Post subject: Reply with quote

1) try first /UNDEF. Now undefined variables in GUI may cause troubles and can be immediately revealed. Which is good. Before they were causing troubles and you never knew what it was. Then

2) end the GUI instead of your line you posted above with
iw=winio@('%hw'), ihw)
where ihw - has to be declared as integer (7) ihw

and see wheat will happen.

3) end the GUI again instead of same line you posted with

iw=winio@('%lw'), ilw)

where ilw - has to be declared as integer and see wheat will happen. Will it crash immediately as you start GUI?


Last edited by DanRRight on Sat Jul 24, 2021 9:48 pm; edited 4 times in total
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1012
Location: Morrison, CO, USA

PostPosted: Sat Jul 24, 2021 9:41 pm    Post subject: Reply with quote

The crashes at window closure are the tough ones to find.

Posting the winio@() statements and some explanation of the variables might help, unless the window is too complex.

Things that might be happening:

There is a variable attached to a window (for control) that was created on the stack (not /SAVE) and now that location contains this bit pattern as its address.

Using the %cc (with or without the grave modifier), there is some construct that was closed before you referenced it as part of the window closure. This asynchronous behavior is tough to find sometimes; might not always happen.

Just some thoughts.
Back to top
View user's profile Send private message Visit poster's website
DanRRight



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

PostPosted: Sat Jul 24, 2021 9:44 pm    Post subject: Reply with quote

4) and yes, Bill above mentioned SAVE. Try to add SAVE statement inside GUI subroutine as last one among all other declarations in the header, just one word: SAVE

This should not affect anything in other code since looks like you have GUI.f95 as separate sub

If all above home medicine will not do any cure, you have to ask the doctor Paul Smile

Also mecej4 likes all crashes with their specific hex addresses. For true fortraneers a day without crashes is just a wasted day. Smile They will quickly find the problem, the 690 lines code is just for one tooth to chew. At the end you can make a smaller demo from it, it is doable. Unlike I have one similar crash problem in one of 6000 lines GUIs, that is the real trouble to reduce, good i found workaround

5) By the way, can you try to run your code via command

SDBG YOURPROGRAM.EXE

Will it crash? Mine stops crashing, hiding the possible bug, making debugging even more difficult
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Jul 25, 2021 7:14 am    Post subject: Reply with quote

Simon

ClearWin+ makes a call to increment_var in response to a user call to the INC standard callback.

Hopefully you are using INC in your code. If you are then as a first step try using the SAVE attribute with the corresponding variable.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 197

PostPosted: Sun Jul 25, 2021 11:49 pm    Post subject: Reply with quote

MANY thanks for all these responses. My code is 100,000 lines, hence I have not yet made the effort to isolate a small example!

But Paul's suggestion to look at 'INC' is just what I needed. The program only started crashing once I had included some 'INC' statements somewhere else and that are used in the creation of this complex window. I will try SAVE as a workaround until I can isolate the offending incremented variable.

Given DanRRight's observation about crashes and wasted days, I will try to remind myself that my work must be exceptionally worthwhile!
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 197

PostPosted: Tue Jul 27, 2021 6:26 am    Post subject: Reply with quote

Solved! My subroutine receives a variable to increment as an optional argument, but I neglected to check whether it was present in one special case and so the specific call to winio@ had a spurious 'INC' callback function. That problem only occurred when I tried to quit the program using an accelerator key.

Many thanks again for all the helpful suggestions.
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Tue Jul 27, 2021 6:36 am    Post subject: Reply with quote

Simon,
Can you or anyone else show any good example of INC use worth of applying it?
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 197

PostPosted: Tue Jul 27, 2021 3:12 pm    Post subject: Reply with quote

Hi Dan,
I cannot easily extract some code, but I use INC for the following in my program for a couple of things:
1. Counting how many times. or simply just checking, whether a menu item has been activated, which I later use primarily to save a record of what program options and settings the user has decided to use;
2. As an alternative to using %dd - I recall having some difficulties with %dd a long time back, and decided to use INC instead, but that may be redundant now.
There are quite a few built-in callback functions that I have never used, but I would never suggest removing them unless they were a maintenance headache for Paul!
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