Re: Segfault in rtld - dlopen RTLD_LAZY (was: Re: CFT: vlc 2.0.3 - want to know where it works and where only partly)

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Sun, 5 Aug 2012 19:13:53 +0300
On Sun, Aug 05, 2012 at 05:31:19PM +0200, Juergen Lock wrote:
> Hi kib, -current, seems we have a segfault in rtld when updating
> the multimedia/vlc port from the version currently in ports to the
> 2.0.3 CFT version from here:
> 
> 	http://people.freebsd.org/~nox/tmp/vlc-2.0.3-006.patch
> 
> (If you test the LIVEMEDIA knob you also need this update:
> 
> 	http://people.freebsd.org/~nox/tmp/livemedia-20120404-001.patch
> 
> )
Please do two things.

1. Provide me the output of readelf -a for the module that was loaded.

2. Recompile rtld with debug symbols and redo the build to get the useful
backtrace from core:
	cd /usr/src/libexec/rtld-elf
	make clean
	make all install DEBUG_FLAGS=-g

> 
> In article <20120804110952.4f3a9cfd_at_ernst.jennejohn.org> you write:
> >On Fri, 3 Aug 2012 18:36:33 +0200
> >Juergen Lock <nox_at_jelal.kn-bremen.de> wrote:
> >
> >> On Fri, Aug 03, 2012 at 05:00:37PM +0200, Rainer Hurling wrote:
> >> > On 03.08.2012 14:27 (UTC+2), Gary Jennejohn wrote:
> >> > > On Thu, 2 Aug 2012 22:56:26 +0200
> >> > > Juergen Lock <nox_at_jelal.kn-bremen.de> wrote:
> >> > >
> >> > > [trimmed irrelevant content]
> >> > >> Ok I added that check:
> >> > >>
> >> > >> 	http://people.freebsd.org/~nox/tmp/vlc-2.0.3-005.patch
> >> > >>
> >> > >>   Enjoy, :)
> >> > >>
> >> > >
> >> > > AMD64 on HEAD.
> >> > >
> >> > > I always get this error, no matter which patch I use:
> >> > >
> >> > >    GEN    ../modules/plugins.dat
> >> > > gmake[2]: *** [../modules/plugins.dat] Segmentation fault: 11 (core dumped)
> >> > > gmake[2]: Leaving directory `/usr/ports/multimedia/vlc/work/vlc-2.0.3/bin'
> >> > > gmake[1]: *** [all-recursive] Error 1
> >> > > gmake[1]: Leaving directory `/usr/ports/multimedia/vlc/work/vlc-2.0.3'
> >> > > gmake: *** [all] Error 2
> >> > > *** [do-build] Error code 1
> >> > 
> >> > I get exactly the same error with CURRENT amd64.
> >> > 
> >> Hm how old are both your installed src and ports?  You two are the
> >> first to report this and I just tried to reproduce it on a head
> >> checkout from May 13 and ports from June 18, and couldn't.
> >> 
> >
> >I update the ports and source trees almost every day.  I do not install
> >new ports binaries unless absolutely necessary, so the ports binaries
> >are pretty much rather old.
> >
> >Just installed a new world/kernel today (updated yesterdya), r239006.
> >
> >> > BTW, mplayer from ports does not build with liveMedia-20120404 ...
> >> > 
> >> > > Stop in /usr/ports/multimedia/vlc.
> >> > > *** [build] Error code 1
> >> > >
> >> > > and there's a work/vlc-2.0.3/bin/vlc-cache-gen.core generated.
> >> > >
> >> > > May be because I have a mix of old and new dependencies, although the vlc
> >> > > port never tries to update any of them.
> >> > >
> >>  Well ports never update dependencies themselves, you need to use
> >> tools like portmaster for that.
> >> 
> >
> >I avoid using tools whenever possible.  Maybe I will have to try
> >portmaster, but I dread seeing 50 ports updated just because I
> >want to update one port.
> >
> >I turned on -g in make.conf and ran vlc-cache-gen in gdb.  Here's the
> >result.
> >
> >gdb /usr/ports/multimedia/vlc/work/vlc-2.0.3/bin/.libs/vlc-cache-gen
> >GNU gdb 6.1.1 [FreeBSD]
> >Copyright 2004 Free Software Foundation, Inc.
> >GDB is free software, covered by the GNU General Public License, and you are
> >welcome to change it and/or distribute copies of it under certain conditions.
> >Type "show copying" to see the conditions.
> >There is absolutely no warranty for GDB.  Type "show warranty" for details.
> >This GDB was configured as "amd64-marcel-freebsd"...
> >(gdb) r ../modules/
> >Starting program: /usr/ports/multimedia/vlc/work/vlc-2.0.3/bin/.libs/vlc-cache-gen ../modules/
> >[New LWP 100125]
> >[New Thread 802406400 (LWP 100125/vlc-cache-gen)]
> >
> >Program received signal SIGSEGV, Segmentation fault.
> >[Switching to Thread 802406400 (LWP 100125/vlc-cache-gen)]
> >0x0000000800606588 in matched_symbol () from /libexec/ld-elf.so.1
> >(gdb) bt
> >#0  0x0000000800606588 in matched_symbol () from /libexec/ld-elf.so.1
> >#1  0x00000008006087e4 in symlook_obj () from /libexec/ld-elf.so.1
> >#2  0x0000000800608ae7 in symlook_list () from /libexec/ld-elf.so.1
> >#3  0x000000080060911b in symlook_default () from /libexec/ld-elf.so.1
> >#4  0x000000080060939d in find_symdef () from /libexec/ld-elf.so.1
> >#5  0x000000080060375b in reloc_non_plt () from /libexec/ld-elf.so.1
> >#6  0x0000000800606ae8 in relocate_object () from /libexec/ld-elf.so.1
> >#7  0x00000008006084a8 in dlopen_object () from /libexec/ld-elf.so.1
> >#8  0x0000000800608f67 in rtld_dlopen () from /libexec/ld-elf.so.1
> >#9  0x0000000800affe95 in module_Load (p_this=0x80244c198,
> >    psz_file=0x802472c00 "../modules//codec/.libs/libfluidsynth_plugin.so",
> >    p_handle=0x7fffffffd180, lazy=true) at posix/plugin.c:62
> >#10 0x0000000800adef4b in module_InitDynamic (obj=0x80244c198,
> >    path=0x802472c00 "../modules//codec/.libs/libfluidsynth_plugin.so",
> >    fast=true) at modules/bank.c:536
> >#11 0x0000000800adede2 in AllocatePluginFile (bank=0x7fffffffd490,
> >    abspath=0x802472c00 "../modules//codec/.libs/libfluidsynth_plugin.so",
> >    relpath=0x802472b80 "codec/.libs/libfluidsynth_plugin.so",
> >    st=0x7fffffffd210) at modules/bank.c:479
> >#12 0x0000000800adeca3 in AllocatePluginDir (bank=0x7fffffffd490, maxdepth=2,
> >    absdir=0x802472b00 "../modules//codec/.libs",
> >    reldir=0x802472a80 "codec/.libs") at modules/bank.c:440
> >#13 0x0000000800adecd7 in AllocatePluginDir (bank=0x7fffffffd490, maxdepth=3,
> >    absdir=0x802472a00 "../modules//codec", reldir=0x8024704f0 "codec")
> >    at modules/bank.c:444
> >#14 0x0000000800adecd7 in AllocatePluginDir (bank=0x7fffffffd490, maxdepth=4,
> >    absdir=0x802452c20 "../modules/", reldir=0x0) at modules/bank.c:444
> >#15 0x0000000800ade9b8 in AllocatePluginPath (p_this=0x80244c198,
> >    path=0x802452c20 "../modules/", mode=CACHE_USE) at modules/bank.c:353
> >#16 0x0000000800ade823 in AllocateAllPlugins (p_this=0x80244c198)
> >    at modules/bank.c:298
> >#17 0x0000000800ade55d in module_LoadPlugins (obj=0x80244c198)
> >    at modules/bank.c:189
> >#18 0x0000000800a53e63 in libvlc_InternalInit (p_libvlc=0x80244c198, i_argc=3,
> >    ppsz_argv=0x7fffffffd6f0) at libvlc.c:247
> >#19 0x000000080082234d in libvlc_new (argc=2, argv=0x7fffffffd7a0) at core.c:59
> >#20 0x0000000000400d1c in main (argc=2, argv=0x7fffffffd858) at cachegen.c:107
> >(gdb)
> >
> >If I remove enough plugins then I can build and install vlc, but the
> >result isn't very useful.
> >
> >The old port builds, installs and works just fine with all the plugins I
> >want to use so I'll stick to it.
> 
>  I Cc'd -current and kib (who did the majority of the recent rtld commits),
> maybe he has an idea.  Seems dlopen() was called from here,
> /usr/ports/multimedia/vlc/work/vlc-2.0.3/src/posix/plugin.c , line 62:
> 
> /**
>  * Load a dynamically linked library using a system dependent method.
>  *
>  * \param p_this vlc object
>  * \param psz_file library file
>  * \param p_handle the module handle returned
>  * \return 0 on success as well as the module handle.
>  */
> int module_Load( vlc_object_t *p_this, const char *psz_file,
>                  module_handle_t *p_handle, bool lazy )
> {
> #if defined (RTLD_NOW)
>     const int flags = lazy ? RTLD_LAZY : RTLD_NOW;
> #elif defined (DL_LAZY)
>     const int flags = DL_LAZY;
> #else
>     const int flags = 0;
> #endif
>     char *path = ToLocale( psz_file );
> 
>     module_handle_t handle = dlopen( path, flags );
>     if( handle == NULL )
>     {
>         msg_Warn( p_this, "cannot load module `%s' (%s)", path, dlerror() );
>         LocaleFree( path );
>         return -1;
>     }
>     LocaleFree( path );
>     *p_handle = handle;
>     return 0;
> }
> 
>  Thanx, :)
> 	Juergen

Received on Sun Aug 05 2012 - 14:13:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC