Hi All, I'm building a package using C/C++ and Fortran code which usually runs fine. However I do get occasional bus errors around the time of exiting one of the C functions. Where do I need to be looking to solve this problem? Do bus errors stem from unmapped memory exceptions? How can I find out if that is what is happening while running R? Any hints greatly appreciated. Best, ingmar visser
These normally occur (at that point) from having written off one end of an array. (If you are using .C/.Fortran, they try to copy back the arguments.) Compiling with bounds checking turned on can help, at least with Fortran. On Wed, 12 May 2004, Ingmar Visser wrote:> I'm building a package using C/C++ and Fortran code which usually runs fine. > However I do get occasional bus errors around the time of exiting one of the > C functions. > > Where do I need to be looking to solve this problem? > Do bus errors stem from unmapped memory exceptions? How can I find out if > that is what is happening while running R?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dear Prof Ripley, Thanks for your answer. On 5/12/04 2:52 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote:> These normally occur (at that point) from having written off one end of an > array. (If you are using .C/.Fortran, they try to copy back the > arguments.) Compiling with bounds checking turned on can help, at least > with Fortran.Can I invoke compile options if/when I use R cmd install etc. to install packages? The situation is this: I pass arguments from R to C, then most of these are passed on to a Fortran routine, and then the same way back. I suppose that at the end of the C-routine the arguments are copied back to R. Where/who or what decides what the length of a vector is that is passed back to R? Best, ingmar
On Mon, 17 May 2004, Ingmar Visser wrote:> On 5/13/04 12:46 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote: > > > On Thu, 13 May 2004, Ingmar Visser wrote: > > > >> Dear Prof Ripley, > >> Thanks for your answer. > >> > >> On 5/12/04 2:52 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote: > >> > >>> These normally occur (at that point) from having written off one end of an > >>> array. (If you are using .C/.Fortran, they try to copy back the > >>> arguments.) Compiling with bounds checking turned on can help, at least > >>> with Fortran. > >> > >> Can I invoke compile options if/when I use R cmd install etc. to install > >> packages? > > > > By using a Makevars file: see Writing R Extensions. > > > I got Makevars to work with bounds checking for the fortran files. Does > something similar exist for C/C++ code?Depends on your compiler, which you have not mentioned and if on MacOS X (sic) I would not know about. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On 5/17/04 12:57 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote:> On Mon, 17 May 2004, Ingmar Visser wrote: > >> On 5/13/04 12:46 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote: >> >>> On Thu, 13 May 2004, Ingmar Visser wrote: >>> >>>> Dear Prof Ripley, >>>> Thanks for your answer. >>>> >>>> On 5/12/04 2:52 PM, "Prof Brian Ripley" <ripley at stats.ox.ac.uk> wrote: >>>> >>>>> These normally occur (at that point) from having written off one end of an >>>>> array. (If you are using .C/.Fortran, they try to copy back the >>>>> arguments.) Compiling with bounds checking turned on can help, at least >>>>> with Fortran. >>>> >>>> Can I invoke compile options if/when I use R cmd install etc. to install >>>> packages? >>> >>> By using a Makevars file: see Writing R Extensions. >> >> >> I got Makevars to work with bounds checking for the fortran files. Does >> something similar exist for C/C++ code? > > Depends on your compiler, which you have not mentioned and if on MacOS X > (sic) I would not know about.I use the gcc compilers that are invoked by using R CMD INSTALL, ie g++ and g77 respectively for c++ and fortran code. ingmar visser