Olaf Mersmann
2008-Dec-27 00:38 UTC
[Rd] Patch to fix small bug in do_External and do_dotcall
I've stumbled upon a small bug/inconsitency in do_External and do_dotcall: Here's an example: % LC_ALL=C R --vanilla < symname-bug.R R version 2.8.0 (2008-10-20) *snip* > options(error=expression(0)) > ## Call 'R_GD_nullDevice' with incorrect parameter count: > .Call("R_GD_nullDevice", 1) Error in .Call("R_GD_nullDevice", 1) : Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice > > ## Same call made via a NativeSymbolInfo object: > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]] > .Call(sym$address, 1) Error: 'getEncChar' must be called on a CHARSXP The error stems from the fact, that both do_External and do_dotcall expect CAR(args) to be a string, while it might be a NativeSymbolInfo object. checkValidSymbolId() already handles this, so the fix is to use the symbol name returned from resolveNativeRoutine(). After applying the attached patch (against R-trunk revision 47348) the output looks like this: % LC_ALL=C bin/R --vanilla < symname-bug.R R version 2.9.0 Under development (unstable) (2008-12-26 r47348) *snip* > options(error=expression(0)) > ## Call 'R_GD_nullDevice' with incorrect parameter count: > .Call("R_GD_nullDevice", 1) Error in .Call("R_GD_nullDevice", 1) : Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice > > ## Same call made via a NativeSymbolInfo object: > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]] > .Call(sym$address, 1) Error in .Call(sym$address, 1) : Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice Greetings from Dortmund Olaf
Prof Brian Ripley
2008-Dec-27 05:59 UTC
[Rd] Patch to fix small bug in do_External and do_dotcall
Thank you, but can we see the patch please (no attachement arrived)? On Sat, 27 Dec 2008, Olaf Mersmann wrote:> I've stumbled upon a small bug/inconsitency in do_External and do_dotcall: > > Here's an example: > > % LC_ALL=C R --vanilla < symname-bug.R > > R version 2.8.0 (2008-10-20) > *snip* > > options(error=expression(0)) > > ## Call 'R_GD_nullDevice' with incorrect parameter count: > > .Call("R_GD_nullDevice", 1) > Error in .Call("R_GD_nullDevice", 1) : > Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice > > > > ## Same call made via a NativeSymbolInfo object: > > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]] > > .Call(sym$address, 1) > Error: 'getEncChar' must be called on a CHARSXP > > The error stems from the fact, that both do_External and do_dotcall > expect CAR(args) to be a string, while it might be a NativeSymbolInfo > object. checkValidSymbolId() already handles this, so the fix is to > use the symbol name returned from resolveNativeRoutine(). > > After applying the attached patch (against R-trunk revision 47348) the > output looks like this: > > % LC_ALL=C bin/R --vanilla < symname-bug.R > > R version 2.9.0 Under development (unstable) (2008-12-26 r47348) > *snip* > > options(error=expression(0)) > > ## Call 'R_GD_nullDevice' with incorrect parameter count: > > .Call("R_GD_nullDevice", 1) > Error in .Call("R_GD_nullDevice", 1) : > Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice > > > > ## Same call made via a NativeSymbolInfo object: > > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]] > > .Call(sym$address, 1) > Error in .Call(sym$address, 1) : > Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice > > Greetings from Dortmund > Olaf >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Maybe Matching Threads
- getNativeSymbolInfo("user_unif_rand") returns different results on windows and linux
- R on Solaris 10 x64
- serializing recordedplot object
- getNativeSymbolInfo fails with Fortran symbol.
- How to call directly "dotTcl" C-function of the tcltk-package from the C-code of an external package?