[Rd] R unstable and crashes after executing .C
Dear R listers, I have developed a C function to be executed from R through the ".C" interface. After doing dyn.load, the function executes properly and I get the results. However, after executing my function, R seems to get unstable and crashes (giving a segmentation fault and exiting) whenever I try to do ANYTHING with a relatively large object (creating a new one or even just writing the name of an existing one). I use R 2.4.0 under a Linux machine with 1 GB RAM. Below there is an example of execution, so you can get an idea of what is happening: dyn.load("my_C_module.so"); res <- .C("my_C_function",.); #The function executes fine and res is ok dyn.unload("my_C_module.so") #I know this isn't strictly necessary #Here R is still running, but when I execute: m <- matrix(0,1000,100); #I try to create a new object and R crashes *** caught segfault *** address 0x10, cause 'memory not mapped' Traceback: 1: matrix(0, 1000, 100) Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Although I tell R to abort and give me the core dump, it doesn't succeed in doing so. I would be grateful if anyone could tell me what could be the problem with my C function that makes R behave this way? Thank you very much in advance, and apologies for this long email. Xavier Solé. [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R unstable and crashes after executing .C
There are many packages around that use .C and .Call interfaces with really huge objects and still are pretty stable. The error is most likely in your own C code and it most likely to be connected to memory allocation/deallocation or array indexing, but without having the code here no one will be able to help further. Oleg Sole Acha, Xavi wrote: > Dear R listers, > > > > I have developed a C function to be executed from R through the ".C" > interface. After doing dyn.load, the function executes properly and I get the > results. However, after executing my function, R seems to get unstable and > crashes (giving a segmentation fault and exiting) whenever I try to do > ANYTHING with a relatively large object (creating a new one or even just > writing the name of an existing one). > > > > I use R 2.4.0 under a Linux machine with 1 GB RAM. Below there is an example > of execution, so you can get an idea of what is happening: > > > > > > dyn.load("my_C_module.so"); > > res <- .C("my_C_function",.); #The function executes fine and res is ok > > dyn.unload("my_C_module.so") #I know this isn't strictly necessary > > > > #Here R is still running, but when I execute: > > > > m <- matrix(0,1000,100); #I try to create a new object and R crashes > > > > *** caught segfault *** > > address 0x10, cause 'memory not mapped' > > > > Traceback: > > 1: matrix(0, 1000, 100) > > > > Possible actions: > > 1: abort (with core dump) > > 2: normal R exit > > 3: exit R without saving workspace > > 4: exit R saving workspace > > > > > > Although I tell R to abort and give me the core dump, it doesn't succeed in > doing so. > > > > I would be grateful if anyone could tell me what could be the problem with my > C function that makes R behave this way? > > > > Thank you very much in advance, and apologies for this long email. > > > > Xavier Solé. > > > > > > > [[alternative HTML version deleted]] > > > > > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R unstable and crashes after executing .C
Please do as I suggested in my reply to your message to R-help! And do read the posting guide and not send HMTL mail. On Wed, 21 Feb 2007, Sole Acha, Xavi wrote: Dear R listers, I have developed a C function to be executed from R through the ".C" interface. After doing dyn.load, the function executes properly and I get the results. However, after executing my function, R seems to get unstable and crashes (giving a segmentation fault and exiting) whenever I try to do ANYTHING with a relatively large object (creating a new one or even just writing the name of an existing one). I use R 2.4.0 under a Linux machine with 1 GB RAM. Below there is an example of execution, so you can get an idea of what is happening: dyn.load("my_C_module.so"); res <- .C("my_C_function",.); #The function executes fine and res is ok dyn.unload("my_C_module.so") #I know this isn't strictly necessary #Here R is still running, but when I execute: m <- matrix(0,1000,100); #I try to create a new object and R crashes *** caught segfault *** address 0x10, cause 'memory not mapped' Traceback: 1: matrix(0, 1000, 100) Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Although I tell R to abort and give me the core dump, it doesn't succeed in doing so. I would be grateful if anyone could tell me what could be the problem with my C function that makes R behave this way? Thank you very much in advance, and apologies for this long email. Xavier Solé. [[alternative HTML version deleted]] -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595__ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] JIT compiler library
Since this escaped my notice before, I thought it useful to post a link here - in case you have not seen it either: http://www.gnu.org/software/lightning/lightning.html This a portable JIT compiler library with fairly easy syntax (one syntax - many cpus). best Vladimir Dergachev __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] JIT compiler library
Vladimir Dergachev wrote: > Since this escaped my notice before, I thought it useful to post a link here > - > in case you have not seen it either: > > http://www.gnu.org/software/lightning/lightning.html > > This a portable JIT compiler library with fairly easy syntax (one syntax - > many cpus). > I think it hasn't been worked on for quite a while, though. Or has it development picked up again? Another idea is LLVM http://llvm.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] "Re: Contents of R-devel digest..."
[EMAIL PROTECTED] - [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] JIT compiler library
I think work on Lightning picked up again when the work on GNU Smalltalk started picking up again (there have been something like 4 or 5 releases in the last 6 months). IIRC it's a bit more lightweight than LLVM. On 2/21/07, Marcus G. Daniels <[EMAIL PROTECTED]> wrote: > Vladimir Dergachev wrote: > > Since this escaped my notice before, I thought it useful to post a link > > here - > > in case you have not seen it either: > > > > http://www.gnu.org/software/lightning/lightning.html > > > > This a portable JIT compiler library with fairly easy syntax (one syntax - > > many cpus). > > > I think it hasn't been worked on for quite a while, though. Or has it > development picked up again? > Another idea is LLVM http://llvm.org > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > -- Byron Ellis ([EMAIL PROTECTED]) "Oook" -- The Librarian __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] non-interactive R_tryEval does not return
...at least I think that is what happens, at least on some configurations. Here's a repeatable example: cd R_HOME/tests/Embedding touch tmp.R make tryEval and then (correct) > ./tryEval --slave Error in sqrt("") : Non-numeric argument to mathematical function Caught an error calling sqrt(). Try again with a different argument. [1] 3 versus (non-interactive; no return) > ./tryEval --slave < tmp.R Error in sqrt("") : Non-numeric argument to mathematical function Execution halted > echo "sessionInfo()" | R --slave R version 2.5.0 Under development (unstable) (2007-02-21 r40774) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Adding difftime objects to POSIXt objects
Hello, ?DateTimeClasses states that "one can add or subtract a number of seconds or a 'difftime' object from a date-time object, but not add two date-time objects." So, is the below expected behavior? > x <- Sys.time() > x [1] "2007-02-21 16:19:56 CST" > x + as.difftime("1","%H") [1] "2007-02-21 16:19:57 CST" Warning message: Incompatible methods ("+.POSIXt", "Ops.difftime") for "+" "+.POSIXt" does behave as expected, though: > "+.POSIXt"(x,as.difftime("1","%H")) [1] "2007-02-21 17:19:56 CST" > R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Under development (unstable) major 2 minor 5.0 year 2007 month 01 day07 svn rev40398 language R version.string R version 2.5.0 Under development (unstable) (2007-01-07 r40398) Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
On Wednesday 21 February 2007 23:09, Martin Morgan wrote: > > ./tryEval --slave < tmp.R > > Error in sqrt("") : Non-numeric argument to mathematical function > Execution halted To force interactive use (when embedding), you can set R_Interactive (from Rinterface.h) to TRUE, after Rf_initEmbeddedR(). Regards Thomas Friedrichsmeier pgpJtOmLfGYg9.pgp Description: PGP signature __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
Yes, I know this, but R then acts as though it were interactive! Thanks for the suggestion though. Martin Thomas Friedrichsmeier <[EMAIL PROTECTED]> writes: > On Wednesday 21 February 2007 23:09, Martin Morgan wrote: >> > ./tryEval --slave < tmp.R >> >> Error in sqrt("") : Non-numeric argument to mathematical function >> Execution halted > > To force interactive use (when embedding), you can set R_Interactive (from > Rinterface.h) to TRUE, after Rf_initEmbeddedR(). > > Regards > Thomas Friedrichsmeier > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Adding difftime objects to POSIXt objects
Jeffrey Horner wrote: > Hello, > > ?DateTimeClasses states that "one can add or subtract a number of > seconds or a 'difftime' object from a date-time object, but not add two > date-time objects." > > So, is the below expected behavior? > > > x <- Sys.time() > > x > [1] "2007-02-21 16:19:56 CST" > > x + as.difftime("1","%H") > [1] "2007-02-21 16:19:57 CST" > Warning message: > Incompatible methods ("+.POSIXt", "Ops.difftime") for "+" > > "+.POSIXt" does behave as expected, though: > > > "+.POSIXt"(x,as.difftime("1","%H")) > [1] "2007-02-21 17:19:56 CST" > > > R.version > _ > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status Under development (unstable) > major 2 > minor 5.0 > year 2007 > month 01 > day07 > svn rev40398 > language R > version.string R version 2.5.0 Under development (unstable) (2007-01-07 > r40398) Oops! I thought I ran this on the latest revision, but the same behavior is exhibited in r40774: > x <- Sys.time() > x [1] "2007-02-21 16:44:16 CST" > x + as.difftime("1","%H") [1] "2007-02-21 16:44:17 CST" Warning message: Incompatible methods ("+.POSIXt", "Ops.difftime") for "+" > R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Under development (unstable) major 2 minor 5.0 year 2007 month 02 day21 svn rev40774 language R version.string R version 2.5.0 Under development (unstable) (2007-02-21 r40774) Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
Yes, this is as expected/documented (in so far as R_tryEval is documented: it is not part of the API, as far as I am aware). Its point is to be the equivalent of submitting an expression from the toplevel and returning to the toplevel, without using R_ReadConsole. So it behaves in just the same ways as any other R session with respect to R errors. I think in all the intended uses R would be in interactive mode, and I suspect it is an oversight that Rf_initEmbeddedR does not set that on Unix-alikes (it does on Windows). You can set R_Interactive afterwards, of course. On Wed, 21 Feb 2007, Martin Morgan wrote: > ...at least I think that is what happens, at least on some > configurations. Here's a repeatable example: > > cd R_HOME/tests/Embedding > touch tmp.R > make tryEval > > and then (correct) > >> ./tryEval --slave > Error in sqrt("") : Non-numeric argument to mathematical function > Caught an error calling sqrt(). Try again with a different argument. > [1] 3 > > versus (non-interactive; no return) > >> ./tryEval --slave < tmp.R > Error in sqrt("") : Non-numeric argument to mathematical function > Execution halted > >> echo "sessionInfo()" | R --slave > R version 2.5.0 Under development (unstable) (2007-02-21 r40774) > x86_64-unknown-linux-gnu > > locale: > LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Adding difftime objects to POSIXt objects
This is known, and not easy to solve given the way dispatch works for binary operators. The documentation was broken when Ops.difftime was introduced. You have found the known fix On Wed, 21 Feb 2007, Jeffrey Horner wrote: > Jeffrey Horner wrote: >> Hello, >> >> ?DateTimeClasses states that "one can add or subtract a number of >> seconds or a 'difftime' object from a date-time object, but not add two >> date-time objects." >> >> So, is the below expected behavior? >> >> > x <- Sys.time() >> > x >> [1] "2007-02-21 16:19:56 CST" >> > x + as.difftime("1","%H") >> [1] "2007-02-21 16:19:57 CST" >> Warning message: >> Incompatible methods ("+.POSIXt", "Ops.difftime") for "+" >> >> "+.POSIXt" does behave as expected, though: >> >> > "+.POSIXt"(x,as.difftime("1","%H")) >> [1] "2007-02-21 17:19:56 CST" >> >> > R.version >> _ >> platform i686-pc-linux-gnu >> arch i686 >> os linux-gnu >> system i686, linux-gnu >> status Under development (unstable) >> major 2 >> minor 5.0 >> year 2007 >> month 01 >> day07 >> svn rev40398 >> language R >> version.string R version 2.5.0 Under development (unstable) (2007-01-07 >> r40398) > > Oops! I thought I ran this on the latest revision, but the same behavior > is exhibited in r40774: > > > x <- Sys.time() > > x > [1] "2007-02-21 16:44:16 CST" > > x + as.difftime("1","%H") > [1] "2007-02-21 16:44:17 CST" > Warning message: > Incompatible methods ("+.POSIXt", "Ops.difftime") for "+" > > R.version >_ > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status Under development (unstable) > major 2 > minor 5.0 > year 2007 > month 02 > day21 > svn rev40774 > language R > version.string R version 2.5.0 Under development (unstable) (2007-02-21 > r40774) > > > Jeff > -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
On Wednesday 21 February 2007 23:53, Martin Morgan wrote: > Yes, I know this, but R then acts as though it were interactive! > Thanks for the suggestion though. Martin If that is a problem, another way around it would be to set options("error") instead. Regards Thomas Friedrichsmeier pgp3lsjKdD2pj.pgp Description: PGP signature __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
On Wednesday 21 February 2007 23:58, Prof Brian Ripley wrote: > Yes, this is as expected/documented (in so far as R_tryEval is > documented: it is not part of the API, as far as I am aware). Fortunately, it is part of the API. Regards Thomas Friedrichsmeier pgpvK3lruN9w8.pgp Description: PGP signature __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
Prof Brian Ripley <[EMAIL PROTECTED]> writes: > Yes, this is as expected/documented (in so far as R_tryEval is > documented: it is not part of the API, as far as I am aware). > > Its point is to be the equivalent of submitting an expression from the > toplevel and returning to the toplevel, without using > R_ReadConsole. So it behaves in just the same ways as any other R > session with respect to R errors. Unpacking the above a bit, I guess the meaning of 'as expected / documented' is that in non-interactive modes errors halt R (in errors.c just before LONGJMP(R_ToplevelContext->cjmpbuf, 0)). This does not seem quite consistent with the idea that R_tryEval is 'the equivalent of submitting an expression from the toplevel and returning to the toplevel', since in this case there is no return to the top level. This tension is where my problem came from. > I think in all the intended uses R would be in interactive mode, and I > suspect it is an oversight that Rf_initEmbeddedR does not set that on > Unix-alikes (it does on Windows). You can set R_Interactive > afterwards, of course. Alternative GUIs might want an interactive, embedded R. I would have thought other uses (web services for me) would rather a non-interactive embedded R. Whatever the case, I likely over-worried the consequences of R_Interactive=TRUE; it seems only to matter with plots, or when there is a segfault (plus whatever user packages might choose to do differently in response to interactive()). Thanks to both for the help, Martin > On Wed, 21 Feb 2007, Martin Morgan wrote: > >> ...at least I think that is what happens, at least on some >> configurations. Here's a repeatable example: >> >> cd R_HOME/tests/Embedding >> touch tmp.R >> make tryEval >> >> and then (correct) >> >>> ./tryEval --slave >> Error in sqrt("") : Non-numeric argument to mathematical function >> Caught an error calling sqrt(). Try again with a different argument. >> [1] 3 >> >> versus (non-interactive; no return) >> >>> ./tryEval --slave < tmp.R >> Error in sqrt("") : Non-numeric argument to mathematical function >> Execution halted >> >>> echo "sessionInfo()" | R --slave >> R version 2.5.0 Under development (unstable) (2007-02-21 r40774) >> x86_64-unknown-linux-gnu >> >> locale: >> LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C >> >> attached base packages: >> [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" >> [7] "base" >> > > -- > Brian D. Ripley, [EMAIL PROTECTED] > 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, UKFax: +44 1865 272595 -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] non-interactive R_tryEval does not return
On Thu, 22 Feb 2007, Thomas Friedrichsmeier wrote: > On Wednesday 21 February 2007 23:58, Prof Brian Ripley wrote: >> Yes, this is as expected/documented (in so far as R_tryEval is >> documented: it is not part of the API, as far as I am aware). > > Fortunately, it is part of the API. I was unaware that you were the arbiter of what is part of the API. R_tryEval is not mentioned in 'Writing R Extensions', which is. -- Brian D. Ripley, [EMAIL PROTECTED] 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, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel