[Rd] uninitialised value in R (PR#13476)

Mathieu Ribatet mathieu.ribatet at epfl.ch
Wed Jan 28 11:27:56 CET 2009


Hi Martin,

Sorry I was stupid. Indeed, I named the file tom.c instead of tmp.cc. 
Now with the right extension, it works with the 'extern "C"' piece of code.

However, for your (ii) point, this shouldn't be related to the omission 
of 'extern "C"' but to the fact that the shared library is not loaded in R.
I used "dyn.load("tmp.so")" (or "tmp.dll" under Windows) before running 
your example. With this, you should not have the message "Error in 
.Call("XXX") : C symbol name "XXX" not in load table ".

It seems weired that you didn't get the message with the "extern "C"". 
Is the loaded shared library the latest version of your code - i.e. I 
mean that did you recompile and reload the latest version of your c++ code?

I hope this will help,
Cheers,
Mathieu

Martin Schlather a écrit :
> Hi Mathieu,
>
> Very strange.
> (i) The whole package RandomFields is written with ` extern "C" '
>     and seems working. There is no message from valgrind
>     anywhere, except in two situations that I have boiled
>     down to the code in the bug report.
> (ii) without ` extern "C" ' I get a warning plus an
>     error:
>
>   
>> .Call("XXX")
>>     
> ==18032== Conditional jump or move depends on uninitialised value(s)
> ==18032==    at 0x401620C: (within /lib/ld-2.8.so)
> ==18032==    by 0x42825C3: (within /lib/libc-2.8.so)
> ==18032==    by 0x4282989: _dl_sym (in /lib/libc-2.8.so)
> ==18032==    by 0x417ADE7: (within /lib/libdl-2.8.so)
> ==18032==    by 0x400DE25: (within /lib/ld-2.8.so)
> ==18032==    by 0x417B0DB: (within /lib/libdl-2.8.so)
> ==18032==    by 0x417AD72: dlsym (in /lib/libdl-2.8.so)
> ==18032==    by 0x811012D: R_dlsym (Rdynload.c:787)
> ==18032==    by 0x8110A98: R_FindSymbol (Rdynload.c:836)
> ==18032==    by 0x816E41C: resolveNativeRoutine (dotcode.c:240)
> ==18032==    by 0x817473A: do_dotcall (dotcode.c:825)
> ==18032==    by 0x8194C12: Rf_eval (eval.c:487)
> ==18032==    by 0x805B163: Rf_ReplIteration (main.c:257)
> ==18032==    by 0x805B3E7: R_ReplConsole (main.c:306)
> ==18032==    by 0x805B6D7: run_Rmainloop (main.c:966)
> ==18032==    by 0x8058F80: main (Rmain.c:33)
> Error in .Call("XXX") : C symbol name "XXX" not in load table
>
> Have you named the file u.c or u.cc?
>
> Cheers,
> Martin
>
>
> Mathieu Ribatet wrote:
>   
>> Hi Martin,
>>
>> I wasn't able to compile your files. Replacing "extern "C" SEXP XXX();"
>> by "SEXP XXX();" solve the issue and I got no message from valgrind -
>> I'm not sure this is what you really want to do though.
>> I hope this might help.
>> Cheers,
>> Mathieu
>>
>>
>> schlather at math.uni-goettingen.de a écrit :
>>     
>>> Hi,
>>>
>>> I get an "Conditional jump or move depends on uninitialised value(s)"
>>> from valgrind when using 'solve' in combination with some simple
>>> C-code. (I did not use other functions of R besides 'solve'.)
>>>
>>> In detail: running
>>>
>>> R --vanilla -d "valgrind --tool=memcheck --memcheck:leak-check=yes
>>> --num-callers=20 "
>>>
>>> and calling
>>>
>>> .Call("XXX")
>>> nd <- 3
>>> solve(diag(nd) , as.vector(1:nd))
>>> .Call("XXX")
>>>
>>> gives the above valgrind message for the second call of "XXX".
>>> Without "solve" in the middle, there is no message
>>> from valgrind.
>>>
>>> Best regards,
>>> Martin
>>>
>>>
>>> /////////////////////////////// C source file u.cc
>>> #include "u.h"
>>>
>>> SEXP XXX() {
>>>   SEXP ans;
>>>   PROTECT (ans = allocVector(INTSXP, 1));
>>>   INTEGER(ans)[0] = 1;
>>>   UNPROTECT(1);
>>>   return ans;
>>> }
>>>
>>>
>>> /////////////////////////////// header file u.h
>>> #ifndef RFsimu_public_H
>>> #define RFsimu_public_H 1
>>>
>>> #include <R.h>
>>> #include <Rinternals.h>
>>> #include <Rmath.h>
>>> #include <Rdefines.h>
>>>
>>> extern "C" SEXP XXX();
>>>
>>>
>>> #endif /* RF_simu_PUBLIC_H*/
>>>
>>>
>>>
>>>
>>>
>>>
>>> --please do not edit the information below--
>>>
>>> Version:
>>>  platform = i686-pc-linux-gnu
>>>  arch = i686
>>>  os = linux-gnu
>>>  system = i686, linux-gnu
>>>  status = Under development (unstable)
>>>  major = 2
>>>  minor = 9.0
>>>  year = 2009
>>>  month = 01
>>>  day = 13
>>>  svn rev = 47573
>>>  language = R
>>>  version.string = R version 2.9.0 Under development (unstable)
>>> (2009-01-13 r47573)
>>>
>>> Locale:
>>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C
>>>
>>>
>>> Search Path:
>>>  .GlobalEnv, package:stats, package:graphics, package:grDevices,
>>> package:utils, package:datasets, package:methods, Autoloads, package:base
>>>
>>>   
>>>       
>
>
>   

-- 
Institute of Mathematics
Ecole Polytechnique Fédérale de Lausanne
STAT-IMA-FSB-EPFL, Station 8
CH-1015 Lausanne   Switzerland
http://stat.epfl.ch/
Tel: + 41 (0)21 693 7907



More information about the R-devel mailing list