search for: rf_allocvector

Displaying 20 results from an estimated 74 matches for "rf_allocvector".

2019 Feb 27
2
Intermittent crashes with inset `[<-` command
...ide a block of size 160,048 free'd ==4711== at 0x4C2ACBD: free (vg_replace_malloc.c:530) ==4711== by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055) ==4711== by 0x4FAFCB2: RunGenCollect (memory.c:1825) ==4711== by 0x4FAFCB2: R_gc_internal (memory.c:2998) ==4711== by 0x4FB166F: Rf_allocVector3 (memory.c:2682) ==4711== by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577) ==4711== by 0x4FB2310: R_alloc (memory.c:2197) ==4711== by 0x5023F7A: logicalSubscript (subscript.c:575) ==4711== by 0x5026DA3: Rf_makeSubscript (subscript.c:994) ==4711== by 0x501A2F3: VectorAssign (subassig...
2019 Feb 27
0
Intermittent crashes with inset `[<-` command
...t; free'd > ==4711== at 0x4C2ACBD: free (vg_replace_malloc.c:530) > ==4711== by 0x4FAFCB2: ReleaseLargeFreeVectors (memory.c:1055) > ==4711== by 0x4FAFCB2: RunGenCollect (memory.c:1825) > ==4711== by 0x4FAFCB2: R_gc_internal (memory.c:2998) > ==4711== by 0x4FB166F: Rf_allocVector3 (memory.c:2682) > ==4711== by 0x4FB2310: Rf_allocVector (Rinlinedfuns.h:577) > ==4711== by 0x4FB2310: R_alloc (memory.c:2197) > ==4711== by 0x5023F7A: logicalSubscript (subscript.c:575) > ==4711== by 0x5026DA3: Rf_makeSubscript (subscript.c:994) > ==4711== by 0x501A2F...
2020 Sep 08
1
some questions about R internal SEXP types
...in the R help (? command) and in Writing R Extensions. The > former covers what is allowed from R code in extensions, the latter > mostly what is allowed from C code in extensions (with some references > to Fortran). Could you clarify what you mean by "documented"? For example, Rf_allocVector() is mentioned several times in R-exts, but I don't see anywhere where the inputs and output are precisely described (which is what I would consider to be documented). Is Rf_allocVector() part of the API? Hadley -- http://hadley.nz
2010 May 06
1
R on kdeedu-svn library problem
...or/src/backends/R/rserver/CMakeFiles/cantor_rserver.dir/radaptor.o Linking CXX executable cantor_rserver CMakeFiles/cantor_rserver.dir/rserver.o: In function `RServer::runCommand(QString const&, bool)': $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:223: undefined reference to `Rf_allocVector' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:223: undefined reference to `Rf_protect' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:224: undefined reference to `Rf_mkChar' $SOURCES/kdeedu/cantor/src/backends/R/rserver/rserver.cpp:224: undefined reference to...
2020 Sep 11
4
Garbage collection of seemingly PROTECTed pairlist
...tting a strange garbage collection error. My PROTECTed pairlist prlst gets garbage collected away and causes a memory leak error when I try to access it. Here's my code. #include <Rinternals.h> SEXP C_int_mat_nth_row_nrnc(int *int_mat_int, int nr, int nc, int n) { SEXP out = PROTECT(Rf_allocVector(INTSXP, nc)); int *out_int = INTEGER(out); if (n <= 0 | n > nr) { for (int i = 0; i != nc; ++i) { out_int[i] = NA_INTEGER; } } else { for (int i = 0; i != nr; ++i) { out_int[i] = int_mat_int[n - 1 + i * nr]; } } UNPROTECT(1); return out;} SEXP C_make_l...
2011 Apr 14
1
Rcpp segmentation faults on the simplest code
...run it, it segfaults. The following is the gdb trace: &lt;co(gdb) run Starting program: /home/jingy/tmp/stl [Thread debugging using libthread_db enabled] Program received signal SIGSEGV, Segmentation fault. 0x00002aaaabb86d70 in ?? () from /usr/lib/libR.so (gdb) up #1 0x00002aaaabb8849b in Rf_allocVector () from /usr/lib/libR.so (gdb) #2 0x0000000000401618 in Vector (this=0x7fffffffd880, size=@0x7fffffffd89c) at /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:130 130 RObject::setSEXP( Rf_allocVector( RTYPE, size) ) ; (gdb) #3 0x0000000000401438 in main (argc=1, argv=0x7ffff...
2013 Dec 16
1
External pointers and changing SEXPTYPE
...ta = Calloc( 1, my_data_ptr ) ; SEXP Rdata; PROTECT(Rdata = R_MakeExternalPtr( mydata, R_fname, R_NilValue )); ... mydata->a = Calloc(mydata->na, float); // same for b and c // initializing names so that I could use e.g. df$a where df is returned by read_my_data() PROTECT(mydata->ans_nms = Rf_allocVector(STRSXP, efldNR )); for( ix = 0; ix < efldNR; ix++ ) SET_STRING_ELT(mydata->ans_nms, ix, mkChar(vnames[ix])); // later I bind values of non-R variables from my data structure to a proper vector PROTECT(mydata->ans = Rf_allocVector(VECSXP, efldNR )); Rf_setAttrib(mydata->ans, R_...
2009 Sep 20
1
Return a list from a .Call but segfaults
...threads: generic error] and cannot proceed. ==== Code ==== SEXP returnListOfKV(SEXP raw,SEXP numread){ if(TYPEOF(raw)!=RAWSXP){ return(R_NilValue); } int num = INTEGER(numread)[0]; char *rawdata = (char*)RAW(raw); SEXP KV ,rval; int r; PROTECT(rval = Rf_allocVector(VECSXP, num)); for(int i=0;i<num;i++){ SEXP k = R_NilValue; PROTECT(KV = Rf_allocVector(VECSXP, 2)); r = reverseUInt(*((int*) rawdata)); //converts network order to host rawdata+=4; //yes, hard code size of int PROTECT(k= kk_(rawdata,r)); //deserializes...
2006 Oct 19
0
Memory leak
...ide a block of size 168 free'd ==11423== at 0x401B2A3: free (vg_replace_malloc.c:233) ==11423== by 0x80ED27C: ReleaseLargeFreeVectors (memory.c:759) ==11423== by 0x80EED30: RunGenCollect (memory.c:1351) ==11423== by 0x80F0635: R_gc_internal (memory.c:2141) ==11423== by 0x80F000C: Rf_allocVector (memory.c:1942) ==11423== by 0x814F67A: RestoreToEnv (saveload.c:2038) ==11423== by 0x8150465: do_loadFromConn2 (saveload.c:2358) ==11423== by 0x80F95FF: do_internal (names.c:1097) ==11423== by 0x80CB320: Rf_eval (eval.c:431) ==11423== by 0x80CCAC1: do_begin (eval.c:1107) ==11423==...
2023 Apr 30
0
Forcing a PROTECT Bug to Occur
...ough), or a single larger object (as you did). It doesn't make sense speculating more without reading the code, instrumenting and possibly debugging, if you want to find out exactly what is happening in your situation. Tomas > > z = inline::cfunction(body=" > ? ? SEXP vec_1 = Rf_allocVector(INTSXP, 100); > ? ? SEXP vec_2 = Rf_allocVector(VECSXP, 3); > ? ? SET_VECTOR_ELT(vec_2, 1, vec_1); > ") > > z() > NULL > Warning message: > In z() : your C program does not return anything! > > gctorture(TRUE) > > z() > > ?*** caught segfault *** >...
2017 Mar 29
3
Transferring ownership of R-managed buffer
I have a use case where I would like to create an SEXP around an existing buffer that is managed by R, thus avoiding a copy operation. If I have something like: void *p = (void*) RAW(PROTECT(Rf_allocVector(RAWSXP, n))); ... additional maniupulation ... SEXP x = somefunc(SXPTYPE, n, p); // ???? Is there a "placement" constructor available? (I have arranged for the corresponding UNPROTECT.) I've looked at and experimented with R_allocator and allocVector3, but can't quite get it rig...
2019 Feb 26
8
Intermittent crashes with inset `[<-` command
The following code crashes after about 300 iterations on my?x86_64-w64-mingw32?machine on R 3.5.2 --vanilla.?? Others have duplicated this (see?https://github.com/tidyverse/magrittr/issues/190?if necessary), but I don't know how machine/OS-dependent it may be.?? If it doesn't crash for you, please try increasing the length of the x vector. Substituting the commented-out line for the one
2000 Dec 18
1
1.2.0 segfault
...A() Undefined command: "dsecurvature". Try "help". (gdb) continue Continuing. > dsecurvature.function.testsA() Random number generator tests ...ok DSE curvature test A 1 ... completed DSE curvature test A 2 ... Program received signal SIGSEGV, Segmentation fault. 0x763cc in Rf_allocVector (type=14, length=2) at memory.c:1551 1551 CLASS_GET_FREE_NODE(node_class, s); (gdb) bactrace Undefined command: "bactrace". Try "help". (gdb) backtrace #0 0x763cc in Rf_allocVector (type=14, length=2) at memory.c:1551 #1 0x5561c in Rf_duplicate (s=0xbcd6f0) at duplicate....
2024 Apr 22
1
Is ALTREP "non-API"?
...functions are in the headers for historical or other reasons since the > headers are used both for the internal implementation and packages. That's > why this is in R-exts under "The R API: entry points for C code": > If I understand your point correctly, does this mean that Rf_allocVector() is not part of the "official" R API? It does not appear to be documented in the "The R API: entry points for C code" section. Hadley -- http://hadley.nz [[alternative HTML version deleted]]
2019 Mar 01
1
Surprising results from INTEGER_GET_REGION with ALTREP object
Dear Listmembers, wanting to learn more about ALTREP I wrote the following function to extract a subsequence from an integer vector: #include <Rinternals.h> SEXP integer_get_region(SEXP _x, SEXP _i, SEXP _n) { int i = INTEGER(_i)[0]; int n = INTEGER(_n)[0]; SEXP result = PROTECT(Rf_allocVector(INTSXP, n)); INTEGER_GET_REGION(_x, i, n, INTEGER(result)); UNPROTECT(1); return result; } For "shorter" vectors, the result is as expected: > dyn.load("altrep_int_region.so") > .Call("integer_get_region", 1:1e9, 0L, 10L) [1] 1 2 3 4 5 6 7 8 9 1...
2004 Jun 16
1
Compiling C++ package source: linking problem?
...all: #include <R.h> #include <Rdefines.h> ... SEXP whatever (SEXP model) { SEXP anotherModel; PROTECT(anotherModel = NEW_NUMERIC(4)); UNPROTECT(1); return anotherModel; } An example of compiler feedback from R CMD SHLIB (I have mingw 3.1.0): ...: undefined reference to 'Rf_allocVector(unsigned,int)' ...: undefined reference to 'Rf_protect(SEXPREC*)' ...: undefined reference to 'Rf_unprotect(int)' Can anybody tell me what the matter is? Did I miss something? My PATH variable is as follows: C:\R\tools;C:\Perl\bin\;C:\mingw\bin;c:\R\rw1090\bin;C:\Program File...
2023 Apr 29
1
Forcing a PROTECT Bug to Occur
...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 inline package for simplicity): > gctorture(TRUE) > z = inline::cfunction(body=" SEXP vec_1 = Rf_ScalarInteger(99); SEXP vec_2 = Rf_allocVector(VECSXP, 10); SET_VECTOR_ELT(vec_2, 1, vec_1); Rf_PrintValue(vec_2); ") My thinking was that, with torture mode enabled, the allocation of vec_2 should ensure that vec_1 is collected, and then trying to put it into vec_2 and then print it would then fail. But it consistently prints 99...
2020 Sep 12
0
Garbage collection of seemingly PROTECTed pairlist
...ROTECTed pairlist prlst > gets garbage collected away and causes a memory leak error when I try to > access it. > > Here's my code. > > #include <Rinternals.h> > > > SEXP C_int_mat_nth_row_nrnc(int *int_mat_int, int nr, int nc, int n) { > SEXP out = PROTECT(Rf_allocVector(INTSXP, nc)); > int *out_int = INTEGER(out); > if (n <= 0 | n > nr) { > for (int i = 0; i != nc; ++i) { > out_int[i] = NA_INTEGER; > } > } else { > for (int i = 0; i != nr; ++i) { > out_int[i] = int_mat_int[n - 1 + i * nr]; > } >...
2010 Oct 27
2
must .Call C functions return SEXP?
...would definitely appreciate any help. Thanks! My R code looks like this: result.1 <- vector("list" ,1e6) result.2 <- vector("list" ,1e6) .Call("my_C_function", result.1, result.2, other.input) My C code looks like this: SEXP result_v; result_v = Rf_allocVector(REALSXP, 5); SET_VECTOR_ELT(result_list_1, k1, result_v); REAL(result_v)[0] = some_number; REAL(result_v)[1] = another_number; /* Also do the same sort of thing for result_list_2. */ return(result_list_1); /* Appears to work ok. */ /* return; */ /* Segfaults. */ -- Andrew Piskor...
2013 Oct 16
1
Parallel R expression evaluations
...ng R, parsing and evaluation of R expression // For initialization int res= Rf_initEmbeddedR(R_argc, (char**)R_argv); // For parsing and evaluation SEXP cmd1= Rf_mkChar(rscript); SEXP cmdSexp, cmdexpr, sresult = R_NilValue; ParseStatus status; R_len_t i=0; PROTECT(cmdSexp = Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, cmd1); // parsing vector for R expressions cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); // error handling return; } for(i = 0; i < Rf_length(cmdexpr); i++) { int error; s...