Summary: | dev-lang/ruby fails to build with glibc-2.14 | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Diego Elio Pettenò (RETIRED) <flameeyes> |
Component: | New packages | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | andriy155, ao, b.brachaczek, bkohler, bob.deblier, bugs+gentoo, bugzie, carlphilippreh, che, chris, dark, darkcircle.0426, gentoo, godzil, graham, hanno, help, hwoarang, ian, jlec, kripton, ksuves, kuba.iluvatar, leonchik1976, lmedinas, lpmichalik, m.debruijne, mark_alec, massimobalestra, mitaspiotr, mmokrejs, muzuiget, pesa, rose, ruby, shkdmb, steven, StormByte, tetromino, tsg, ulm, vityokster, zeekec |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | http://redmine.ruby-lang.org/issues/5108 | ||
See Also: | http://sourceware.org/bugzilla/show_bug.cgi?id=12724 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 370409 | ||
Attachments: |
Build log
Build log 0068_all_glibc-2.14-glibc-revert-fseek-on-fclose.patch |
Description
Diego Elio Pettenò (RETIRED)
2011-06-07 06:58:23 UTC
Created attachment 276115 [details]
Build log
*** Bug 377213 has been marked as a duplicate of this bug. *** I saw a workarround for this on github, consider taking it a look: https://gist.github.com/1057203 I'll braindump here what i have found out. It's likely caused by this change in glibc: http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fcabc0f8b185f9e0a9289720be5ede6c39b3bf21#patch5 Why i think so: The simplest test case i was able to get is the following: sf dl # pwd /var/tmp/portage/dev-lang/ruby-1.8.7_p334-r2/work/ruby-1.8.7-p334/ext/dl sf dl # cat mkfoo.rb # -*- ruby -*- # we emulate emulate # require 'mkmf' # > @orgerr = $stderr.dup # > @orgout = $stdout.dup # orgout = $stdout.dup #more than 4kb, seems to be a glibc's buffer printf("1\n" * 2048) printf("2\n" * 32) sf dl # ../../miniruby mkfoo.rb > a.foo; head -n 2 a.foo 2 2 The head is overwritten. Let's look at the strace log: sf dl $ strace -etrace=open,write,close,lseek,dup,dup2,execve ../../miniruby mkfoo.rb > a.foo; head -n 2 a.foo ... [snippet] ... [1] dup(1) = 3 lseek(3, 0, SEEK_CUR) = 0 lseek(1, 0, SEEK_CUR) = 0 lseek(3, 0, SEEK_SET) = 0 [2] write(1, "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"..., 4096) = 4096 [3] lseek(3, 0, SEEK_SET) = 0 [4] close(3) = 0 [5] write(1, "2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n"..., 64) = 64 2 2 Here we see: [1] fd=3 is an alias of fd=1 (stdout) [2] part of print()s is written to disk [4] 'orgout' is garbage collected out (program shutdowns) [3] and right before fclose() glibc "restores" pointer of file descriptor (offest for fd=3 is 0, as nobody written to the dupped fd). [5] last bits of stdout are flushed to fd=1, but it's descriptor is shifted, so last write overwrites head I don't know how to fix it properly. I see such variants: 1. all mkfmrb users must call $stdout.flush at the end of file 2. Ruby's implementation of IO#dup(io.c:rb_io_init_copy:rb_fdopen) and it's finalizer (io.c:fptr_finalize:fclose) should not use fdopen/fclose. Or should restore position properly. 3. fix mkfm Logger module Thus, the workaround for this particular case is the following: --- mkcallback.rb.orig 2011-08-10 19:20:59.338487021 +0300 +++ mkcallback.rb 2011-08-10 19:20:39.154739353 +0300 @@ -54,3 +54,5 @@ print(mkfunc(t, n, 15), "\n\n") end } + +$stdout.flush (In reply to comment #4) Thanks for digging in! > Thus, the workaround for this particular case is the following: > > --- mkcallback.rb.orig 2011-08-10 19:20:59.338487021 +0300 > +++ mkcallback.rb 2011-08-10 19:20:39.154739353 +0300 > @@ -54,3 +54,5 @@ > print(mkfunc(t, n, 15), "\n\n") > end > } > + > +$stdout.flush But if we do this then we fix the installation of ruby itself, but code using ruby will behave differently depending on the glibc version underneath it and thus "randomly" break things. Option 2 (fix IO::dup) is probably the solution we should aim at, but also something that is outside our own scope. If someone wants to work on this it's probably better to do so on the upstream bug directly. The conclusion appears to be that this is a bug in glibc instead. See http://sourceware.org/bugzilla/show_bug.cgi?id=12724 Reassigning accordingly. *** Bug 385961 has been marked as a duplicate of this bug. *** *** Bug 391969 has been marked as a duplicate of this bug. *** *** Bug 392415 has been marked as a duplicate of this bug. *** *** Bug 392611 has been marked as a duplicate of this bug. *** Upstream bug report, with patch: http://redmine.ruby-lang.org/issues/5108 Builds ok with the patch... but I don't actively USE ruby myself, but: Tue Nov 29 18:49:02 2011 >>> sys-libs/glibc-2.14.1-r1 Thu Dec 1 09:11:23 2011 >>> dev-lang/ruby-1.8.7_p352 # ruby --version ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] (In reply to comment #11) > Upstream bug report, with patch: http://redmine.ruby-lang.org/issues/5108 Already linked to the bug in the URL field. Also, as mentioned in comment #5, the patch would only fix the ruby build but leave users of this module open for similar, but probably much harder to detect, problems. *** Bug 392741 has been marked as a duplicate of this bug. *** *** Bug 393101 has been marked as a duplicate of this bug. *** Created attachment 294893 [details, diff]
0068_all_glibc-2.14-glibc-revert-fseek-on-fclose.patch
try this patch; it comes from opensuse. place it in /etc/portage/patches/sys-libs/glibc/ and re-emerge glibc. see if it fixes the troubles with ruby.
Works here! queued it up then http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.14.1/0068_all_glibc-2.14-glibc-revert-fseek-on-fclose.patch?rev=1.1 *** Bug 393349 has been marked as a duplicate of this bug. *** *** Bug 393417 has been marked as a duplicate of this bug. *** *** Bug 394215 has been marked as a duplicate of this bug. *** I have sys-libs/glibc-2.14.1-r1 and I still have this problem. Has the patch been inserted in portage without a version bump or is it still in approval process? I also noticed that dev-lang/ruby-1.9.3_rc1 compiles fine without patched glibc. Ditto comment 22. Me too. I still have this problem building ruby-1.8.7_p352 with glibc-2.14.1-r1 on an old x86 machine, but it worked on my newer amd64 machine. The patch isn't in glibc-2.14.1-patches-2.tar.bz2, so I guess we need to wait for glibc-2.14.1-patches-3.tar.bz2 and sys-libs/glibc-2.14.1-r2. My previous comment 23 saying ruby built okay on my amd64 machine with glibc-2.14.1-r1 was incorrect; I should have checked my emerge logs first! *** Bug 395137 has been marked as a duplicate of this bug. *** This bug was resolved as "fixed" over a fortnight ago. Any news on when a patched version of glibc >=2.14.1 containing the fix will be released to portage? *** Bug 395325 has been marked as a duplicate of this bug. *** ruby compiled for me after adding the patch to /etc/portage/patches/sys-libs/glibc/ emerge --info System uname: Linux-3.1.5-gentoo-x86_64-AMD_Phenom-tm-_9150e_Quad-Core_Processor-with-gentoo-2.1 Timestamp of tree: Thu, 22 Dec 2011 18:45:01 +0000 app-shells/bash: 4.2_p20 dev-java/java-config: 2.1.11-r3 dev-lang/python: 2.7.2-r3, 3.1.4-r3, 3.2.2 dev-util/cmake: 2.8.6-r4 dev-util/pkgconfig: 0.26 sys-apps/baselayout: 2.1 sys-apps/openrc: 0.9.7 sys-apps/sandbox: 2.5 sys-devel/autoconf: 2.13, 2.68 sys-devel/automake: 1.9.6-r3, 1.10.3, 1.11.1-r1 sys-devel/binutils: 2.22-r1 sys-devel/gcc: 4.5.3-r2 sys-devel/gcc-config: 1.5-r2 sys-devel/libtool: 2.4.2 sys-devel/make: 3.82-r3 sys-kernel/linux-headers: 3.1 (virtual/os-headers) sys-libs/glibc: 2.14.1-r1 Repositories: gentoo x11 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="*" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -march=athlon64-sse3 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /var/lib/hsqldb" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-O2 -march=athlon64-sse3 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch" FFLAGS="" GENTOO_MIRRORS="http://www.cyberuse.com/gentoo/ http://mirror.datapipe.net/gentoo ftp://mirror.datapipe.net/gentoo http://gentoo.mirrors.easynews.com/linux/gentoo/ http://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/ ftp://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/ http://distro.ibiblio.org/pub/linux/distributions/gentoo/ rsync://distro.ibiblio.org/pub/linux/distributions/gentoo/ ftp://ftp.ussg.iu.edu/pub/linux/gentoo http://lug.mtu.edu/gentoo/ ftp://lug.mtu.edu/gentoo/ ftp://gentoo.netnitco.net/pub/mirrors/gentoo/source/ http://gentoo.netnitco.net http://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/ ftp://gentoo.mirrors.pair.com/ rsync://mirrors.rit.edu/gentoo/ ftp://mirrors.rit.edu/gentoo/ http://mirrors.rit.edu/gentoo/ ftp://mirror.iawnet.sandia.gov/pub/gentoo/ http://mirror.iawnet.sandia.gov/gentoo/ ftp://gentoo.llarian.net/pub/gentoo http://gentoo.llarian.net/ ftp://gentoo.mirrors.tds.net/gentoo rsync://gentoo.mirrors.tds.net/gentoo http://gentoo.mirrors.tds.net/gentoo http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ ftp://ftp.lug.udel.edu/pub/gentoo/ http://mirror.lug.udel.edu/pub/gentoo/ ftp://mirror.its.uidaho.edu/gentoo/ http://mirror.its.uidaho.edu/pub/gentoo/ http://gentoo.cites.uiuc.edu/pub/gentoo/ ftp://gentoo.cites.uiuc.edu/pub/gentoo/ rsync://gentoo.cs.uni.edu/gentoo-distfiles http://gentoo.cs.uni.edu/ http://mirror.usu.edu/mirrors/gentoo/ ftp://ftp.wallawalla.edu/pub/mirrors/ftp.gentoo.org" LANG="en_US.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j5" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/var/lib/layman/x11" SYNC="rsync://rsync.us.gentoo.org/gentoo-portage" USE="X a52 aac acl acpi additions alsa amd64 apng automount branding bzip2 cairo cdda cdr cli consolekit cracklib crypt cups cxx dbus dirac doc dri dts dvd dvdr emboss encode exif extras facc fadd fam firefox flac fontconfig fortran gd gdbm gdu gif gnome gpm gtk hddtemp iconv introspection iostats ipv6 java jpeg kdrive lcms ldap libnotify live lm_sensors lock lua lua-cairo lua-imlib lxde mad math mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses network nls nptl nptlonly ogg opengl openmp pam pango pcre pdf png policykit ppds pppd pulseaudio python qt-bundled qt3support qt4 readline rss scanner sdl session sound spell sqlite sse sse2 ssl startup-notification static-libs svg sysfs tcpd tiff truetype udev unicode usb utp vorbis x264 xcb xml xorg xulrunner xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="ati vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS (In reply to comment #18) > queued it up then > > http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.14.1/0068_all_glibc-2.14-glibc-revert-fseek-on-fclose.patch?rev=1.1 Can you please release this patch? We just had a security bump for ruby over in bug 396301 but with current glibc people won't be able to update to that version. *** Bug 396391 has been marked as a duplicate of this bug. *** *** Bug 396393 has been marked as a duplicate of this bug. *** *** Bug 396407 has been marked as a duplicate of this bug. *** Why is it marked RESOLVED FIXED if it's not fixed? *** Bug 396409 has been marked as a duplicate of this bug. *** Reopening this since it is not fixed in CVS and many people are now hitting this. *** Bug 396423 has been marked as a duplicate of this bug. *** (In reply to comment #6) > The conclusion appears to be that this is a bug in glibc instead. See > http://sourceware.org/bugzilla/show_bug.cgi?id=12724 > > Reassigning accordingly. Is this a bug in glibc, as (at least on my ~x86 system) glibc 2.14.1-r1 seems to have the that bug fixed as the sample program in the bug runs successfully (ie none of the asserts trigger). So if anything it looks like the fix to the glibc bug has triggered a problem in ruby, so should it not be fixed in ruby rather than reverting the change to glibc? (In reply to comment #37) > (In reply to comment #6) > > The conclusion appears to be that this is a bug in glibc instead. See > > http://sourceware.org/bugzilla/show_bug.cgi?id=12724 > > > > Reassigning accordingly. > > Is this a bug in glibc, as (at least on my ~x86 system) glibc 2.14.1-r1 seems > to have the that bug fixed as the sample program in the bug runs successfully > (ie none of the asserts trigger). So if anything it looks like the fix to the > glibc bug has triggered a problem in ruby, so should it not be fixed in ruby > rather than reverting the change to glibc? Not a glibc bug imho. The patch presented here reverts functionality introduced to adhere standards and as such changes glibc'S behavior if reverted. This needs to be fixed in ruby. Patch attached to bug #396393 fixes the problem with ruby, IMHO. (In reply to comment #38) > (In reply to comment #37) > > (In reply to comment #6) > > > The conclusion appears to be that this is a bug in glibc instead. See > > > http://sourceware.org/bugzilla/show_bug.cgi?id=12724 > > > > > > Reassigning accordingly. > > > > Is this a bug in glibc, as (at least on my ~x86 system) glibc 2.14.1-r1 seems > > to have the that bug fixed as the sample program in the bug runs successfully > > (ie none of the asserts trigger). So if anything it looks like the fix to the > > glibc bug has triggered a problem in ruby, so should it not be fixed in ruby > > rather than reverting the change to glibc? > > Not a glibc bug imho. The patch presented here reverts functionality introduced > to adhere standards and as such changes glibc'S behavior if reverted. This > needs to be fixed in ruby. Nope, while the patch in glibc fixes one aspect, it doesn't fix another, leaving a non-POSIX solution in place that ruby happens to trip up. This needs to be reverted or fixed properly in glibc, which is what Mike already has done (but not added to our main tree yet). (In reply to comment #39) > Patch attached to bug #396393 fixes the problem with ruby, IMHO. It doesn't. True, it let's ruby's own build process continue, but this still leaves broken code around that will trip up other people's code. I'd rather ruby doesn't build at all in that case. *** Bug 396563 has been marked as a duplicate of this bug. *** *** Bug 396645 has been marked as a duplicate of this bug. *** *** Bug 404399 has been marked as a duplicate of this bug. *** |