[R] Acces violation ???
Duncan Murdoch
dmurdoch at pair.com
Wed Oct 1 17:24:44 CEST 2003
On Wed, 1 Oct 2003 16:17:42 +0200, "Juan Ramon Gonzalez"
<jrgonzalez at ico.scs.es> wrote :
>Dear R-listers,
>
>I have created a "dll" and I call it from a R function. However R stops and
>shows the message:
>
>"Unhandled exception in Rgui.exe (R.DLL): 0xC0000005: Access Violation"
>
>I get this error in other situations and I solved it verifying that all
>parameters are called fine. (e.g., double precision -> as.double, integer ->
>as.integer,...). I have verify this. Then, I have tried to debug Fortran
>program in order to verify why (or where) function doesn't work.
>Surprisingly the subroutine arrives until the end.
>
>What is happening?
Most likely it's a clash of calling conventions. R uses the "cdecl"
calling convention, which means it expects to clean up the stack after
a call. If your Fortran uses the more common "stdcall" convention, it
will have already removed parameters from the stack. Removing things
twice is bad.
I've got a web page
<http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/> that
gives some advice on writing DLLs for R. It also gives pointers to
the existing documentation in the R manuals, etc.
Duncan Murdoch
More information about the R-help
mailing list