NetBSD Problem Report #53414

From www@NetBSD.org  Fri Jun 29 23:38:19 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B079A7A157
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 29 Jun 2018 23:38:19 +0000 (UTC)
Message-Id: <20180629233818.553877A218@mollari.NetBSD.org>
Date: Fri, 29 Jun 2018 23:38:18 +0000 (UTC)
From: jdbaker@mylinuxisp.com
Reply-To: jdbaker@mylinuxisp.com
To: gnats-bugs@NetBSD.org
Subject: mplayer tries to write-enable text segment on NetBSD/i386-8.0_RC2, fails.
X-Send-Pr-Version: www-1.0

>Number:         53414
>Category:       pkg
>Synopsis:       mplayer tries to write-enable text segment on NetBSD/i386-8.0_RC2, fails.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 29 23:40:00 +0000 2018
>Originator:     John D. Baker
>Release:        NetBSD/i386-8.0_RC2, pkgsrc-HEAD (pre-pkgsrc-2018Q2)
>Organization:
>Environment:
NetBSD verthandi 8.0_RC2 NetBSD 8.0_RC2 (VERTHANDI) #30: Sun Jun 24 11:32:15 CDT 2018  sysop@plex760.technoskunk.fur:/r0/build/netbsd-8/obj/i386/sys/arch/i386/compile/VERTHANDI i386

>Description:
Previous appended to pkg/53319, requested to file new PR.

On my i386-8.0_RC2 system, mplayer built from recent pkgsrc-HEAD (in
the freeze before pkgsrc-2018Q2) fails to run as follows:

  $ mplayer
  mplayer: text relocations
  mplayer: Cannot write-enable text segment: Permission denied

Running mplayer through 'ktruss' ends with:

[...]
  1541      1 mplayer  open("/usr/local/lib/libcrypt.so.1", 0, 0xbfb613cc) Err#2 ENOENT
  1541      1 mplayer  open("/lib/libcrypt.so.1", 0, 0xbfb613cc) = 3
  1541      1 mplayer  __fstat50(0x3, 0xbfb613cc)  = 0
  1541      1 mplayer  mmap(0, 0x1000, 0x1, 0x1, 0x3, 0, 0, 0) = 0xaade5000
  1541      1 mplayer  munmap(0xaade5000, 0x1000)  = 0
  1541      1 mplayer  mmap(0, 0xb000, 0x5, 0x2, 0x3, 0, 0, 0) = 0xaaddb000
  1541      1 mplayer  mmap(0xaade1000, 0x2000, 0x3, 0x12, 0x3, 0, 0x5000, 0) = 0xaade1000
  1541      1 mplayer  mmap(0xaade3000, 0x3000, 0x3, 0x1012, 0xffffffff, 0, 0, 0) = 0xaade3000
  1541      1 mplayer  close(0x3)                  = 0
  1541      1 mplayer  write(0x2, 0xbfb619ec, 0x19) = 25
        "mplayer: text relocations"
  1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
        "\n"
  1541      1 mplayer  mprotect(0x26000, 0x2c9000, 0x3) Err#13 EACCES
  1541      1 mplayer  write(0x2, 0xbfb61a00, 0x3c) = 60
        "mplayer: Cannot write-enable text segment: Permission denied"
  1541      1 mplayer  write(0x2, 0xbac88872, 0x1) = 1
        "\n"
  1541      1 mplayer  exit(0x1)

So, mprotect() is being called with prot=3 (-wx) for a region of memory
at 0x26000.

Looking earlier in the 'ktruss' output shows several instances of
"26000".  Two are the requsted length for mmap()ing
"/usr/lib/libexpat.so.2" and "/usr/X11R7/lib/libxcb.so.2", respectively.
Another is a byte offset into "/usr/lib/liblzma.so.2" to be mmap()ed.
The rest are tails of longer addresses either requested of or returned
by mmap().

Not sure what it's doing, then.

Even built with the "debug" option, running mplayer under 'gdb' is
not particularly informative:

[...]
Reading symbols from mplayer...done.
(gdb) run
Starting program: /usr/pkg/bin/mplayer 
/usr/pkg/bin/mplayer: text relocations

Program received signal SIGSEGV, Segmentation fault.
_rtld_relocate_plt_lazy (obj=obj@entry=0xb48d7000)
    at /x/netbsd-8/src/libexec/ld.elf_so/arch/i386/mdreloc.c:210
210			*where += (Elf_Addr)obj->relocbase;
(gdb) bt
#0  _rtld_relocate_plt_lazy (obj=obj@entry=0xb48d7000)
    at /x/netbsd-8/src/libexec/ld.elf_so/arch/i386/mdreloc.c:210
#1  0xbb24c515 in _rtld_relocate_objects (first=0xb48d7000, 
    bind_now=bind_now@entry=false)
    at /x/netbsd-8/src/libexec/ld.elf_so/reloc.c:213
#2  0xbb24ae89 in _rtld (sp=<optimized out>, relocbase=3139731456)
    at /x/netbsd-8/src/libexec/ld.elf_so/rtld.c:694
#3  0xbb2484aa in .rtld_start () from /usr/libexec/ld.elf_so
(gdb) list
205			Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
206	
207			assert(ELF_R_TYPE(rel->r_info) == R_TYPE(JMP_SLOT));
208	
209			/* Just relocate the GOT slots pointing into the PLT */
210			*where += (Elf_Addr)obj->relocbase;
211			rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where));
212		}
213	
214		return 0;
(gdb) continue
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) quit


As some have noted, other ffmpeg3 users work OK on i386 (notably
firefox).

Any clues?  'mplayer' is the last show-stopper keeping me from using
netbsd-8 on my i386 systems.


For the record, my "mplayer" is built with the following options:

PKG_DEFAULT_OPTIONS+=pam ssl oss -cups -pulseaudio -alsa -dbus -gvfs
PKG_DEFAULT_OPTIONS+=-jack -arts
PKG_OPTIONS.mplayer+=aalib caca dts ggi mplayer-ssse3 mplayer-win32 debug

>How-To-Repeat:
See above.  Also affects i386-current.
>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.