Behaviour of get.hist.quote when presented with bad inputs

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Behaviour of get.hist.quote when presented with bad inputs

Ajay Shah
With R 2.3, when I say get.hist.quote("rubbish") he gets extremely unhappy:

> library(tseries)
Loading required package: quadprog
Loading required package: zoo
> x <- get.hist.quote("rubbish")
trying URL
'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'

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

Traceback:
 1: download.file(url, destfile, method = method)
 2: get.hist.quote("rubbish")

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

I believe that before R 2.3, it was not so bad - there was no segfault
when a bad input was presented. I feel that it's enough to return NULL
when presented with "rubbish", but segfaulting is kinda extreme.

I tried to say
  > try(x <- get.hist.quote("rubbish"))
but that also segfaults.

How can I do better?

My machine is an ibook running an uptodate copy of OS X "tiger".
$ uname -a
Darwin lubyanka.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc

--
Ajay Shah                                      http://www.mayin.org/ajayshah 
[hidden email]                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Dirk Eddelbuettel

Hi Ajay,

On 9 May 2006 at 14:41, Ajay Narottam Shah wrote:
| With R 2.3, when I say get.hist.quote("rubbish") he gets extremely unhappy:
|
| > library(tseries)
| Loading required package: quadprog
| Loading required package: zoo
| > x <- get.hist.quote("rubbish")
| trying URL
| 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
|
|  *** caught segfault ***
| address 0x5f4d4550, cause 'memory not mapped'
|
| Traceback:
|  1: download.file(url, destfile, method = method)
|  2: get.hist.quote("rubbish")
|
| Possible actions:
| 1: abort (with core dump)
| 2: normal R exit
| 3: exit R without saving workspace
| 4: exit R saving workspace
| Selection: c
|
| I believe that before R 2.3, it was not so bad - there was no segfault
| when a bad input was presented. I feel that it's enough to return NULL
| when presented with "rubbish", but segfaulting is kinda extreme.
|
| I tried to say
|   > try(x <- get.hist.quote("rubbish"))
| but that also segfaults.
|
| How can I do better?
|
| My machine is an ibook running an uptodate copy of OS X "tiger".
| $ uname -a
| Darwin lubyanka.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc

Looks like it is a Mac issue as it works fine here. I'm CCing Simon.

One other thing you could try is to set the option() argument for the
downloader to use the external wget command instead of the built-in solution.
That may prevent the segfault.

Hth, Dirk

edd@basebud:~> R

R : Copyright 2006, The R Foundation for Statistical Computing
Version 2.3.0 (2006-04-24)
ISBN 3-900051-07-0

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 and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(tseries)
Loading required package: quadprog
Loading required package: zoo
Warning message:
use of NULL environment is deprecated
>  x <- get.hist.quote("rubbish")
trying URL 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
Error in download.file(url, destfile, method = method) :
        cannot open URL 'http://chart.yahoo.com/table.csv?s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv'
In addition: Warning message:
cannot open: HTTP status was '404 Not Found'
>



