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 

Randomly Occurring Crash?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Fri Sep 23, 2011 4:17 am    Post subject: Randomly Occurring Crash? Reply with quote

Hello,

I regularly recieve the following exception message:
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x70b53757, on thread 0x864. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

I usually recieve it after calling the same FORTRAN subroutine again after just having called it.

How can I prevent this crash from occurring and was it causing it?

Thanks,
Alex.
Back to top
View user's profile Send private message MSN Messenger
Robert



Joined: 29 Nov 2006
Posts: 444
Location: Manchester

PostPosted: Mon Oct 10, 2011 8:38 am    Post subject: Reply with quote

0xc0000005 is an access violation and quite often means that a null pointer has been referenced. Presumably you are calling FTN95 that has been compiled with the /CLR flag?
Back to top
View user's profile Send private message Visit poster's website
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Thu Oct 13, 2011 1:47 am    Post subject: Reply with quote

I cannot see the /CLR flag in my compiler options for the FORTRAN project so I do not think I am compiling it with that flag, where is it set for the FORTRAN project?
Back to top
View user's profile Send private message MSN Messenger
PaulLaidler
Site Admin


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

PostPosted: Thu Oct 13, 2011 7:39 am    Post subject: Reply with quote

If you are compiling for .NET then the IDE will add /CLR to the FTN95 command line. Both Plato and Visual Studio provide build logs that log the compiler command line that was applied by the IDE. To the user this is displayed as a .NET configuration (release, debug or checkmate) in a toolbar combo box.
Back to top
View user's profile Send private message AIM Address
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Sat Oct 15, 2011 1:19 pm    Post subject: Reply with quote

Yeah I am compiling the fortran code to a .NET assembly which is called from a .NET WPF application. Is there anything I might be doing in fortran code that would cause these access violations?
Back to top
View user's profile Send private message MSN Messenger
PaulLaidler
Site Admin


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

PostPosted: Sun Oct 16, 2011 9:38 am    Post subject: Reply with quote

To start with you should compile using checkmate and use the debugger to run to the point where the failure occurs.
Back to top
View user's profile Send private message AIM Address
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Mon Oct 24, 2011 3:18 am    Post subject: Reply with quote

Hey,

Sorry for the late reply but after using CheckMate to debug the FORTRAN I noticed the crash seemed to be occurring more consistantly, mainly on lines of code where virtual files were being written to. So I commented out these lines as they were not vital.

However I am still getting the same randomly occurring crash except more frequently now, and the main problem is that it tell me the source involved with the crash is not available so I think it is occurring in an external dll somewhere, possibly one of the silverfrost DLLs.

Also I am now getting this error message popping up after the crash:
An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll

Im not sure if the above may have something to do with the failure of showing the source related to the crash.

So what else could be causing this? Also the code calling the fortran involves multiple threads, I noticed some compiler options relating to threading, however I am unsure as to what they do.

Thanks,
Alex.
Back to top
View user's profile Send private message MSN Messenger
PaulLaidler
Site Admin


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

PostPosted: Mon Oct 24, 2011 8:07 am    Post subject: Reply with quote

Two points:

1) Is the Fortran code standard conforming? If it is, try testing under Win32 rather than .NET. This might help identify the problem.

2) Can you identify the last call in the Fortran code that leads to the exception. If you can, are the arguments for the call valid?
Back to top
View user's profile Send private message AIM Address
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Tue Nov 29, 2011 6:30 am    Post subject: Reply with quote

Hey,

I have narrowed down this crash after spending more time on the FORTRAN module of my program. The FORTRAN seems to be randomly loosing pointers to .Net functions while waiting for the return value... So I think the reason it is occurring randomly is because the garbage collector is destroying what ever the FORTRAN is pointing to before the FORTRAN can get the result.

So does this sound about right? What could be causing this behaviour? How could I fix it?

Thanks,
Alex.
Back to top
View user's profile Send private message MSN Messenger
PaulLaidler
Site Admin


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

PostPosted: Tue Nov 29, 2011 9:35 am    Post subject: Reply with quote

If your Fortran points to a .NET object created in C# say, then DBK_LINK may not lock down the .NET object for you. In other words the garbage collector could mess things up for you.

You can use LOC in the Fortran to monitor the address whilst monitoring the same address in the C#. This will tell you if there is a problem here.

If there is a problem then you will need to lock down the pointer in the C# so that garbage collection does not kick in.
Back to top
View user's profile Send private message AIM Address
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Tue Nov 29, 2011 9:47 am    Post subject: Reply with quote

What is LOC?
Back to top
View user's profile Send private message MSN Messenger
PaulLaidler
Site Admin


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

PostPosted: Tue Nov 29, 2011 10:21 am    Post subject: Reply with quote

LOC is an FTN95 intrinsic function that gives the address of the argument.

real x
integer addr
addr = LOC(x)
Back to top
View user's profile Send private message AIM Address
alex21



Joined: 20 Apr 2011
Posts: 75
Location: Australia

PostPosted: Wed Nov 30, 2011 6:52 am    Post subject: Reply with quote

Here is a stackoverflow question I created on this issue because I can't figure out whether it is Silverfrost related or just a generic unmanaged code problem. There is more information on my issue in this question.

http://stackoverflow.com/questions/8321679/wpf-exception-being-thrown-after-execution-of-unmanaged-code
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support 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