Blame SOURCES/BZ-1458841-preload-shared-libs.patch

d2a170
diff -up yum-3.4.3/cli.py.orig yum-3.4.3/cli.py
d2a170
--- yum-3.4.3/cli.py.orig	2017-06-29 17:44:53.784522557 +0200
d2a170
+++ yum-3.4.3/cli.py	2017-06-29 17:46:16.249149700 +0200
d2a170
@@ -28,6 +28,7 @@ import logging
d2a170
 import math
d2a170
 from optparse import OptionParser,OptionGroup,SUPPRESS_HELP
d2a170
 import rpm
d2a170
+import ctypes
d2a170
 
d2a170
 from weakref import proxy as weakref
d2a170
 
d2a170
@@ -779,6 +780,38 @@ class YumBaseCli(yum.YumBase, output.Yum
d2a170
         if self.conf.debuglevel < 2:
d2a170
             cb.display.output = False
d2a170
 
d2a170
+        # Whenever we upgrade a shared library (and its dependencies) which the
d2a170
+        # yum process itself may dlopen() post-transaction (e.g. in a plugin
d2a170
+        # hook), we may end up in a situation where the upgraded library and
d2a170
+        # the pre-transaction version of a library it depends on which is ABI
d2a170
+        # incompatible are loaded in memory at the same time, leading to
d2a170
+        # unpredictable behavior and possibly a crash.  Let's avoid that by
d2a170
+        # preloading all such dynamically loaded libraries pre-transaction so
d2a170
+        # that dlopen(), if called post-transaction, uses those instead of
d2a170
+        # loading the newly installed versions.
d2a170
+        preload = {
d2a170
+            # Loaded by libcurl, see BZ#1458841
d2a170
+            'nss-sysinit': ['libnsssysinit.so'],
d2a170
+        }
d2a170
+        for pkg in preload:
d2a170
+            # Only preload the libs if the package is actually installed and we
d2a170
+            # are changing it with the transaction
d2a170
+            if not self.tsInfo.matchNaevr(name=pkg) or \
d2a170
+                    not self.rpmdb.searchNevra(name=pkg):
d2a170
+                continue
d2a170
+            for lib in preload[pkg]:
d2a170
+                try:
d2a170
+                    ctypes.cdll.LoadLibrary(lib)
d2a170
+                    self.verbose_logger.log(
d2a170
+                        yum.logginglevels.DEBUG_4,
d2a170
+                        _('Preloaded shared library %s') % lib
d2a170
+                    )
d2a170
+                except Exception as e:
d2a170
+                    self.verbose_logger.log(
d2a170
+                        yum.logginglevels.DEBUG_4,
d2a170
+                        _('Could not preload shared library %s: %s') % (lib, e)
d2a170
+                    )
d2a170
+
d2a170
         self.verbose_logger.log(yum.logginglevels.INFO_2, _('Running transaction'))
d2a170
         resultobject = self.runTransaction(cb=cb)
d2a170