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

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