Mysterious Date Parsing Failures: NaN

C

Curt Sampson

I've got an application that goes through apache log files, and one of
the things is does is parse the dates. However, I'm getting mysterious
ocassional failures on what seem to be random lines, different every
time, and a line that wouldn't parse will start parsing when I put it
into a test case.

Here's the stacktrace, in this case I did a "Date.new(2003, 4, 11)":

Exception: Couldn't parse date 2003-4-11 (11/Apr/2003): NaN
/usr/local/lib/ruby/1.8/date.rb:300:in `floor'
/usr/local/lib/ruby/1.8/date.rb:300:in `civil_to_jd'
/usr/local/lib/ruby/1.8/date.rb:568:in `valid_civil?'
/usr/local/lib/ruby/1.8/date.rb:590:in `new'
./HttpLogRecord.rb:83:in `parse_apache_date'
./HttpLogRecord.rb:36:in `parse'
...

This happens both with 1.8.1 and 1.8.2preview2. Any thoughts?

cjs
 
Z

Zev Blut

Hello Curt,

[ Snip description of Date parsing error ]

Here's the stacktrace, in this case I did a "Date.new(2003, 4, 11)":

Exception: Couldn't parse date 2003-4-11 (11/Apr/2003): NaN
/usr/local/lib/ruby/1.8/date.rb:300:in `floor'
/usr/local/lib/ruby/1.8/date.rb:300:in `civil_to_jd'
/usr/local/lib/ruby/1.8/date.rb:568:in `valid_civil?'
/usr/local/lib/ruby/1.8/date.rb:590:in `new'
./HttpLogRecord.rb:83:in `parse_apache_date'
./HttpLogRecord.rb:36:in `parse'
...

This happens both with 1.8.1 and 1.8.2preview2. Any thoughts?

That is quite odd, I cannot recreate it on my machine. Although,
digging through the source code makes me think it might be a C library
issue with your "math.h" implementation. Granted I am nowhere close
to knowledgeable when it comes to this level of detail. So in order
to help the ones in the know; What is your output when you type
"ruby -v" ?

Best,
Zev
 
C

Curt Sampson

That is quite odd, I cannot recreate it on my machine.

Did you try calling it a lot. It happens only once every few hundred
thousand times.
Although, digging through the source code makes me think it might be
a C library issue with your "math.h" implementation.

Hm. I wonder.
So in order to help the ones in the know; What is your output when you
type "ruby -v" ?

ruby 1.8.2 (2004-07-29) [i386-netbsdelf2.0.]

uname -a gives:

NetBSD dev1.tabemo.com 2.0_BETA NetBSD 2.0_BETA ($Id: TABEMO.WORKSTATION,v 1.1 2004/09/27 07:02:01 cjs Exp $) #2: Mon Sep 27 16:04:17 JST 2004 (e-mail address removed):/u/netbsd/src-2.0/sys/arch/i386/compile/TABEMO.WORKSTATION i386

cjs
 
Z

Zev Blut

Did you try calling it a lot. It happens only once every few hundred
thousand times.

Ah, no I did not. Although, I just tried it with the following code
with no problems.

require "date"
(1000000).times { Date.new(2003, 4, 11) }

Although, digging through the source code makes me think it might be
a C library issue with your "math.h" implementation.

Hm. I wonder.
So in order to help the ones in the know; What is your output when you
type "ruby -v" ?

ruby 1.8.2 (2004-07-29) [i386-netbsdelf2.0.]

uname -a gives:

NetBSD dev1.tabemo.com 2.0_BETA NetBSD 2.0_BETA ($Id:
TABEMO.WORKSTATION,v 1.1 2004/09/27 07:02:01 cjs Exp $) #2: Mon Sep 27
16:04:17 JST 2004
(e-mail address removed):/u/netbsd/src-2.0/sys/arch/i386/compile/TABEMO.WORKSTATION
i386

Just for comparison's sake, here are the details of the machine I ran it
on:

$ ruby -v
ruby 1.8.2 (2004-05-24) [i686-linux]
$ uname -a
Linux TwinStar 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686
i386
GNU/Linux

If I get some time this weekend I might boot up my Sparc 5 with NetBSD and
see
what it does. But, hopefully someone in the know will answer the problem
before then :)

Best,
Zev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,421
Latest member
StacyTaver

Latest Threads

Top