Project

General

Profile

Actions

Bug #2400

closed

string formating in, e. g. rb_raise, is truncated differently depending on OS/build environment

Added by flori (Florian Frank) almost 15 years ago. Updated over 13 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.7.0]
[ruby-core:26899]

Description

=begin
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?
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0