Bug 204034

Summary: multimedia/plexmediaserver: Startup script should include /usr/local/lib/compat/ in LD_LIBRARY_PATH
Product: Ports & Packages Reporter: Reynold Chery <jfltech>
Component: Individual Port(s)Assignee: Mark Felder <feld>
Status: Closed FIXED    
Severity: Affects Some People CC: feld, miguelmclara
Priority: --- Keywords: needs-patch, needs-qa
Version: LatestFlags: koobs: maintainer-feedback? (feld)
koobs: merge-quarterly?
Hardware: amd64   
OS: Any   
URL: https://forums.plex.tv/discussion/comment/1041033/#Comment_1041033

Description Reynold Chery 2015-10-26 14:25:50 UTC
When the gcc and plexmediaserver is installed on FreeBSD 10.x the linker resolves to the "libstdc++.so.6" library in

/usr/local/lib/gcc48/libstdc++.so.6 
vs 
/usr/local/lib/compat/libstdc++.so.6

Which causes "Plex Media Server" to fail immediately upon startup via an exception in thr_kill () from /lib/libc.so.7 

Testing that the the correct lib path exists and added to LD_LIBRARY_PATH via the start script would help prevent this issue from re-occurring with new installs.
Comment 1 Mark Felder freebsd_committer freebsd_triage 2015-10-26 17:03:04 UTC
I can't reproduce this. I have plex installed in a 10.1-RELEASE jail and I just installed gcc48. Starting Plex works just fine with "service" command and running the rc script directly.

Can you show me "ldd" on your Plex Media Server binary?
Comment 2 Reynold Chery 2015-10-26 20:15:31 UTC
With a default install 
[pvr@plexter ~]$ sudo pkg install plexmediaserver

[pvr@plexter ~]$ uname -rp
10.2-RELEASE amd64

Starts and fails within a second (I had to use pgrep to catch PID with lsof)
[pvr@plexter ~]$ sudo service plexmediaserver onestart ; sudo lsof -p `pgrep -f Plex_Media_Server`


Plex\x20M 18888 plex  txt   VREG   0,84  423466595516416 564252 /usr/local/share/plexmediaserver/libiconv.so.7
Plex\x20M 18888 plex  txt   VREG   0,84  423466595516416 564253 /usr/local/share/plexmediaserver/libidn.so.17
Plex\x20M 18888 plex  txt   VREG   0,84  424329883942912 494727 /usr/local/lib/gcc48/libstdc++.so.6.0.19
Plex\x20M 18888 plex  txt   VREG   0,83  423466595516416  98796 /lib/libm.so.5
Plex\x20M 18888 plex  txt   VREG   0,83  423466595516416  98789 /lib/libgcc_s.so.1
Plex\x20M 18888 plex  txt   VREG   0,83  423466595516416  98780 /lib/libc.so.7
Plex\x20M 18888 plex  txt   VREG   0,83  423466595516416  98810 /lib/libutil.so.9

[pvr@plexter ~]$ ldd /usr/local/share/plexmediaserver/Plex\ Media\ Server  | grep libstdc
        libstdc++.so.6 => /usr/local/lib/gcc48/libstdc++.so.6 (0x801e49000)


My default linker search PATH has /usr/local/lib/gcc48 first hence why it is chosen, I assume this is because I installed compat after gcc.
root@plexter:/usr/local/libdata/ldconfig # ldconfig -r | head -n 2
/var/run/ld-elf.so.hints:
        search directories: /lib:/usr/lib:/usr/lib/compat:/usr/local/lib:/usr/local/lib/gcc48:/usr/local/lib/compat
Comment 3 Mark Felder freebsd_committer freebsd_triage 2015-10-27 15:49:19 UTC
If you do "service ldconfig restart" does it fix it?

There's potentially another issue at hand here, but we can force it to play nice with the LD_LIBRARY_PATH change...
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-10-27 16:06:30 UTC
A commit references this bug:

Author: feld
Date: Tue Oct 27 16:06:27 UTC 2015
New revision: 400328
URL: https://svnweb.freebsd.org/changeset/ports/400328

Log:
  multimedia/plexmediaserver{-plexpass}: Update LD_LIBRARY_PATH in rc script

  Occasionally a user would be unable to run plex due to a crash on startup.
  The problem was identified as the libstdc++.so.6 from GCC being picked
  up first instead of the one from compat9x.

  PR:		204034

Changes:
  head/multimedia/plexmediaserver/Makefile
  head/multimedia/plexmediaserver/files/plexmediaserver.in
  head/multimedia/plexmediaserver-plexpass/Makefile
  head/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in