[Rd] Rcurl crash in R-devel

2015-02-05 Thread Marc Girondot

Hello,

I don't know if the problem originates from R-devel 3.2 or Rcurl itself. 
I post this message to the R-devel list and to the author of RCurl 
(dun...@r-project.org).


> library("RCurl")
Le chargement a nécessité le package : bitops
> print(sessionInfo())
R Under development (unstable) (2015-02-03 r67717)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

other attached packages:
[1] RCurl_1.95-4.5 bitops_1.0-6

> filepath <- 
"/Users/marc/Documents/Espace_de_travail_R/package_embryogrowth/embryogrowth/DESCRIPTION"
> urlx <- 
"ftp://x:...@max2.ese.u-psud.fr/conservation/embryogrowth/DESCRIPTION";


> ftpUpload(what=filepath, to=urlx)

 *** caught segfault ***
address 0x0, cause 'memory not mapped'

Traceback:
 1: .Call("R_curl_easy_perform", curl, .opts, isProtected, 
.encoding, PACKAGE = "RCurl")
 2: curlPerform(url = to, upload = TRUE, readfunction = 
uploadFunctionHandler(file, asText), ..., curl = curl)

 3: ftpUpload(what = filepath, to = urlx)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Hope it will help,

Sincerely,

Marc

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] How to unload R.dll successfully by FreeLibrary

2015-02-05 Thread 暮如雪
hi,
I've some C++ code which try to load R.dll and execute some R command, then 
unload R.dll, yet it seems fail to unload it, so second time to call the 
function hangs since it is trying to Initialize R again(this is not allowed as 
documented). Anyone can tell me why, thanks.
//the following is my c++ code, used in a Visual Studio 2012 Console Application
#define ORAPI__cdecl
typedefBOOL(ORAPI*PFN_Rf_initEmbeddedR)(int argc, char *argv[]);
typedefvoid(ORAPI*PFN_Rf_endEmbeddedR)(int fatal);


staticvoid_simple_test()
{
#define STR_R_DLL_PATH_T("D:\\R\\R-3.1.2\\bin\\i386\\R.dll")
HMODULEm_hRDll = LoadLibrary(STR_R_DLL_PATH);
if ( m_hRDll )
{
PFN_Rf_initEmbeddedR pfnInit = (PFN_Rf_initEmbeddedR)GetProcAddress(m_hRDll, 
"Rf_initEmbeddedR");
PFN_Rf_endEmbeddedR pfnEnd = (PFN_Rf_endEmbeddedR)GetProcAddress(m_hRDll, 
"Rf_endEmbeddedR");


char*szArgs[] = {"REmbeddedPostgres", "--gui=none", "--silent"};
BOOL bRet = pfnInit(_countof(szArgs), szArgs); //call second time, this 
function will not return
//do something.
pfnEnd(0);
FreeLibrary(m_hRDll); //==> After this, R.dll still in memory, as I can see in 
Visual Studio 2012, Module window
}
}
//testing code end
int _tmain(int argc, _TCHAR* argv[])
{
_simple_test(); //first time, seems fine.
_simple_test(); //second time, hangs...
//_start_test_OR_Cache();
//_start_test_OR_Cache();
return 0;
}



�ֻ��˽�
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Invalid read of size 8

2015-02-05 Thread niandra
Hi,

I have a R program that call a C function.  I define a vector of pointer as


int nLC=3;
int pownLC = nLC*nLC
double *MatCovExtra[nT+1];
for(k=0;kK. Then i put some values on the vector associated with the
pointer:

for(k=0;khttp://r.789695.n4.nabble.com/Invalid-read-of-size-8-tp4702843.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Rcurl crash in R-devel

2015-02-05 Thread Prof Brian Ripley

On 05/02/2015 09:42, Marc Girondot wrote:

Hello,

I don't know if the problem originates from R-devel 3.2 or Rcurl itself.


The traceback is 100% sure it originates in or below RCurl (possibly in 
your system's libcurl).   R-devel must be innocent here.


Your example is not reproducible (see the posting guide), so you need to 
run this under a debugger for yourself.



I post this message to the R-devel list and to the author of RCurl
(dun...@r-project.org).

 > library("RCurl")
Le chargement a nécessité le package : bitops
 > print(sessionInfo())
R Under development (unstable) (2015-02-03 r67717)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods base

other attached packages:
[1] RCurl_1.95-4.5 bitops_1.0-6

 > filepath <-
"/Users/marc/Documents/Espace_de_travail_R/package_embryogrowth/embryogrowth/DESCRIPTION"

 > urlx <-
"ftp://x:...@max2.ese.u-psud.fr/conservation/embryogrowth/DESCRIPTION";


 > ftpUpload(what=filepath, to=urlx)

  *** caught segfault ***
address 0x0, cause 'memory not mapped'

Traceback:
  1: .Call("R_curl_easy_perform", curl, .opts, isProtected,
.encoding, PACKAGE = "RCurl")
  2: curlPerform(url = to, upload = TRUE, readfunction =
uploadFunctionHandler(file, asText), ..., curl = curl)
  3: ftpUpload(what = filepath, to = urlx)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Hope it will help,

Sincerely,

Marc


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Invalid read of size 8

2015-02-05 Thread niandra
Few more details:

nSamples_save is an integer variable and if nSamples_save>1000 I get the
error, while if nSamples_save<1000 everything is fine



--
View this message in context: 
http://r.789695.n4.nabble.com/Invalid-read-of-size-8-tp4702843p4702847.html
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Invalid read of size 8

2015-02-05 Thread Simon Urbanek
As you can see from the stack trace the memory you're trying to use has already 
been released so it was not protected.
Since you only provided part of your code we can't really reproduce it or help 
you.

However, why don't you use just use

double *MatCovExtra = REAL(PROTECT(allocMatrix(REALSXP, pownLC, nT+1)));

instead the double-pointers?

Cheers,
Simon



> On Feb 5, 2015, at 7:41 AM, niandra  wrote:
> 
> Hi,
> 
> I have a R program that call a C function.  I define a vector of pointer as
> 
> 
> int nLC=3;
> int pownLC = nLC*nLC
> double *MatCovExtra[nT+1];
> for(k=0;k {
> MatCovExtra[k] = (double*)R_alloc(pownLC, sizeof(double));
> 
> }
> 
> where nT>K. Then i put some values on the vector associated with the
> pointer:
> 
> for(k=0;k {
> for(i=0;i {
> for(j=i;j {
> MatCovExtra[k][i*nLC+j] = startSigma[i*nLC+j];
> }
> }
> }
> and i check that everithing is ok with
> 
> for(k=0;k {
> Rprintf("First Cov Extra %i \n",k);
> for(i=0;i {
> for(j=i;j {
> Rprintf("%f ", MatCovInv[k][i*nLC+j]);
> }
> Rprintf("\n");
> }
> Rprintf("\n\n");
> 
> }
> 
> After that i define an  R variable
> 
> int nProtect =0;
> SEXP zDP_out_r;
> 
> PROTECT(zDP_out_r  = allocMatrix(INTSXP, nT, nSamples_save));
> nProtect++;
> int *zDP_out_P = INTEGER(zDP_out_r);
> 
> 
> 
> and using the same syntax as before
> 
> for(k=0;k {
> Rprintf("Later Cov Extra %i \n",k);
> for(i=0;i {
> for(j=i;j {
> Rprintf("%f ", MatCovInv[k][i*nLC+j]);
> }
> Rprintf("\n");
> }
> Rprintf("\n\n");
> 
> }
> 
> I see that the values of MatCovInv[k] have changed.
> 
> Valgrind shows the following error on the second block of Rprintf:
> 
> 
> Later Cov Extra 3  0x107df7fb8
> ==954== Invalid read of size 8
> ==954==at 0xA92D599: NPHDPHMM (in /Users/NPHDPHMM.so)
> ==954==by 0x8632A: do_dotcall (dotcode.c:652)
> ==954==by 0xB036A: Rf_eval (eval.c:657)
> ==954==by 0xBE8C0: do_set (eval.c:2028)
> ==954==by 0xB0404: Rf_eval (eval.c:629)
> ==954==by 0xBE3C4: do_begin (eval.c:1638)
> ==954==by 0xB0404: Rf_eval (eval.c:629)
> ==954==by 0xBB95D: Rf_applyClosure (eval.c:1038)
> ==954==by 0xB03BC: Rf_eval (eval.c:676)
> ==954==by 0xBE8C0: do_set (eval.c:2028)
> ==954==by 0xB0404: Rf_eval (eval.c:629)
> ==954==by 0xE9012: Rf_ReplIteration (main.c:260)
> ==954==  Address 0x107df7fb8 is 40 bytes inside a block of size 176 free'd
> ==954==at 0x4D8D: free (vg_replace_malloc.c:477)
> ==954==by 0xF0BCA: R_gc_internal (memory.c:1026)
> ==954==by 0xF2400: Rf_allocVector3 (memory.c:2578)
> ==954==by 0x2BBCE: Rf_allocMatrix (Rinlinedfuns.h:189)
> ==954==by 0xA92D449: NPHDPHMM (in /Users/NPHDPHMM.so)
> ==954==by 0x8632A: do_dotcall (dotcode.c:652)
> ==954==by 0xB036A: Rf_eval (eval.c:657)
> ==954==by 0xBE8C0: do_set (eval.c:2028)
> ==954==by 0xB0404: Rf_eval (eval.c:629)
> ==954==by 0xBE3C4: do_begin (eval.c:1638)
> ==954==by 0xB0404: Rf_eval (eval.c:629)
> ==954==by 0xBB95D: Rf_applyClosure (eval.c:1038)
> ==954== 
> 
> 
> Where is the error? I tried to search on the internet but i didn't find a
> solution.
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Invalid-read-of-size-8-tp4702843.html
> Sent from the R devel mailing list archive at Nabble.com.
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel