[Rcpp-devel] Extract a function from a list and create a call
Romain Francois
romain.francois at dbmail.com
Mon Mar 22 15:51:19 CET 2010
Le 22/03/10 14:30, Dirk Eddelbuettel a écrit :
>
> On 22 March 2010 at 08:14, Douglas Bates wrote:
> |> And when I run the code on OSX (gcc 4.2), I get :
> |>
> |> *** caught segfault ***
> |> address 0x0, cause 'memory not mapped'
> |>
> |> Traceback:
> |> 1: .Call("file10d63af1", PACKAGE = f, l)
> |> 2: fx(binomial())
> |> aborting ...
> |> Segmentation fault
> |>
> |> which is not good either.
> |
> | It's likely the segfault occurs when trying to create the std::string
> | from fpt. A simpler test is
> |
> | suppressWarnings(require(inline))
> | suppressWarnings(require(Rcpp))
> |
> | fx<- cfunction( signature( l = "list" ), '
> | List ll(l);
> | CharacterVector fam = ll["family"];
> | Rprintf("Assigned fam of length %d\\n", fam.size());
> | if (!fam.size()) return R_NilValue;
> | char *fpt = fam[0];
> | Rprintf("(char*)fam[0] points to \\"%s\\"\\n", fpt);
> | std::string fstr(fpt);
> | Rprintf("std::string fstr points to \\"%s\\"\\n", fstr.c_str());
> | return R_NilValue;
> | ', Rcpp = TRUE, includes = "using namespace Rcpp;" )
> |
> | fx(binomial())
> |
> | I think the problem under Linux is extracting fam[0]. The error
>
> Agreed. I tried a few quick variants as well last night without success.
> However, no segfaults on my end.
>
> Dirk
Hello,
I'm confused now because I cannot reproduce the original problem (with
the script Doug first posted) on fc12 (64 bits) with:
[romain at serifos tmp]$ gcc --version
gcc (GCC) 4.4.3 20100127 (Red Hat 4.4.3-4)
> version$version.string
R version 2.11.0 Under development (unstable) (2010-03-17 r51295)
.. and the second script also works (prints what I expect).
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5
More information about the Rcpp-devel
mailing list