From eeda0d585ce06b20a26b0ffacdf124c2cb483a4b Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 11 Dec 2017 22:13:21 -0500 Subject: [PATCH] Force LD_BIND_NOW on all runtime invocation. Behavior regarding lazy on immediate binding can vary based on distribution and gcc configuration. We are interested in the immediate binding case (LD_BIN_NOW, ld.so '-z now'). Signed-off-by: Jonathan Rajotte --- README | 10 ++++++++++ .../test_tools_liblttng-ctl_vs_sessiond.py | 10 +++++----- lttng_ivc/utils/runtime.py | 8 ++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README b/README index 9865bbf..1170d37 100644 --- a/README +++ b/README @@ -30,3 +30,13 @@ How to run: With tox: 1: tox -r ./ + +Findings +======== + +The binding type (ld.so) (now or lazy) is dependent on the gcc/ld distribution +configuration. Hence, for this test suite, we force the behavior to "now". This +result in the lookup of all required symbols at launch. This is particularly +important since we want to prevent inconsistent behavior. Immediate might be +forced in the future for lttng project but for now we simply force it at +runtime. diff --git a/lttng_ivc/tests/tools_liblttng-ctl_vs_sessiond/test_tools_liblttng-ctl_vs_sessiond.py b/lttng_ivc/tests/tools_liblttng-ctl_vs_sessiond/test_tools_liblttng-ctl_vs_sessiond.py index 1259ec0..2776ff2 100644 --- a/lttng_ivc/tests/tools_liblttng-ctl_vs_sessiond/test_tools_liblttng-ctl_vs_sessiond.py +++ b/lttng_ivc/tests/tools_liblttng-ctl_vs_sessiond/test_tools_liblttng-ctl_vs_sessiond.py @@ -81,7 +81,7 @@ def test_tools_liblttng_ctl_vs_sessiond_basic_listing(tmpdir, client_label, tool sessiond = utils.sessiond_spawn(runtime_tools) - cp, out, err = runtime_tools.run('{} create trace'.format(lttng_client), check_return=False) + cp, out, err = runtime_tools.run('{} create trace'.format(lttng_client), check_return=False, ld_debug=True) if outcome == "Missing symbol": assert(cp.returncode != 0) assert(utils.file_contains(err, "Missing symbol")) @@ -89,12 +89,12 @@ def test_tools_liblttng_ctl_vs_sessiond_basic_listing(tmpdir, client_label, tool assert(cp.returncode == 0) - runtime_tools.run('lttng enable-event -u tp:tptest') - runtime_tools.run('lttng start') + runtime_tools.run('{} enable-event -u tp:tptest'.format(lttng_client)) + runtime_tools.run('{} start'.format(lttng_client)) # Stop tracing - runtime_tools.run('lttng stop') - runtime_tools.run('lttng destroy -a') + runtime_tools.run('{} stop'.format(lttng_client)) + runtime_tools.run('{} destroy -a'.format(lttng_client)) cp = runtime_tools.subprocess_terminate(sessiond) if cp.returncode != 0: pytest.fail("Sessiond return code") diff --git a/lttng_ivc/utils/runtime.py b/lttng_ivc/utils/runtime.py index 7166176..41194e0 100644 --- a/lttng_ivc/utils/runtime.py +++ b/lttng_ivc/utils/runtime.py @@ -162,7 +162,8 @@ class Runtime(object): _logger.debug("Spawned sub pid: {} args: {} stdout: {} stderr{}".format(p.pid, p.args, out_path, err_path)) return tmp_id - def run(self, command_line, cwd=None, check_return=True, ld_preload="", classpath="", timeout=None): + def run(self, command_line, cwd=None, check_return=True, ld_preload="", + classpath="", timeout=None, ld_debug=False): """ Run the command and return a tuple of a (CompletedProcess, stdout_path, stderr_path). The subprocess is already executed and returned. The @@ -175,7 +176,9 @@ class Runtime(object): env['LD_PRELOAD'] = ld_preload if classpath: env['CLASSPATH'] = classpath - + if ld_debug: + # ld debugging switch + env["LD_DEBUG"] = "all" tmp_id = self._run_command_count self._run_command_count += 1 @@ -245,6 +248,7 @@ class Runtime(object): env = os.environ.copy() env["LTTNG_HOME"] = self.lttng_home + env["LD_BIND_NOW"] = "enabled" env_fetch = {"CPPFLAGS": (self.get_cppflags(), " "), "LDFLAGS": (self.get_ldflags(), " "), -- 2.34.1