Project

General

Profile

Actions

Bug #3030

closed

make test-all fails with zlib 1.2.4

Added by sheepman (Takashi Tamura) about 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-03-26 trunk 27066) [x86_64-darwin10.2.0]
Backport:
[ruby-dev:40802]

Description

=begin
1.9 の trunk で make test-all すると、
zlib 関連で以下のようなエラーがあります。

$ ./ruby -v
ruby 1.9.2dev (2010-03-26 trunk 27066) [x86_64-darwin10.2.0]

$ port info zlib
zlib @1.2.4, Revision 1 (archivers)

  1. Error:
    test_params(TestZlibDeflate):
    Zlib::BufError: buffer error
    /Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in inflate' /Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in test_params'
    =end
Actions #1

Updated by nahi (Hiroshi Nakamura) almost 14 years ago

=begin
2010/3/28 Takashi Tamura :

1.9 の trunk で make test-all すると、
zlib 関連で以下のようなエラーがあります。

ruby_1_8でも同様でした。zlib 1.2.4への追従が必要ですね。
これもmaintainerが居ないのか。どなたか追いかけてる人は居ますか?
いなければやります。

=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 14 years ago

=begin
なかだです。

At Sun, 28 Mar 2010 16:39:07 +0900,
Takashi Tamura wrote in [ruby-dev:40802]:

$ port info zlib
zlib @1.2.4, Revision 1 (archivers)

  1. Error:
    test_params(TestZlibDeflate):
    Zlib::BufError: buffer error
    /Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in inflate' /Users/tamura/ruby/src/ruby19/test/zlib/test_zlib.rb:129:in test_params'

1.2.4のdeflateParams()が、すでにflushしているのに再度同じデータ
を追加しているようです。それをちゃんとカウントしていないのは
ext/zlibのバグだと思うのですが、zlib 1.2.4のほうもまたバグがある
ような気がします。どっちがいいんでしょうねぇ。


diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 435a1a6..fbeb72a 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1371,16 +1371,31 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
struct zstream *z = get_zstream(obj);
int level, strategy;
int err;

  • uInt n; /* workaround for 1.2.4 */
    +#if 0

  • /* add extra data */
    +#define ADJUST(z, n) (z->buf_filled += n - z->stream.avail_out)
    +#else

  • /* drop extra data */
    +#define ADJUST(z, n) ( \

  • z->stream.next_out -= n - z->stream.avail_out, \

  • z->stream.avail_out = n)
    +#endif

    level = ARG_LEVEL(v_level);
    strategy = ARG_STRATEGY(v_strategy);

    zstream_run(z, (Bytef*)"", 0, Z_SYNC_FLUSH);

  • zstream_run(z, (Bytef*)"", 0, Z_SYNC_FLUSH);

  • n = z->stream.avail_out;
    err = deflateParams(&z->stream, level, strategy);

  • ADJUST(z, n);
    while (err == Z_BUF_ERROR) {
    rb_warning("deflateParams() returned Z_BUF_ERROR");
    zstream_expand_buffer(z);

  • n = z->stream.avail_out;
    err = deflateParams(&z->stream, level, strategy);

  • ADJUST(z, n);
    }
    if (err != Z_OK) {
    raise_zlib_error(err, z->stream.msg);

--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦

=end

Actions #3

Updated by mame (Yusuke Endoh) almost 14 years ago

  • Assignee set to mame (Yusuke Endoh)

=begin
遠藤です。

1.2.4のdeflateParams()が、すでにflushしているのに再度同じデータ
を追加しているようです。それをちゃんとカウントしていないのは
ext/zlibのバグだと思うのですが、zlib 1.2.4のほうもまたバグがある
ような気がします。どっちがいいんでしょうねぇ。

zlib 1.2.5 で確かめましたが、zlib 本体にバグはないと思います。
deflateParams が flush してるのは、データではなく、byte boundary に
align させるための dummy block (展開しても長さ 0 になるブロック) の
ようです。

ext/zlib 側でわざわざ Z_SYNC_FLUSH しなければ余計なデータが出なく
なると思います。この flush は #239 を修正するために入った (r18029)
のですがこれは間違った解決方法で、今回のなかださんのパッチのように
deflatePrams 進んだ分カウンタを更新するのが正しい解決方法でした。
(まったく誰がこんな変な flush を入れたんでしょうね。)

というわけで、以下のパッチでよいと思います。

diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 435a1a6..8c3af3d 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1371,16 +1371,20 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
struct zstream *z = get_zstream(obj);
int level, strategy;
int err;

  • uInt n;

    level = ARG_LEVEL(v_level);
    strategy = ARG_STRATEGY(v_strategy);

  • zstream_run(z, (Bytef*)"", 0, Z_SYNC_FLUSH);
  • n = z->stream.avail_out;
    err = deflateParams(&z->stream, level, strategy);
  • z->buf_filled += n - z->stream.avail_out;
    while (err == Z_BUF_ERROR) {
    rb_warning("deflateParams() returned Z_BUF_ERROR");
    zstream_expand_buffer(z);
  • n = z->stream.avail_out;
    err = deflateParams(&z->stream, level, strategy);
  • z->buf_filled += n - z->stream.avail_out;
    }
    if (err != Z_OK) {
    raise_zlib_error(err, z->stream.msg);

--
Yusuke Endoh
=end

Actions #4

Updated by mame (Yusuke Endoh) almost 14 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27423.
Takashi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0