|
| --
| Ajay Shah                                      http://www.mayin.org/ajayshah 
| [hidden email]                             http://ajayshahblog.blogspot.com
| <*(:-? - wizard who doesn't know the answer.
|
| _______________________________________________
| [hidden email] mailing list
| https://stat.ethz.ch/mailman/listinfo/r-sig-finance

--
Hell, there are no rules here - we're trying to accomplish something.
                                                  -- Thomas A. Edison

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Simon Urbanek

On May 9, 2006, at 6:20 AM, Dirk Eddelbuettel wrote:

>
> Hi Ajay,
>
> On 9 May 2006 at 14:41, Ajay Narottam Shah wrote:
> | With R 2.3, when I say get.hist.quote("rubbish") he gets  
> extremely unhappy:
> |
> | > library(tseries)
> | Loading required package: quadprog
> | Loading required package: zoo
> | > x <- get.hist.quote("rubbish")
> | trying URL
> | 'http://chart.yahoo.com/table.csv?
> s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv
> '
> |
> |  *** caught segfault ***
> | address 0x5f4d4550, cause 'memory not mapped'
> |

This is a (hard to trace) bug in the internal http request code in R  
2.3.0 that strangely enough appears only on OS X. If the URL doesn't  
exist, R blows (basically it blows when it wants to print an error  
message). You may want to switch to another download method for now  
as Dirk suggested, and hopefully we'll fix this soon.

Cheers,
Simon

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Ajay Shah
> >| With R 2.3, when I say get.hist.quote("rubbish") he gets  
> >extremely unhappy:
> >|
> >| > library(tseries)
> >| Loading required package: quadprog
> >| Loading required package: zoo
> >| > x <- get.hist.quote("rubbish")
> >| trying URL
> >| 'http://chart.yahoo.com/table.csv?
> >s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.csv
> >'
> >|  *** caught segfault ***
> >| address 0x5f4d4550, cause 'memory not mapped'
>
> This is a (hard to trace) bug in the internal http request code in R  
> 2.3.0 that strangely enough appears only on OS X. If the URL doesn't  
> exist, R blows (basically it blows when it wants to print an error  
> message). You may want to switch to another download method for now  
> as Dirk suggested, and hopefully we'll fix this soon.

I tried to use options() to set the download method to wget, but the
problem didn't go away.

--
Ajay Shah                                      http://www.mayin.org/ajayshah 
[hidden email]                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Simon Urbanek

On May 9, 2006, at 10:34 AM, Ajay Narottam Shah wrote:

>>> | With R 2.3, when I say get.hist.quote("rubbish") he gets
>>> extremely unhappy:
>>> |
>>> | > library(tseries)
>>> | Loading required package: quadprog
>>> | Loading required package: zoo
>>> | > x <- get.hist.quote("rubbish")
>>> | trying URL
>>> | 'http://chart.yahoo.com/table.csv?
>>> s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.c
>>> sv
>>> '
>>> |  *** caught segfault ***
>>> | address 0x5f4d4550, cause 'memory not mapped'
>>
>> This is a (hard to trace) bug in the internal http request code in R
>> 2.3.0 that strangely enough appears only on OS X. If the URL doesn't
>> exist, R blows (basically it blows when it wants to print an error
>> message). You may want to switch to another download method for now
>> as Dirk suggested, and hopefully we'll fix this soon.
>
> I tried to use options() to set the download method to wget, but  
> the problem didn't go away.
>

get.hist.quote stubbornly refuses to use options, so you have to use  
get.hist.quote("foo",method="wget")

Cheers,
Simon

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Achim Zeileis-2
On Tue, 9 May 2006 10:47:08 -0400 Simon Urbanek wrote:

>
> On May 9, 2006, at 10:34 AM, Ajay Narottam Shah wrote:
>
> >>> | With R 2.3, when I say get.hist.quote("rubbish") he gets
> >>> extremely unhappy:
> >>> |
> >>> | > library(tseries)
> >>> | Loading required package: quadprog
> >>> | Loading required package: zoo
> >>> | > x <- get.hist.quote("rubbish")
> >>> | trying URL
> >>> | 'http://chart.yahoo.com/table.csv?
> >>> s=rubbish&a=0&b=02&c=1991&d=4&e=08&f=2006&g=d&q=q&y=0&z=rubbish&x=.c
> >>> sv
> >>> '
> >>> |  *** caught segfault ***
> >>> | address 0x5f4d4550, cause 'memory not mapped'
> >>
> >> This is a (hard to trace) bug in the internal http request code in
> >> R 2.3.0 that strangely enough appears only on OS X. If the URL
> >> doesn't exist, R blows (basically it blows when it wants to print
> >> an error message). You may want to switch to another download
> >> method for now as Dirk suggested, and hopefully we'll fix this
> >> soon.
> >
> > I tried to use options() to set the download method to wget, but  
> > the problem didn't go away.
> >
>
> get.hist.quote stubbornly refuses to use options,

...because `method = method' is explicitely passed to download.file()
which only triggers getOptions if(missing(method)).

I've just added a workaround to the tseries devel version so that
getOption () is used.
Z

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
Reply | Threaded
Open this post in threaded view
|

Re: Behaviour of get.hist.quote when presented with bad inputs

Ajay Shah
In reply to this post by Simon Urbanek
> get.hist.quote stubbornly refuses to use options, so you have to use  
> get.hist.quote("foo",method="wget")

Thanks! It worked. Just a small suggestion - a table.csv* file is left
lying around; ideally it should be blown away (or it should be created
in /tmp).

--
Ajay Shah                                      http://www.mayin.org/ajayshah 
[hidden email]                             http://ajayshahblog.blogspot.com
<*(:-? - wizard who doesn't know the answer.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance