similar to: segfault debugging

Displaying 20 results from an estimated 400 matches similar to: "segfault debugging"

2019 Sep 15
2
REprintf could be caught by tryCatch(message)
Dear R-devel community, There appears to be an inconsistency in R C API about the exceptions that can be raised from C code. Mapping of R C funs to corresponding R functions is as follows. error -> stop warning -> warning REprintf -> message Rprintf -> cat Rprint/cat is of course not an exception, I listed it just for completeness. The inconsistency I would like to report is
2014 Oct 31
3
ScalarLogical and setAttrib
Is it expected that attributes set on a LGLSXP created by ScalarLogical will apply to all future objects created by ScalarLogical as well? For example: the 'test1' function below returns FALSE and 'test2' returns FALSE with an attribute: library(inline) test1 <- cfunction(body = 'return ScalarLogical(0);') test2 <- cfunction(body = ' SEXP success =
2012 Mar 17
1
how to pass 'raw' values with cfunction()?
I am having trouble handing "raw" data to a C function, using "cfunction", as demonstrated in the function and output pasted below. Can anyone suggest what I'm doing incorrectly? Thanks. Dan Kelley [Dalhousie University]. 1. TEST FILE library(inline) code <- 'Rprintf("inside f(), b is 0X%x\\n", *b);' f <-
2019 Sep 15
2
[External] REprintf could be caught by tryCatch(message)
Thank you Luke for prompt reply. Is it possible then to request a new function to R C API "message" that would equivalent to R "message" function? Similarly as we now have C "warning" and C "error" functions. Best, Jan On Sun, Sep 15, 2019 at 5:25 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote: > > On Sun, 15 Sep 2019, Jan Gorecki wrote:
2013 Feb 01
1
Problem using raw vectors with inline cfunction
Hello, >From what I understood from the documentation I found, when using the inline cfunction with convention=".C", R raw vectors should be given as unsigned char* to the C function. But consider the following script: library(inline) testRaw <- cfunction(signature(raw='raw', len='integer') , body=' int l = *len; int i = 0;
2010 Jun 13
5
Count of unique factors within another factor
I have a data frame with two factors (sampling 'unit', 'species'). I want to calculate the number of unique 'species' per 'unit.' I can calculate the number of unique values for each variable separately, but can't get a count for each ?unit?. > data=read.csv("C:/Desktop/sr_sort_practice.csv") > attach(data) > data[1:10,] unit species 1
2020 Jun 30
3
Build a R call at C level
On 6/30/20 1:06 PM, Jan Gorecki wrote: > It is quite known that R documentation on R C api could be improved... Please see "5.11 Evaluating R expressions from C" from "Writing R Extensions" Best Tomas > Still R-package-devel mailing list should be preferred for this kind > of questions. > Not sure if that is the best way, but works. > > call_to_sum <-
2020 Jun 30
2
Build a R call at C level
Hi All, I was reading the R extension manual section 5.11 ( Evaluating R expression from C) and I tried to build a simple call to the sum function. Please see below. call_to_sum <- inline::cfunction( language = "C", sig = c(x = "SEXP"), body = " SEXP e = PROTECT(lang2(install(\"sum\"), x)); SEXP ans = PROTECT(eval(e, R_GlobalEnv)); UNPROTECT(2); return
2010 Apr 13
3
Inline Package: void vs return type functions
Dear all, After having a look at the "inline" package and also going through the "Rcpp" package which is tighty related to it, it came to me this question: 1) my C/ C++ code has a return type (let say a double[][] or a user define class) 2) I am working with an extensive library built by someone else and I don't have the time/knowledge to change it by means of working
2019 Jan 05
1
unsorted - suggestion for performance improvement and ALTREP support for POSIXct
I believe the performance of isUnsorted() in sort.c could be improved by calling REAL() once (outside of the for loop), rather than calling it twice inside the loop. As an aside, it is implemented in the faster way in doSort() (sort.c line 401). The example below shows the performance improvement for a vectors of double of moving REAL() outside the for loop. # example as implemented in
2017 Apr 14
2
potential bug in attribute handling for externalptr
Is the following expected behavior? > mkext <- inline::cfunction(language="C", body='return R_MakeExternalPtr(NULL, install("tag"), R_NilValue);') > x <- mkext() > y <- x > attr(y, "foo") <- "bar" > attributes(x) $foo [1] "bar" I would expect that modifying y's attributes should not affect x. [Tested
2008 Nov 05
2
Calling optim and .C
Hi all, I want to optimize a function fn using optim. This function fn calls the .C function in it with a function name and arguments given to fn, i.e. something like this pseudocode: fn <- function(par, "some params for fn") {... .C("Cfunction", ...) ...} optim(par, fn, "some params for fn") In my case this doesn't work, but is it possible in general and I
2010 Mar 07
1
duplicate STRSXP : shallow copy ?
Hello, As this little program illustrates, duplicating a STRSXP does not seem deep enough. require( inline ) fx <- cfunction( signature( x = "character"), ' SEXP y = PROTECT( duplicate( x ) ); int n = LENGTH(x); int nc = 0 ; char* p = 0 ; for( int i=0; i<n; i++){ p = (char*)( CHAR( STRING_ELT( y , i ) ) ); nc = strlen( p ) ; for( int j=0; j<nc; j++){ p[j] =
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
I'm observing that base::sum(x, na.rm=FALSE) for typeof(x) == "double" is much more time consuming when there are missing values versus when there are not. I'm observing this on both Window and Linux, but it's quite surprising to me. Currently, my main suspect is settings in on how R was built. The second suspect is my brain. I hope that someone can clarify the below
2017 Nov 21
1
Truncating vectors by reference in C-backend
Dear all, I want to create a function shrinkVector(x) that takes x and truncates it to the first element without copy. With SETLENGTH and SET_TRUELENGTH, I can achieve that. You can find a reproducible example below. But the memory that was freed is not available for other objects afterwards, except if x is a list (VECSXP). Any suggestions? library(inline) ## define the shrinking function
2023 Apr 29
1
Forcing a PROTECT Bug to Occur
I'm trying to learn about R's PROTECT system. To that end I've tried to create an example of C code that doesn't protect anything. I was hoping it would either segfault from trying to access deallocated memory, or maybe print out nonsense results because the unprotected memory got overwritten, but I can't make either happen. Here's my current code (all in R, using the
2007 May 22
2
inline C/C++ in R: question and suggestion
This is a question and maybe an announcement. We've been discussing in the group that it would be nice to have a mechanism for something like "inline" C/C++ function calls in R. I do not want to reinvent the wheel, therefore, if something like that already exists, please give me a hint -- I could not find anything. If not, here is a working solution, please criticise so I could
2017 May 06
2
xrealloc namespace conflict
I have a package on CRAN now (corpus-0.3.1) that is currently failing tests on Linux, but passing on all other architectures: https://cran.r-project.org/web/checks/check_results_corpus.html I believe that the issue arrises from a namespace class between "xrealloc", which my package provides for internal use, but which R also seems to provide (possibly as part of TRE in
2017 Oct 20
1
Illegal Logical Values
I'm wondering if WRE Section 5.2 should be a little more explicit about misuse of integer values other than NA, 0, and 1 in LGLSXPs.? I'm thinking of this passage: > Logical values are sent as 0 (FALSE), 1 (TRUE) or INT_MIN = -2147483648 (NA, but only if NAOK is true), and the compiled code should return one of these three values. (Non-zero values other than INT_MIN are mapped to
2008 Feb 12
4
assigning NULLs to elements of a list
Dear developers: I have just came across an (unexpected to me) behaviour of lists when assigning NULLs to list elements. I understand that a NULL is a valid R object, thus assigning a NULL to a list element should yield exactly the same result as assigning any other object. So I was surprised when assigning a NULL in fact removed the element from the list. Is this an intended behaviour? If