[Bug #3030] make test-all fails with zlib 1.2.4

Bug #3030: make test-all fails with zlib 1.2.4
http://redmine.ruby-lang.org/issues/show/3030

e$B5/I<<Te(B: Takashi T.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: ext, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-03-26 trunk 27066) [x86_64-darwin10.2.0]

1.9 e$B$Ne(B trunk e$B$Ge(B make test-all e$B$9$k$H!“e(B
zlib e$B4XO”$G0J2<$N$h$&$J%(%i!<$,$"$j$^$9!#e(B

$ ./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:intest_params’

2010/3/28 Takashi T. [email protected]:

1.9 e$B$Ne(B trunk e$B$Ge(B make test-all e$B$9$k$H!“e(B
zlib e$B4XO”$G0J2<$N$h$&$J%(%i!<$,$"$j$^$9!#e(B

ruby_1_8e$B$G$bF1MM$G$7$?!#e(Bzlib 1.2.4e$B$X$NDI=>$,I,MW$G$9$M!#e(B
e$B$3$l$be(Bmaintainere$B$,5o$J$$$N$+!#$I$J$?$+DI$$$+$1$F$k?M$O5o$^$9$+!)e(B
e$B$$$J$1$l$P$d$j$^$9!#e(B

[email protected]$G$9!#e(B

At Sun, 28 Mar 2010 16:39:07 +0900,
Takashi T. 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:intest_params’

1.2.4e$B$Ne(BdeflateParams()e$B$,!"$9$G$Ke(Bflushe$B$7$F$$$k$N$K:FEYF1$8%G!<%?e(B
e$B$rDI2C$7$F$$$k$h$&$G$9!#$=$l$r$A$c$s$H%+%&%s%H$7$F$$$J$$$N$Oe(B
ext/zlibe$B$N%P%[email protected]$H;W$&$N$G$9$,!“e(Bzlib
1.2.4e$B$N$[$&$b$^$?%P%0$,$”$ke(B
e$B$h$&$J5$$,$7$^$9!#$I$C$A$,$$$$$s$G$7$g$&$M$’!#e(B

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);

e$B%A%1%C%He(B #3030 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

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.


http://redmine.ruby-lang.org/issues/show/3030

e$B%A%1%C%He(B #3030 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$BC4Ev<Te(B Yusuke E.e$B$K%;%C%He(B

e$B1sF#$G$9!#e(B

1.2.4e$B$Ne(BdeflateParams()e$B$,!"$9$G$Ke(Bflushe$B$7$F$$$k$N$K:FEYF1$8%G!<%?e(B
e$B$rDI2C$7$F$$$k$h$&$G$9!#$=$l$r$A$c$s$H%+%&%s%H$7$F$$$J$$$N$Oe(B
ext/zlibe$B$N%P%[email protected]$H;W$&$N$G$9$,!“e(Bzlib 1.2.4e$B$N$[$&$b$^$?%P%0$,$”$ke(B
e$B$h$&$J5$$,$7$^$9!#$I$C$A$,$$$$$s$G$7$g$&$M$’!#e(B

zlib 1.2.5 e$B$G3N$+$a$^$7$?$,!“e(Bzlib
e$BK\BN$K%P%0$O$J$$$H;W$$$^$9!#e(B
deflateParams e$B$,e(B flush e$B$7$F$k$N$O!”%G!<%?$G$O$J$/!"e(Bbyte
boundary e$B$Ke(B
align e$B$5$;$k$?$a$Ne(B dummy block (e$BE83+$7$F$bD9$5e(B 0
e$B$K$J$k%V%m%C%/e(B) e$B$Ne(B
e$B$h$&$G$9!#e(B

ext/zlib e$BB&$G$o$6$o$6e(B Z_SYNC_FLUSH
e$B$7$J$1$l$PM>7W$J%G!<%?$,=P$J$/e(B
e$B$J$k$H;W$$$^$9!#$3$Ne(B flush e$B$Oe(B #239
[email protected]$9$k$?$a$KF~$C$?e(B (r18029)
e$B$N$G$9$,$3$l$O4V0c$C$?2r7hJ}K!$G!":#[email protected]$5$s$N%Q%C%A$N$h$&$Ke(B
deflatePrams [email protected],%+%&%s%?$r99?7$9$k$N$,@5$7$$2r7hJ}K!$G$7$?!#e(B
(e$B$^$C$?$/C/$,$3$s$JJQ$Je(B flush e$B$rF~$l$?$s$G$7$g$&$M!#e(B)

e$B$H$$$&$o$1$G!"0J2<$N%Q%C%A$G$h$$$H;W$$$^$9!#e(B

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 E. [email protected]

http://redmine.ruby-lang.org/issues/show/3030

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs