Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 708758 - sys-libs/glibc - MIPS/Linux inline syscall template is miscompiled
Summary: sys-libs/glibc - MIPS/Linux inline syscall template is miscompiled
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: MIPS Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords: UPSTREAM
: 711646 (view as bug list)
Depends on:
Blocks: make-4.3
  Show dependency tree
 
Reported: 2020-02-08 22:41 UTC by Joshua Kinard
Modified: 2020-03-06 10:52 UTC (History)
5 users (show)

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


Attachments
emerge --info (emerge_info-ip30-20200208.txt,5.26 KB, text/plain)
2020-02-08 22:43 UTC, Joshua Kinard
Details
Add local USE to control posix_spawn() functionality in make-4.3 (make-4.3_add-use-for-posix_spawn.patch,1.20 KB, patch)
2020-02-09 20:26 UTC, Joshua Kinard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Kinard gentoo-dev 2020-02-08 22:41:02 UTC
On a mips64 system, sys-devel/crossdev-20200125 can't be merged using sys-devel/make-4.3:

>>> Emerging (1 of 1) sys-devel/crossdev-20200125::gentoo
 * crossdev-20200125.tar.xz BLAKE2B SHA512 size ;-) ...                                                                                                                      [ ok ]
>>> Unpacking source...
>>> Unpacking crossdev-20200125.tar.xz to /usr/obj/portage/sys-devel/crossdev-20200125/work
>>> Source unpacked in /usr/obj/portage/sys-devel/crossdev-20200125/work
>>> Preparing source in /usr/obj/portage/sys-devel/crossdev-20200125/work/crossdev-20200125 ...
>>> Source prepared.
>>> Configuring source in /usr/obj/portage/sys-devel/crossdev-20200125/work/crossdev-20200125 ...
>>> Source configured.
>>> Compiling source in /usr/obj/portage/sys-devel/crossdev-20200125/work/crossdev-20200125 ...
make -j4
make: Nothing to be done for 'all'.
>>> Source compiled.
>>> Test phase [not enabled]: sys-devel/crossdev-20200125

