Daniel Berger | 15 May 06:24
Picon

Strange bug with common.mk, File, Test::Unit

Hi all,

Ruby 1.8.6-p114
OS X, Solaris, Windows XP and Linux

I added a couple of test tasks in the common.mk file so that I could 
test specific subsets of test files. Below are just two that I added.

daniel-bergers-computer:~/src/ruby/ruby-1.8.6-p114 djberge$ diff -u 
common.orig common.mk
--- common.orig 2007-02-28 06:23:42.000000000 -0700
+++ common.mk   2008-05-14 22:09:14.000000000 -0600
@@ -66,6 +66,8 @@
                         $(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)

  TESTSDIR      = $(srcdir)/test
+TESTSDIR_ARRAY = $(srcdir)/test/core/Array
+TESTSDIR_FILE = $(srcdir)/test/core/File
  TESTWORKDIR   = testwork

  all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
@@ -286,6 +288,12 @@
  test-all:
         $(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" 
--runner=$(TESTUI) $(TESTS)

+test-array:
+       $(RUNRUBY) "$(srcdir)/test/runner.rb" 
--basedir="$(TESTSDIR_ARRAY)" --runner=$(TESTUI) $(TESTS)
+
(Continue reading)

Evan Phoenix | 15 May 03:59
Gravatar

Singleton methods on Float and Bignum

In 1.8 (and 1.9 likely), trying to add a singleton method to a Float  
or Bignum raises a TypeError, even though they aren't immediates.

Tracking it back, I see that the function num_sadded contains a comment:

/* Numerics should be values; singleton_methods should not be added to  
them */

Is this still true? Is there a real reason to not allow methods  
singleton methods to be added to Float or Bignum instances?

  - Evan Phoenix

Brian Ford | 14 May 21:01
Picon
Gravatar

The RubySpec project at rubyspec.org

Hi all,

Cross-posting this here for those of you who find sipping from the
firehose that is ruby-talk to be a bit overwhelming.

http://groups.google.com/group/ruby-talk-google/browse_thread/thread/e20f76ca2b8afe78

Cheers,
Brian

Christopher Thompson | 14 May 01:19
Favicon

Minor memory leak in 1.8.6?

Is it not the case that rb_Str_to_inum(str, base, badcheck) in bignum.c 
leaks the memory allocated with ALLOCA_N?

I think it should always be the case that the string has a sentinel and 
so if we end up running that section, there's already a bug, in which 
case this may not be worth worrying about.

VALUE
rb_str_to_inum(str, base, badcheck)
     VALUE str;
     int base;
     int badcheck;
{
     char *s;
     long len;

     StringValue(str);
     if (badcheck) {
	s = StringValueCStr(str);
     }
     else {
	s = RSTRING(str)->ptr;
     }
     if (s) {
	len = RSTRING(str)->len;
	if (s[len]) {		/* no sentinel somehow */
	    char *p = ALLOCA_N(char, len+1);  /* THIS BIT HERE */

	    MEMCPY(p, s, char, len);
	    p[len] = '\0';
(Continue reading)

Christopher Thompson | 14 May 01:19
Favicon

Minor memory leak in 1.8.6?

Is it not the case that rb_Str_to_inum(str, base, badcheck) in bignum.c 
leaks the memory allocated with ALLOCA_N?

I think it should always be the case that the string has a sentinel and 
so if we end up running that section, there's already a bug, in which 
case this may not be worth worrying about.

VALUE
rb_str_to_inum(str, base, badcheck)
     VALUE str;
     int base;
     int badcheck;
{
     char *s;
     long len;

     StringValue(str);
     if (badcheck) {
	s = StringValueCStr(str);
     }
     else {
	s = RSTRING(str)->ptr;
     }
     if (s) {
	len = RSTRING(str)->len;
	if (s[len]) {		/* no sentinel somehow */
	    char *p = ALLOCA_N(char, len+1);  /* THIS BIT HERE */

	    MEMCPY(p, s, char, len);
	    p[len] = '\0';
(Continue reading)

Stephen Bannasch | 13 May 19:25

errors running make test

I updated to revision 16403 and now compiling and running ruby1.9 
works [thanks Nobu].

I get the errors below running: make test -- I haven't been working 
with 1.9 before and am not certain just what error is being reported 
below.  Is the failure that ends the tests below in sample/eval.rb?

$ make test
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb  -I. 
-rrbconfig ./tool/compile_prelude.rb \
		./prelude.rb ./enc/prelude.rb ./gem_prelude.rb prelude.c.new
./tool/ifchange "prelude.c" "prelude.c.new"
prelude.c unchanged

sample/test.rb:assignment 
.............................................................................................................................................................................................................................................................................................................................................
sample/test.rb:condition ..
sample/test.rb:if/unless ...
sample/test.rb:case .....
sample/test.rb:while/until ........
sample/test.rb:exception .......
sample/test.rb:array .......................................
sample/test.rb:hash ...........................
sample/test.rb:iterator 
...............................................................................................................
sample/test.rb:float 
................................................................................
sample/test.rb:bignum ...............................
sample/test.rb:string & char 
..............................................................
(Continue reading)

Stephen Bannasch | 13 May 07:24

problems compiling 1.9 on MacOS 10.5.2


I'm getting errors that purelib.rb can't be found compiling Ruby 1.9 
on MacOS 10.5.2.

ruby trunk r16372

mkdir ruby1.9
cd ruby1.9/
svn co http://svn.ruby-lang.org/repos/ruby/trunk src
cd src
autoconf
./configure --prefix=/Users/stephen/dev/ruby1.9
make

...

gcc -g -O2 -pipe -fno-common    -I. -I.ext/include/i686-darwin9.2.2 
-I./include -I.  -DRUBY_EXPORT -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -o 
blockinlining.o -c blockinlining.c
rm -f ruby
ruby -Ks ./tool/insns2vm.rb --srcdir="." insns.inc
ruby: no such file to load -- purelib.rb (LoadError)
make: *** [insns.inc] Error 1

However purelib.rb is in ext/ dir:

$ ls ext/purelib.rb
ext/purelib.rb

(Continue reading)

Christopher Thompson | 12 May 19:23
Favicon

Buffer overflow in Ruby 1.8.6?

I think I have found a minor buffer overflow in string.c in Ruby 1.8.6. 
  I could very easily be wrong.  I would appreciate feedback either way.

Roughly around line 739, we have the following code:
VALUE
rb_str_cat(str, ptr, len)
     VALUE str;
     const char *ptr;
     long len;
{
     if (len < 0) {
	rb_raise(rb_eArgError, "negative string size (or size too big)");
     }
     if (FL_TEST(str, STR_ASSOC)) {
	rb_str_modify(str);
	REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+len);
	memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len);
	RSTRING(str)->len += len;
	RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; /* sentinel */
	return str;
     }

     return rb_str_buf_cat(str, ptr, len);
}

I believe the REALLOC_N line is incorrect.  Instead of:
REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+len);
I believe it should be:
REALLOC_N(RSTRING(str)->ptr, char, RSTRING(str)->len+len+1);

(Continue reading)

Charles Thornton | 12 May 13:33

IRHG -- Small Problem with Multi Character Translation

Core,

  In trying to translate the following from chapter08 =

    I am totally unfamiliar with multi-byte character codings
can some one tell me what is meant here about character sets...

------------------------------------------------------------------------------------------------------------------------------------------------------------
<pre class="emlist">
In addition<code>Ruby</code>In command<code>-K</code>When option is 
acquired, the multiple byte character string
It reaches the point where it passes. As for presently it is
corresponding EUC-JP (<code>-Ke</code>)
Shift JIS (<code>-Ks</code>) UTF8 (<code>-Ku</code>) It is three.
</p></pre>

<pre class="emlist">
' "Chinese character passes", that "multiple byte letter passes", just
a little it is different, '
</pre>
----------------------------------------------------------------------------------------------------------------

Any help would be appreciated

Thanks,

      Chuck T.

ts | 12 May 10:59
Picon
Picon

defined?(C &&= 0)


 1.8 and 1.9 disagree with 'defined?(C &&= 0)'

vgs% ./ruby -ve 'p defined?(C &&= 0)'
ruby 1.9.0 (2008-05-12 revision 16388) [i686-linux]
"assignment"
vgs% 

vgs% /usr/bin/ruby -ve 'p defined?(C &&= 0)'
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
nil
vgs% 

 which is right ?

 another small difference

vgs% ./ruby -ve 'p defined?(a &&= 0)'
ruby 1.9.0 (2008-05-12 revision 16388) [i686-linux]
"assignment"
vgs% 

vgs% /usr/bin/ruby -ve 'p defined?(a &&= 0)'
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
"expression"
vgs% 

Guy Decoux

(Continue reading)

Charles Thornton | 12 May 00:28

IRHG -- NEW RELEASE -- Chapter 05 Complete and Moving On

Core,

  RHG_5_11_2008.tgz  (At: hawthorne-press.com) has been released.

  This release completes chapter 05 (Garbage Collection!)

  Cheers

  Chuck Thornton


Gmane