Bug 8471 - find+sort regression (no output after sort)
Summary: find+sort regression (no output after sort)
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.24.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-19 18:24 UTC by alex hauras
Modified: 2016-03-18 05:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments
config to reproduce bug (26.31 KB, text/plain)
2016-01-04 05:31 UTC, alex hauras
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alex hauras 2015-11-19 18:24:45 UTC
here is sample case:

busybox 1.23.2:

$touch 1 2 3 4 5; find ./; echo "---"; find ./ |sort
./
./5
./4
./3
./2
./1
---
./
./1
./2
./3
./4
./5

busybox 1.24.1:

$touch 1 2 3 4 5; find ./; echo "---"; find ./ |sort
./
./5
./4
./3
./2
./1
---
Comment 1 Denys Vlasenko 2016-01-03 21:33:27 UTC
Can't reproduce. Please reopen and attach your .config
Comment 2 alex hauras 2016-01-04 05:31:10 UTC
Created attachment 6271 [details]
config to reproduce bug

Config file is generated by 'make oldconfig' with majority of questions set to "no" from working 1.23.2 config.
Comment 3 Denys Vlasenko 2016-01-17 02:58:54 UTC
I can't reproduce it even with your config.

You will have to look deeper on the system which exhibits the bug, or try reproducing it under qemu. See

https://busybox.net/FAQ.html#emu
Comment 4 alex hauras 2016-01-17 07:12:58 UTC
Here is qemu image of buggy busybox: http://rghost.ru/6MY9rYpFF#
(external link due to file size limit in bugzilla)

I got this image from http://wiki.qemu.org/Testing and added busybox and busybox_unstripped, both configs (working 1.23.2 and buggy 1.24.1), and test case.
Image can be mounted with -o loop to transfer files


run command:
#qemu-system-i386 -m 256 -hda ./linux-0.2.img

testcase:

cd /busybox-test
./testcase.sh
Comment 5 alex hauras 2016-01-17 07:17:41 UTC
Above link is compessed image (via xz), if you need uncompressed image (about 20mb), please use this link: http://rghost.ru/7KbZxGqMP
Comment 6 alex hauras 2016-02-23 06:56:38 UTC
I noticed that this bug is somehow releated to glibc/and/or gcc.
On glibc 2.11.3 + gcc 4.4.4 it can be reproduced,
but when I switch to glibc 2.22 + gcc 4.9.3, it's gone.
Comment 7 Denys Vlasenko 2016-03-16 20:01:03 UTC
Reproduced in qemu.
This looks like a reappearance of an old glibc bug where stdout wasn't flushed on exit, because glibc uses some linker magic to achieve that and --gc-sections was breaking it. The symptom was that "CMD" which outputs a lew lines of text was working, but "CMD | cat" was printing nothing.

scripts/trylink has a workaround:

# Static linking against glibc produces buggy executables
# (glibc does not cope well with ld --gc-sections).
# See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
# Note that glibc is unsuitable for static linking anyway.
# We are removing -Wl,--gc-sections from link command line.
GC_SECTIONS="-Wl,--gc-sections"
if (. ./.config && test x"$CONFIG_STATIC" = x"y") then
    if check_libc_is_glibc; then
        echo "Static linking against glibc, can't use --gc-sections"
        GC_SECTIONS=""
    fi
fi

(1) Do you see the "Static linking against glibc, can't use --gc-sections" message when you build the buggy executable?

(2) If you switch CONFIG_STATIC=y to off, change nothing else, and rebuild bbox, does resulting binary still show the bug?

If both answers are "yes", then glibc is now broken wrt static linking in a different way than before...
Comment 8 alex hauras 2016-03-17 09:18:33 UTC
1.
With busybox 1.23.2 (not buggy) there is no such message.
With busybox 1.24.1 (buggy) i see that message.

I noticed some inconsistence in trylink between git and release (http://busybox.net/downloads/busybox-1.24.1.tar.bz2) image:
--- ./trylink.1241      2015-10-24 07:27:41.000000000 +0700
+++ ./trylink.git       2016-03-17 15:07:37.000000000 +0600
@@ -54,7 +54,7 @@
     # "eval" may be needed if CFLAGS can contain
     # '... -D"BB_VER=KBUILD_STR(1.N.M)" ...'
     # and we need shell to process quotes!
-    $CC $CFLAGS $1 "$tempname".c -o "$tempname" >/dev/null 2>&1
+    $CC $CFLAGS $LDFLAGS $1 "$tempname".c -o "$tempname" >/dev/null 2>&1
     r=$?
     rm -f "$tempname" "$tempname".c "$tempname".o
     return $r
@@ -111,7 +111,7 @@
 if (. ./.config && test x"$CONFIG_STATIC" = x"y") then
     if check_libc_is_glibc; then
        echo "Static linking against glibc, can't use --gc-sections"
-#      GC_SECTIONS=""
+       GC_SECTIONS=""
     fi
 fi
 # The --gc-sections option is not supported by older versions of ld

I found LDFLAGS commit: https://git.busybox.net/busybox/commit/?id=77e2bde6a50f0f6b9b3c9983c86e661a9872b5f6
But i cannot find, which commit comments/uncomments GC_SECTIONS in trylink between 1.23.2 and 1.24.1:
https://git.busybox.net/busybox/log/scripts/trylink

With fixed trylink (uncommenting GC_SECTIONS="") bug is gone on busybox 1.24.1

2. dynamic linking also fixes bug.
Comment 9 Denys Vlasenko 2016-03-17 20:44:11 UTC
(In reply to alex hauras from comment #8)
>         echo "Static linking against glibc, can't use --gc-sections"
> -#      GC_SECTIONS=""
> +       GC_SECTIONS=""

Oh no.

Please try http://busybox.net/downloads/busybox-1.24.2.tar.bz2
Comment 10 alex hauras 2016-03-18 05:21:31 UTC
1.24.2 works without bug, thank you!