>>> Install sys-devel/crossdev-20200125 into /usr/obj/portage/sys-devel/crossdev-20200125/image
make -j4 DESTDIR=/usr/obj/portage/sys-devel/crossdev-20200125/image install
install -m 755 -d /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/
install -m 755 crossdev /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/
sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
sed: couldn't open temporary file /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/sed5gJc2R: Permission denied
make: *** [Makefile:11: install] Error 4
 * ERROR: sys-devel/crossdev-20200125::gentoo failed (install phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=sys-devel/crossdev-20200125::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-devel/crossdev-20200125::gentoo'`.
 * The complete build log is located at '/usr/obj/portage/sys-devel/crossdev-20200125/temp/build.log'.
 * The ebuild environment file is located at '/usr/obj/portage/sys-devel/crossdev-20200125/temp/environment'.
 * Working directory: '/usr/obj/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'
 * S: '/usr/obj/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'

Downgrading back to sys-devel/make-4.2.1-r4 allows crossdev to merge.  Unable to reproduce on my x86_64 platform, so this might be MIPS-specific somehow.  Not terribly sure how.  Nothing appears in dmesg indicating a failure, and perms on my PORTAGE_TMPDIR are all correct.  Having similar issues with other packages, such as nano and shadow.  Either getting a "permission denied" error or "operation not permitted".
Comment 1 Joshua Kinard gentoo-dev 2020-02-08 22:43:35 UTC
Created attachment 612884 [details]
emerge --info
Comment 2 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-08 23:16:34 UTC
> sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
> sed: couldn't open temporary file /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/sed5gJc2R: Permission denied

If sed is called with precisely these arguments then make version should not affect it's execution. You can try to run in manually in a loop to see if it's reproducible.

If it does reproduce 'strace' might provide a clue.
Comment 3 Joshua Kinard gentoo-dev 2020-02-09 04:17:21 UTC
(In reply to Sergei Trofimovich from comment #2)
> > sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
> > sed: couldn't open temporary file /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/sed5gJc2R: Permission denied
> 
> If sed is called with precisely these arguments then make version should not
> affect it's execution. You can try to run in manually in a loop to see if
> it's reproducible.
> 
> If it does reproduce 'strace' might provide a clue.

It's definitely tied to make-4.3 somehow.  Running the sed command by itself returns no errors.  IT might be related to ABI.  I have an O32
Comment 4 Joshua Kinard gentoo-dev 2020-02-09 04:18:31 UTC
(In reply to Joshua Kinard from comment #3)
> (In reply to Sergei Trofimovich from comment #2)
> > > sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
> > > sed: couldn't open temporary file /usr/obj/portage/sys-devel/crossdev-20200125/image/usr/bin/sed5gJc2R: Permission denied
> > 
> > If sed is called with precisely these arguments then make version should not
> > affect it's execution. You can try to run in manually in a loop to see if
> > it's reproducible.
> > 
> > If it does reproduce 'strace' might provide a clue.
> 
> It's definitely tied to make-4.3 somehow.  Running the sed command by itself
> returns no errors.  IT might be related to ABI.  I have an O32

** I have an O32 chroot I can test in shortly after I sync my portage tree up.  My main root filesystem runs N32, and sometimes, albeit rarely, weird bugs can crop up on N32 because it's a hybrid 32bit/64bit model.
Comment 5 Joshua Kinard gentoo-dev 2020-02-09 19:58:42 UTC
Okay, I also have the same failure in my O32 chroot when using make-4.3.  However, I had 'sandbox' enabled on the first attempt, and that coughed up a different set of error messages:

>>> Install sys-devel/crossdev-20200125 into /var/tmp/portage/sys-devel/crossdev-20200125/image
make -j3 DESTDIR=/var/tmp/portage/sys-devel/crossdev-20200125/image install
install -m 755 -d /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
install -m 755 crossdev /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
make -C wrappers install
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
make[1]: Entering directory '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125/wrappers'
make[1]: portageq: Operation not permitted
install -m 755 -d /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/ /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/share/crossdev/include/site /var/tmp/portage/sys-devel/crossdev-20200125/image/etc/crossdev/include/site
make[1]: install: Operation not permitted
make[1]: *** [Makefile:14: install] Error 127
make[1]: Leaving directory '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125/wrappers'
make: *** [Makefile:12: install] Error 2
 * ERROR: sys-devel/crossdev-20200125::gentoo failed (install phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=sys-devel/crossdev-20200125::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-devel/crossdev-20200125::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-devel/crossdev-20200125/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-devel/crossdev-20200125/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'
 * S: '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'


After adding "-sandbox -usersandbox" to FEATURES, I get the same error as my N32 chroot:
>>> Install sys-devel/crossdev-20200125 into /var/tmp/portage/sys-devel/crossdev-20200125/image
make -j3 DESTDIR=/var/tmp/portage/sys-devel/crossdev-20200125/image install
install -m 755 -d /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/
install -m 755 crossdev /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/
sed -i -e "s:@GENTOO_PORTAGE_EPREFIX@::g" /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/crossdev
make -C wrappers install
make[1]: Entering directory '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125/wrappers'
make[1]: portageq: Operation not permitted
install -m 755 -d /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/bin/ /var/tmp/portage/sys-devel/crossdev-20200125/image/usr/share/crossdev/include/site /var/tmp/portage/sys-devel/crossdev-20200125/image/etc/crossdev/include/site
make[1]: install: Operation not permitted
make[1]: *** [Makefile:14: install] Error 127
make[1]: Leaving directory '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125/wrappers'
make: *** [Makefile:12: install] Error 2
 * ERROR: sys-devel/crossdev-20200125::gentoo failed (install phase):
 *   emake failed
 *
 * If you need support, post the output of `emerge --info '=sys-devel/crossdev-20200125::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sys-devel/crossdev-20200125::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sys-devel/crossdev-20200125/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sys-devel/crossdev-20200125/temp/environment'.
 * Working directory: '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'
 * S: '/var/tmp/portage/sys-devel/crossdev-20200125/work/crossdev-20200125'


So this is probably a MIPS-specific problem with make-4.3 at the moment.  Is there anything major that changed in make between 4.2.1 and 4.3 that might have anything to do with file system access?  It seems the issue is there somehow.
Comment 6 Joshua Kinard gentoo-dev 2020-02-09 20:19:08 UTC
Okay, I found the problem:

* GNU make will now use posix_spawn() on systems where it is available.
  If you prefer to use fork/exec even on systems where posix_spawn() is
  present, you can use the --disable-posix-spawn option to configure.
  Implementation contributed by Aron Barath <baratharon@caesar.elte.hu>

There's some kind of issue with the use of posix_spawn() on MIPS I guess.  Recompiling make-4.3 without support for this (using the older fork/exec), it works fine now in installing crossdev.

I'll attach a patch shortly that adds a local USE flag to allow the enabling/disabling of posix_spawn, with it defaulting to enabled for all ARCHs, then if that is accepted, the MIPS profiles can mask that USE until something is fixed either in upstream GNU make, or possibly even in Glibc.
Comment 7 Joshua Kinard gentoo-dev 2020-02-09 20:26:13 UTC
Created attachment 613128 [details, diff]
Add local USE to control posix_spawn() functionality in make-4.3

Patch adds a new local USE flag, posix-spawn, to enable or disable the use of the posix_spawn() function call that make-4.3 can use over the older fork()/exec() calls.  Enabled by default, this local USE will be disabled on MIPS until upstream can look into why posix_spawn does not work on MIPS correctly.
Comment 8 Mike Gilbert gentoo-dev 2020-02-09 22:08:59 UTC
Will you will handle reporting this upstream? I doubt anyone on base-system will be able to reproduce it.
Comment 9 Joshua Kinard gentoo-dev 2020-02-09 23:39:52 UTC
(In reply to Mike Gilbert from comment #8)
> Will you will handle reporting this upstream? I doubt anyone on base-system
> will be able to reproduce it.

Yup, just waiting for the machine to finish some updates.
Comment 10 Mike Gilbert gentoo-dev 2020-02-10 00:07:24 UTC
Great. Please feel free to push your workaround.
Comment 11 Joshua Kinard gentoo-dev 2020-02-10 08:15:08 UTC
Upstream bug created.  I'll add the ebuild changes tomorrow.
Comment 12 Joshua Kinard gentoo-dev 2020-02-10 17:11:49 UTC
From upstream, this looks more like a glibc bug.  See the new bug reference for details.
Comment 13 Joshua Kinard gentoo-dev 2020-02-10 17:44:01 UTC
Looking at the related glibc bug, I am wondering if this issue explains why I very very randomly get odd errors in my chroots.  I recently updated an O32/MIPS2 chroot with little problem, other than with make-4.3.  But an N32/MIPS3 chroot  kept having weird errors, like illegal instructions, which might be explained by screwed up arg passing in glibc's syscall templates.  I'll have to run some local tests to see.  The proposed fix might need to be backported to glibc-2.30 and added to 2.31 in our tree.  I'll update when I know more.
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-11 22:42:43 UTC
Sounds good. Thanks for the detailed follow-up!
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-11 22:43:01 UTC
https://sourceware.org/PR25523
Comment 16 Joshua Kinard gentoo-dev 2020-02-15 08:11:25 UTC
(In reply to Sergei Trofimovich from comment #15)
> https://sourceware.org/PR25523

Upstream has this fixed for MIPS, Sparc, Microblaze, and RISC-V.  @toolchain, can the patches at the below URLs be pulled into glibc's patchball for 2.30 as well as 2.31?  At a minimum, MIPS, Sparc, and RISC-V.  I'm not sure if Gentoo supports Microblaze yet.  I've CC'ed the relevant arch teams.  I am guessing that glibc-2.32 will fix this, so they can be dropped from the patchball when that is released.

I've verified in a MIPS3/N32 chroot that make-4.3 works fine using posix_spawn() after glibc is built with the MIPS-specific patch applied.

MIPS:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=aa638b86b222fcc9f9cdf1d2cb49a36ea681b469

Sparc:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=c261718b3fda4b629ee120f48e3ee50db9c793a1

RISC-V:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=be74b42ee2a97009a6cd4fc90126add4a41c583b
Comment 17 Joshua Kinard gentoo-dev 2020-02-15 08:13:54 UTC
Comment on attachment 613128 [details, diff]
Add local USE to control posix_spawn() functionality in make-4.3

Unless anyone objects, I think the real fix is to fix glibc's bug on MIPS, Sparc, and RISC-V.  No need to add a new local USE flag to make as a workaround.
Comment 18 Sergei Trofimovich (RETIRED) gentoo-dev 2020-02-15 19:32:34 UTC
Yeah, totally. We'll pull in all linked here patches into 2.30/2.31.
Comment 19 Larry the Git Cow gentoo-dev 2020-02-16 19:25:37 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9097e0e8399937b751ac38153f44a12f9f1c2b54

commit 9097e0e8399937b751ac38153f44a12f9f1c2b54
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2020-02-16 19:23:13 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-02-16 19:25:25 +0000

    sys-libs/glibc: pull 2.30 and 2.31 upstream patches, bug #708758
    
    Among other things patches to fix posix_spawn syscall on mips
    and other targets..
    
    Reported-by: Joshua Kinard
    Closes: https://bugs.gentoo.org/708758
    Package-Manager: Portage-2.3.89, Repoman-2.3.20
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-libs/glibc/Manifest             |    2 +
 sys-libs/glibc/glibc-2.30-r4.ebuild | 1490 ++++++++++++++++++++++++++++++++++
 sys-libs/glibc/glibc-2.31-r1.ebuild | 1493 +++++++++++++++++++++++++++++++++++
 3 files changed, 2985 insertions(+)
Comment 20 Andrew Aladjev 2020-03-06 10:52:44 UTC
*** Bug 711646 has been marked as a duplicate of this bug. ***