Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Errors in line numbers reported?

Reply
Thread Tools

Errors in line numbers reported?

 
 
Hal Fulton
Guest
Posts: n/a
 
      10-25-2004
Has anyone ever seen Ruby report incorrect line numbers
where runtime errors occur?

It's doing it to me, but it's hard to reproduce without
the (large) file I'm using.

Matz: If you're interested, I'll send you a tarball.


Hal



 
Reply With Quote
 
 
 
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      10-26-2004
Hi,

In message "Re: Errors in line numbers reported?"
on Tue, 26 Oct 2004 08:13:05 +0900, Hal Fulton <> writes:

|Matz: If you're interested, I'll send you a tarball.

Send me, unless the source file is larger than 8191 lines.
It's implementation restriction.

matz.


 
Reply With Quote
 
 
 
 
Ara.T.Howard@noaa.gov
Guest
Posts: n/a
 
      10-26-2004
On Tue, 26 Oct 2004, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: Errors in line numbers reported?"
> on Tue, 26 Oct 2004 08:13:05 +0900, Hal Fulton <> writes:
>
> |Matz: If you're interested, I'll send you a tarball.
>
> Send me, unless the source file is larger than 8191 lines.
> It's implementation restriction.
>
> matz.


you mean __LINE__ cannot go > that that?

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself. --Shunryu Suzuki
================================================== =============================
 
Reply With Quote
 
Hal Fulton
Guest
Posts: n/a
 
      10-26-2004
Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: Errors in line numbers reported?"
> on Tue, 26 Oct 2004 08:13:05 +0900, Hal Fulton <> writes:
>
> |Matz: If you're interested, I'll send you a tarball.
>
> Send me, unless the source file is larger than 8191 lines.
> It's implementation restriction.


OK, I never knew that.

The file is 11,756 lines (down from 22,000).

I know that's a lot, and in general is a very bad idea.

But this file is generated code. I'm generating a large
number of child classes based on data.

Is there a workaround -- perhaps the line reported is
real_line mod 8192? In that case I could just add 8K
once or twice...


Thanks,
Hal



 
Reply With Quote
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      10-26-2004
Hi,

In message "Re: Errors in line numbers reported?"
on Tue, 26 Oct 2004 11:34:05 +0900, writes:

|> Send me, unless the source file is larger than 8191 lines.
|> It's implementation restriction.

|you mean __LINE__ cannot go > that that?

Unfortunately yes. It's balance between performance and my
intelligence. Maybe someone wiser than me can enlighten me.

matz.


 
Reply With Quote
 
Yukihiro Matsumoto
Guest
Posts: n/a
 
      10-26-2004
Hi,

In message "Re: Errors in line numbers reported?"
on Tue, 26 Oct 2004 11:27:59 +0900, Hal Fulton <> writes:

|> Send me, unless the source file is larger than 8191 lines.
|> It's implementation restriction.
|
|Is there a workaround -- perhaps the line reported is
|real_line mod 8192? In that case I could just add 8K
|once or twice...

It should be. It is a bad restriction. I should have fix that. But
I couldn't think of the way to fix the problem without hindering
performance.

matz.


 
Reply With Quote
 
Ara.T.Howard@noaa.gov
Guest
Posts: n/a
 
      10-26-2004
On Tue, 26 Oct 2004, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: Errors in line numbers reported?"
> on Tue, 26 Oct 2004 11:34:05 +0900, writes:
>
> |> Send me, unless the source file is larger than 8191 lines.
> |> It's implementation restriction.
>
> |you mean __LINE__ cannot go > that that?
>
> Unfortunately yes. It's balance between performance and my
> intelligence. Maybe someone wiser than me can enlighten me.
>
> matz.


with a lead in like that you can't expect many patches can you?

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself. --Shunryu Suzuki
================================================== =============================
 
Reply With Quote
 
Markus
Guest
Posts: n/a
 
      10-26-2004
