Skip to content

Core dump with "parse" (PR#2120)

4 messages · j.c.rougier@durham.ac.uk, Roger D. Peng, Thomas Lumley +1 more

#
Hi everyone,

The following code may not be very sensible, but it generates a core dump.  The same happens in R-1.5.1.

Cheers, Jonathan.

arrow:dma0jcr% R-1.6.0

R : Copyright 2002, The R Development Core Team
Version 1.6.0  (2002-10-01)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.

R is a collaborative project with many contributors.
Type `contributors()' for more information.

Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.
expression({
    if (is.null(attr(x, "class")) && is.function(x)) {
        if ("ylab" 0names(list(...))) 
            plot.function(x, ...)
        else plot.function(x, ylab = paste(deparse(substitute(x)), 
            "(x)"), ...)
    }
    else UseMethod("plot")
})
Segmentation fault (core dumped)



--please do not edit the information below--

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = 
 major = 1
 minor = 6.0
 year = 2002
 month = 10
 day = 01
 language = R

Search Path:
 .GlobalEnv, Autoloads, package:base

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On my GNU/Linux box running 1.6.0, I get

marla:> R --vanilla

R : Copyright 2002, The R Development Core Team
Version 1.6.0  (2002-10-01)

[...]
expression({
    if (is.null(attr(x, "class")) && is.function(x)) {
        if ("ylab" 0names(list(...))) 
            plot.function(x, ...)
        else plot.function(x, ylab = paste(deparse(substitute(x)), 
            "(x)"), ...)
    }
    else UseMethod("plot")
})
_                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    6.0              
year     2002             
month    10               
day      01               
language R                


But on one of our OS X servers running R 1.5.1, I get:

galton:> R --vanilla

R : Copyright 2002, The R Development Core Team
Version 1.5.1  (2002-06-17)

[...]
expression({
    if (is.null(attr(x, "class")) && is.function(x)) {
Bus error

I can't tell what the problem is though.

-roger
_______________________________
UCLA Department of Statistics
rpeng@stat.ucla.edu
http://www.stat.ucla.edu/~rpeng
On Mon, 7 Oct 2002, j.c.rougier@durham.ac.uk wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 7 Oct 2002 j.c.rougier@durham.ac.uk wrote:

            
It doesn't generate a core dump for me in either version, but it doesn't
work correctly either.

A simpler version is:
expression(a 0n% b)

It looks like the %i is being used as a printf format string, which might
well cause a core dump.

This isn't happening inside parse, but inside print, since
a %in% b


	-thomas


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Roger Peng <rpeng@stat.ucla.edu> writes:
...
The problem is that PrintExpression is using 
 
 Rprintf(CHAR(STRING_ELT(u, i)));

which works right until it needs to print something with % inside,
then Rprintf interprets the string as a format specification, and
expects to find further arguments to handle according to the
conversion specification. Since they are not there, it grabs
whatever is sitting in the relevant place on the stack and beyond
that, all bets are off...

I'll put the fix into r-patched after some testing.