Skip to content

Commit 2befd17

Browse files
[3.15] gh-156703: Set LD_LIBRARY_PATH in SystemTap trace commands (GH-156424) (GH-156755)
Prefix commands passed to stap -c with LD_LIBRARY_PATH via env, when probes reside in libpython. This allows the interpreter to find libpython when staprun does not preserve the loader path. (cherry picked from commit faf4e52) Co-authored-by: stratakis <cstratak@redhat.com>
1 parent 37232aa commit 2befd17

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Lib/test/test_dtrace.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ def render_script(self, filename):
243243

244244
return script.replace(self.PROBE_PLACEHOLDER, self.python_probe())
245245

246+
def generate_trace_command(self, script_file, subcommand=None):
247+
probe_binary = get_probe_binary()
248+
if subcommand and probe_binary != sys.executable:
249+
library_path = os.path.dirname(probe_binary)
250+
if existing_path := os.environ.get("LD_LIBRARY_PATH"):
251+
library_path = os.pathsep.join((library_path, existing_path))
252+
env = shlex.join(["env", f"LD_LIBRARY_PATH={library_path}"])
253+
subcommand = f"{env} {subcommand}"
254+
255+
return super().generate_trace_command(script_file, subcommand)
256+
246257
def trace(self, script_file, subcommand=None, *, timeout=None,
247258
check_returncode=False):
248259
with tempfile.NamedTemporaryFile(

0 commit comments

Comments
 (0)