On Mon, 2004-10-25 at 20:54, wrote:
> On Tue, 26 Oct 2004, Yukihiro Matsumoto wrote:
>
> > Hi,
> >
> > In message "Re: Errors in line numbers reported?"
> > on Tue, 26 Oct 2004 11:34:05 +0900, writes:
> >
> > |> Send me, unless the source file is larger than 8191 lines.
> > |> It's implementation restriction.
> >
> > |you mean __LINE__ cannot go > that that?
> >
> > Unfortunately yes. It's balance between performance and my
> > intelligence. Maybe someone wiser than me can enlighten me.
> >
> > matz.

>
> with a lead in like that you can't expect many patches can you?
>


I agree with Ara; so instead I will sign up under the always
implicit "more foolhardy" clause in the hopes of learning a little by
claiming less.

I have a patch (attached). It removes the 8k line limit on error
tracking but increases the size of the RNODE to 36 bytes (if I calculate
correctly) from the easier to align 32 bytes. I suspect that this is
where the performance hit would come from, but I have been unable to
measure any consistent speed difference between the patched and
unpatched versions, so I may not be testing the right cases. It may
also be that the savings of not having to shift the bits around makes up
for the alignment hit somewhat, but I have not tested this idea.

-- Markus

diff -u ruby-1.8.2/eval.c ruby-1.8.2-8klines/eval.c
--- ruby-1.8.2/eval.c 2004-07-27 23:32:37.000000000 -0700
+++ ruby-1.8.2-8klines/eval.c 2004-10-25 22:13:13.000000000 -0700
@@ -8296,7 +8296,7 @@

Data_Get_Struct(self, struct BLOCK, data);
if ((node = data->frame.node) || (node = data->body)) {
- len += strlen(node->nd_file) + 2 +
(SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
+ len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT)/3;
str = rb_str_new(0, len);
sprintf(RSTRING(str)->ptr, "#<%s:0x%.*lx@%s:%d>", cname, w,
(VALUE)data->body,
node->nd_file, nd_line(node));
diff -u ruby-1.8.2/node.h ruby-1.8.2-8klines/node.h
--- ruby-1.8.2/node.h 2004-10-25 22:05:16.000000000 -0700
+++ ruby-1.8.2-8klines/node.h 2004-10-25 22:20:04.000000000 -0700
@@ -130,6 +130,7 @@
typedef struct RNode {
unsigned long flags;
char *nd_file;
+ unsigned long nd_line;
union {
struct RNode *node;
ID id;
@@ -159,11 +160,8 @@
#define nd_set_type(n,t) \

RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))

-#define NODE_LSHIFT (FL_USHIFT+
-#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
-#define nd_line(n) ((unsigned
int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
-#define nd_set_line(n,l) \
-
RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
+#define nd_line(n) (((RNODE(n))->nd_line))
+#define nd_set_line(n,l) (RNODE(n)->nd_line=(l))

#define nd_head u1.node
#define nd_alen u2.argc





 
Reply With Quote
 
ts
Guest
Posts: n/a
 
      10-26-2004
>>>>> "M" == Markus <> writes:

M> I have a patch (attached). It removes the 8k line limit on error
M> tracking but increases the size of the RNODE to 36 bytes (if I calculate
M> correctly) from the easier to align 32 bytes.

The game is to not change the size of R struct


Guy Decoux


 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      10-26-2004
> The game is to not change the size of R struct

As long as the size of the file is recorded somewhere, then you could use
this to have a varying granularity of line numbers. e.g.

file size recorded accuracy
--------- -----------------
0..8191 exact
8192..16383 to within 2 lines
16384..24575 to within 3 lines
24576..32767 to within 4 lines
... etc

def encode_line(n, filesize)
raise "oops" if n > filesize
x = (filesize >> 13) + 1
n / x
end

def decode_line(n, filesize)
x = (filesize >> 13) + 1
(n*x)..(n*x + x - 1)
end

You get the same lack of resolution in the current system. However, if the
file size is 20000 lines (say), then an error in line 17 could be in line
17, line 8209 or line 16401 - rather than line 15, 16 or 17.

Just a thought.

Regards,

Brian.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read a file line by line and write each line to a file based on the5th byte scad C++ 23 05-17-2009 06:11 PM
How to read a text file line by line and remove some line kaushikshome C++ 4 09-10-2006 10:12 PM
Custom errors and line numbers Buddy Ackerman ASP .Net 6 06-26-2005 01:20 AM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57