Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 590578 - sys-devel/binutils-2.25.1-r1 ld buffer overflow when LANG=bg_BG.utf8
Summary: sys-devel/binutils-2.25.1-r1 ld buffer overflow when LANG=bg_BG.utf8
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal major (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-05 16:44 UTC by blackd
Modified: 2017-03-12 21:52 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
genkernel output (genkernel-output.txt,89.28 KB, text/plain)
2016-08-05 16:44 UTC, blackd
Details
emerge --info (file_590578.txt,6.88 KB, text/plain)
2016-08-05 16:48 UTC, blackd
Details
emerge --info second machine (file_590578.txt,5.49 KB, text/plain)
2016-08-10 06:05 UTC, blackd
Details
successful run output (file_590578.txt,79.99 KB, text/plain)
2016-08-10 11:34 UTC, blackd
Details
Failed run output (file_590578.txt,18.13 KB, text/plain)
2016-08-10 11:35 UTC, blackd
Details
backtrace (file_590578.txt,1.98 KB, text/plain)
2016-08-10 11:38 UTC, blackd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description blackd 2016-08-05 16:44:56 UTC
Created attachment 442630 [details]
genkernel output

sys-devel/binutils-2.25.1-r1 ld buffer overflow when env too big and 
LANG=bg_BG.utf8

steps to reproduce:

# emerge genkernel[-next]
# export LANG=bg_BG.utf8
# genkernel --no-clean --no-mrproper --lvm --btrfs --luks --e2fsprogs --color --loglevel=5 --firmware  --compress-initramfs-type=gzip initramfs 

expected result: 
Shiny new initrd file in /boot

Actual result:
busybox build fails see attachment 1 [details]

Workaround:

# env -u LANG genkernel --no-clean --no-mrproper --lvm --btrfs --luks --e2fsprogs --color --loglevel=5 --firmware  --compress-initramfs-type=gzip initramfs


Note:
You might actually need to have bg_BG.utf8 locale to reproduce this I haven't check.
Comment 1 blackd 2016-08-05 16:48:06 UTC
Created attachment 442632 [details]
emerge --info
Comment 2 blackd 2016-08-05 16:49:15 UTC
Well it looks the attachment numbers are global. 
Please disregard "attachment 1 [details]" in the description.
Comment 3 blackd 2016-08-05 17:07:16 UTC
Another way to reproduce it:

# export LANG=bg_BG.utf8
# cd /usr/portage/sys-apps/busybox
# ebuild busybox-1.24.2.ebuild clean configure
# cd /var/tmp/portage/sys-apps/busybox-1.24.2/work/busybox-1.24.2
# make


It's somehow related to -Wl,-Map,.. because if I remove it the build is successful.


-Wl,-Map, is located in /var/tmp/portage/sys-apps/busybox-1.24.2/work/busybox-1.24.2/scripts/trylink

> INFO_OPTS="-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose"
Comment 4 SpanKY gentoo-dev 2016-08-10 03:04:00 UTC
(In reply to blackd from comment #3)

thanks for the simple reproducer, but it's not reproducing for me :/

can you find a way that fails involving:
  env -i PATH="$PATH" LANG="$LANG" make
Comment 5 blackd 2016-08-10 04:58:51 UTC
Hi,

For me it's 100% reproducible on 2 different installation fallowing these steps.


1. edit /etc/locale.gen to only have 
> en_US.UTF-8 UTF-8
> bg_BG.UTF-8 UTF-8

2. # locale-gen

3. fallow the steps form comment 3 with make changed to env -i PATH="$PATH" LANG="$LANG" make
Comment 6 SpanKY gentoo-dev 2016-08-10 05:57:16 UTC
i don't think it's related, but your global compiler settings are broken.  you should never put -fPIC into CFLAGS/CXXFLAGS.  please delete those and rebuild binutils and see if it happens to improve things.
Comment 7 blackd 2016-08-10 06:05:09 UTC
Created attachment 442894 [details]
emerge --info second machine

One of the computers doesn't have -fPIC in CLFAGS
Comment 8 SpanKY gentoo-dev 2016-08-10 08:10:02 UTC
when the make fails, it should show a line like "Output of: x86_64-pc-linux-gnu-gcc........".  can you try running that line it shows and see if it fails ?

if it does, try deleting the -Wl,-Map,busybox_unstripped.map -Wl,--verbose flags and see if it still crashes.
Comment 9 blackd 2016-08-10 11:34:33 UTC
Created attachment 442902 [details]
successful run output

Successful run output:

env -i PATH="$PATH" x86_64-pc-linux-gnu-gcc  ... (full command in the attachment)
Comment 10 blackd 2016-08-10 11:35:28 UTC
Created attachment 442904 [details]
Failed run output


env -i PATH="$PATH" LANG="$LANG"  x86_64-pc-linux-gnu-gcc ...
Comment 11 blackd 2016-08-10 11:38:42 UTC
Created attachment 442910 [details]
backtrace
Comment 12 blackd 2016-08-10 11:45:50 UTC
(In reply to SpanKY from comment #8)
> when the make fails, it should show a line like "Output of:
> x86_64-pc-linux-gnu-gcc........".  can you try running that line it shows
> and see if it fails ?
> 
> if it does, try deleting the -Wl,-Map,busybox_unstripped.map -Wl,--verbose
> flags and see if it still crashes.

Doesn't crash when I remove -Wl,-Map,busybox_unstripped.map
Removing -Wl,--verbose doesn't make any difference.
Comment 13 SpanKY gentoo-dev 2016-11-15 14:50:39 UTC
2.26.1 & 2.27 are in the tree now.  can you give them a try ?