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) over 14 years ago. Updated almost 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 #1

Updated by nobu (Nobuyoshi Nakada) over 14 years ago

=begin
Hi,

At Wed, 25 Nov 2009 09:22:52 +0900,
Florian Frank wrote in [ruby-core:26899]:

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

I don't think it is.

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?

Rather, you should get rid of such too long messages, IMO.
Who wants to see the flood by a message?

--
Nobu Nakada

=end

Actions #2

Updated by ujihisa (Tatsuhiro Ujihisa) over 14 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin

=end

Actions #3

Updated by nobu (Nobuyoshi Nakada) about 14 years ago

  • Status changed from Assigned to Rejected

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0