Bug #2400: string formating in, e. g. rb_raise, is truncated differently depending on OS/build environment
http://redmine.ruby-lang.org/issues/show/2400

Author: Florian Frank
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]

I am not sure if this is a problem. A method like this:

static VALUE mFoo_raise(VALUE self, VALUE msg)
{
    rb_raise(rb_eRuntimeError, "'%s'", RSTRING_PTR(msg));
}

causes different length in Exception#message on different platforms:

>> [ RUBY_PLATFORM, RUBY_VERSION, RUBY_PATCHLEVEL ] * ' '
 # => "i686-linux 1.8.7 174"
>> Foo.raise "a" * 10_000 rescue $!.message.size 
 # => 8191

>> [ RUBY_PLATFORM, RUBY_VERSION, RUBY_PATCHLEVEL ] * ' '
 # => "i686-darwin9.7.0 1.8.7 174"
>> Foo.raise "a" * 10_000 rescue $!.message.size 
 # => 1023

Under Windows this seems to be 511.

The same happens also in rb_warn and maybe a lot of other ruby functions. Apparently the variable BUFSIZ defined in stdio.h determines the length of this formatting buffer in the source file error.c, but it has a different value on different platforms. Maybe the buffers should all have the same length?


----------------------------------------
http://redmine.ruby-lang.org