EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: OS X edm/medm openmotif woes
From: "J. Lewis Muir" <[email protected]>
To: Jiro Fujita <[email protected]>
Cc: Eric Norum <[email protected]>, tech-talk <[email protected]>
Date: Tue, 15 Nov 2016 18:01:32 -0600
On 11/14, Jiro Fujita wrote:
> Hi Lewis, 
> 
> Actually, Eric and I got this sorted out a while ago, but I guess
> never posted the solutions on the Tech-Talk.
>
> The trick was to install the new version of
> XQuartz (2.7.10_rc5 or newer should do), then, set
> DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace.  That solved the
> problem for Eric and me.

Thanks!

For anyone else following this, the problem appears to be that the
libXt dynamic library as provided by XQuartz 2.7.10 and newer is now a
two-level-namespace dynamic library.  Motif 2.3.4 will only work with
a flat-namespace libXt dynamic library, so things are broken.

XQuartz 2.7.9 also introduced a related change to libXt, but I don't
know if it breaks things.  The XQuartz 2.7.9 release notes are at:

  https://www.xquartz.org/releases/XQuartz-2.7.9.html

They include this note:

  libXt
    * No longer linked with -flat_namespace
    * Binary compatibility maintained for existing clients of libXt.6.dylib

Anyway, I upgraded to XQuartz 2.7.11 and, as expected, still had the
problem with medm crashing immediately.

The XQuartz project says Motif is broken and encourages users to file
a bug report against the Motif project.  Info about this and the
DYLD_LIBRARY_PATH workaround can be found in the XQuartz 2.7.10 release
notes:

  https://www.xquartz.org/releases/XQuartz-2.7.10.html

What the release notes do not warn about, though, is that the
DYLD_LIBRARY_PATH environment variable (and others) receives special
treatment on macOS due to System Integrity Protection (SIP) which was
added in OS X El Capitan (10.11).  I was exec'ing medm from a shell
script and couldn't get the DYLD_LIBRARY_PATH workaround to work because
I did:

$ export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace
$ ./medm-control.sh

In the above case, the DYLD_LIBRARY_PATH environment variable is *not*
passed into the environment of the medm-control.sh shell script because
the shebang is /bin/sh, and /bin/sh is a protected process in SIP!
DYLD_LIBRARY_PATH is set in the shell, but it doesn't get passed into
the environment of protected child processes.  /bin/sh is considered
protected:

$ export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace
$ [ $DYLD_LIBRARY_PATH ] || echo nope
$ /bin/sh -c '[ $DYLD_LIBRARY_PATH ] || echo nope'
nope

This drove me crazy trying to figure out what was going on!  Once I set
and exported DYLD_LIBRARY_PATH *in* the shell script before exec'ing
medm, then it worked!

This behavior is explained in the Runtime Protections section ([1]) of
the System Integrity Protection Guide:

  Spawning children processes of processes restricted by System
  Integrity Protection, such as by launching a helper process in a
  bundle with NSTask or calling the exec(2) command, resets the Mach
  special ports of that child process. Any dynamic linker (dyld)
  environment variables, such as DYLD_LIBRARY_PATH, are purged when
  launching protected processes.

Long term, Motif needs to be fixed to work with a two-level-namespace
libXt.  In the short term, though, the above workaround worked for me.

Another workaround I tried that worked and did not require setting
the DYLD_LIBRARY_PATH environment variable was to move the
two-level-namespace libXt dynamic library from XQuartz out of the way
and replace it with the flat-namespace version XQuartz provides:

$ cd /opt/X11/lib
$ sudo mv libXt.6.dylib libXt.6.dylib.orig
$ sudo ln -s flat_namespace/libXt.6.dylib

I don't know if that's a reasonable hack if setting the
DYLD_LIBRARY_PATH environment variable is not an option, but it worked
for me for medm.

Another option, that I did not try but that I think would work, is to
downgrade XQuartz to 2.7.8.

Lewis

[1] https://developer.apple.com/library/content/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html

Replies:
Re: OS X edm/medm openmotif woes Pete Jemian
Re: OS X edm/medm openmotif woes Matt Newville
References:
OS X edm/medm openmotif woes Eric Norum
Re: OS X edm/medm openmotif woes Jiro Fujita
Re: OS X edm/medm openmotif woes Eric Norum
Re: OS X edm/medm openmotif woes Jiro Fujita
Re: OS X edm/medm openmotif woes Eric Norum
Re: OS X edm/medm openmotif woes Jiro Fujita
Re: OS X edm/medm openmotif woes J. Lewis Muir
Re: OS X edm/medm openmotif woes Jiro Fujita

Navigate by Date:
Prev: Re: module for Keithley 6485 PA-meter Márcio Paduan Donadio
Next: RE: module for Keithley 6485 PA-meter Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: OS X edm/medm openmotif woes Jiro Fujita
Next: Re: OS X edm/medm openmotif woes Pete Jemian
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Nov 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·