[#8815] Segfault in libc strlen, via rb_str_new2 — "Sean E. Russell" <ser@...>

Howdy,

12 messages 2006/09/09
[#8817] Re: Segfault in libc strlen, via rb_str_new2 — Eric Hodel <drbrain@...7.net> 2006/09/09

On Sep 8, 2006, at 10:10 PM, Sean E. Russell wrote:

Re: patch bignums

From: Nobuyoshi Nakada <nobu@...>
Date: 2006-09-21 16:30:49 UTC
List: ruby-core #8905
Hi,

At Thu, 21 Sep 2006 23:52:56 +0900,
Ondrej Bilka wrote in [ruby-core:08904]:
> Bugfix and implented bignum odd? and even? 

Thank you, commited.

> BTW. How do you debug ruby. At README.EXT is this missing. 
> I dont know easy way to inspect ruby objects inside gdb. I used printf+guessing what obj contain.
> But now its "obvious bug" free.

I use attached .gdbinit.


Still I don't have time to review the patch, just a nitpicking.

> --- bignum.c	4 Sep 2006 20:10:45 -0000	1.135
> +++ bignum.c	21 Sep 2006 14:46:25 -0000
> @@ -38,6 +38,13 @@
>  
>  #define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
>  
> +VALUE rb_num_plus(VALUE x,VALUE y);
> +VALUE rb_num_minus(VALUE x,VALUE y);
> +VALUE rb_num_mul(VALUE x,VALUE y);
> +VALUE rb_num_sqr(VALUE x);
> +VALUE rb_num_pow(VALUE x,VALUE y);

Why are these in bignum.c?  It feels they are OK in numeric.c.
Also, I suspect this change makes Fixnum operations slower.

> +#define CSTR_TO_BIG_TRESHOLD 32

Is TRESHOLD a typo?

> -    len *= strlen(str)*sizeof(char);
> +	len=strlen(str);
> +	BDIGIT hbase;
> +	long charsperdig;
> +	charperdig(base,&hbase,&charsperdig);
> +	long si=len/charsperdig+1; 

Illegal in C90.

> +	if FIXNUM_P(x) 

Oops.

-- 
Nobu Nakada

In This Thread