]> git.liburcu.org Git - lttng-tools.git/log
lttng-tools.git
36 hours agoMigrate to SPDX-FileCopyrightText notices master
Jérémie Galarneau [Tue, 28 Jan 2025 20:30:10 +0000 (20:30 +0000)] 
Migrate to SPDX-FileCopyrightText notices

Automated using the following snippet:

find . \
  \( -name '*.c' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \
     -o -name '*.py' -o -name '*.sh' \) -print0 |
while IFS= read -r -d '' file; do
  sed -E -i \
    's/Copyright(\s*\(C\))?\s+([0-9]{4})\s+(.*)/SPDX-FileCopyrightText: \2 \3/g' \
    "$file"
done

Change-Id: I9a12cdc7fc8bed0c6436b5be62cc57f56ec4ed89
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
36 hours agoconfig-session-abi: remove erroneously exported domain name symbol
Jérémie Galarneau [Tue, 28 Jan 2025 19:42:03 +0000 (19:42 +0000)] 
config-session-abi: remove erroneously exported domain name symbol

This symbol has not been exported in a released version yet. It can
be safely removed.

Change-Id: I20c98253d6edd403640fd9fc4215baa4362cd9e6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
36 hours agoChange copyright notice to SPDX-FileCopyrightText
Jérémie Galarneau [Tue, 28 Jan 2025 19:41:53 +0000 (19:41 +0000)] 
Change copyright notice to SPDX-FileCopyrightText

Change-Id: Ie68b4ebcd4ab88f716d88c12b62b2482e1268ed6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
37 hours agoliblttng-ctl.sym: Add SPDX header
Jérémie Galarneau [Tue, 28 Jan 2025 19:38:44 +0000 (19:38 +0000)] 
liblttng-ctl.sym: Add SPDX header

Change-Id: I8f6c8bdaca31f11bc7f70f226bdd51a512d289cf
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
37 hours agotests: Test ABI diff of liblttng-ctl
Kienan Stewart [Fri, 17 Jan 2025 21:01:24 +0000 (16:01 -0500)] 
tests: Test ABI diff of liblttng-ctl

Change-Id: Ic401829c4485773215013bd4233f589f39549372
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
37 hours agoMisc: Add pre-commit check for SPDX License-Identifier and FileCopyrightText
Kienan Stewart [Mon, 20 Jan 2025 20:08:59 +0000 (15:08 -0500)] 
Misc: Add pre-commit check for SPDX License-Identifier and FileCopyrightText

Observed issue
==============

There are frequently small typos or slightly deviant SPDX tags set on files.

Cause
=====

Mostly me.

Solution
========

Add a pre-commit check with the following allowed tags:

 * SPDX-License-Identifier
 * SPDX-FileCopyrightText
 * SPDX-URL

Known drawbacks
===============

This is not a full SPDX validation, and does not validate the license
identifier values.

Change-Id: Iabd78ae14ef143ab4a956e0c5c31c1490b43aeda
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
37 hours agotests: Correct SPDX-License-Identifiers in tests/
Kienan Stewart [Fri, 17 Jan 2025 21:07:33 +0000 (16:07 -0500)] 
tests: Correct SPDX-License-Identifiers in tests/

Change-Id: I24fb2d8c18582ce1de87652dcedfbc31289dcaea
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
37 hours agoClean-up: relayd: remove unreachable code
Jérémie Galarneau [Thu, 19 Dec 2024 18:36:02 +0000 (18:36 +0000)] 
Clean-up: relayd: remove unreachable code

Coverity warns:
1568451 Structurally dead code
Actions intended to be performed by the unreachable code will never occur.

In relay_thread_listener(void *): Code block is unreachable because of the syntactic structure of the code (CWE-561)

Use the appropriate error label to handle the file creation error.

Change-Id: Id4f4eeae287a135d87ec21b14d1eade2afbb1f2c
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 days agoClean-up: sessiond: remove unused ust_app_ctx::list
Jérémie Galarneau [Thu, 5 Dec 2024 20:49:20 +0000 (20:49 +0000)] 
Clean-up: sessiond: remove unused ust_app_ctx::list

Change-Id: Ib13497dea90fa1d22bee51b7745a1960e09181f4
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 days agoClean-up: sessiond: ust-app: comment style fixes
Jérémie Galarneau [Thu, 12 Dec 2024 21:27:43 +0000 (21:27 +0000)] 
Clean-up: sessiond: ust-app: comment style fixes

Change-Id: Iaf79efb1c0fa1724e4883fedeca05979953d01a7
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up: lttng-list: use bool for boolean value
Jérémie Galarneau [Fri, 17 Jan 2025 22:09:54 +0000 (22:09 +0000)] 
Clean-up: lttng-list: use bool for boolean value

Change-Id: I9daaf64c6c9b796a124903ec2d707c1fefe41b00
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up typos: encoutered -> encountered
Jérémie Galarneau [Fri, 17 Jan 2025 21:59:36 +0000 (21:59 +0000)] 
Clean-up typos: encoutered -> encountered

For some reason, this typo is present all over the project. I'll practice
writting that word over the week-end.

Change-Id: Ifc6b0d205de8792c1a96cbac009fd5abdfb36199
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up: lttng-list: comment style
Jérémie Galarneau [Fri, 17 Jan 2025 21:59:18 +0000 (21:59 +0000)] 
Clean-up: lttng-list: comment style

Change-Id: Ice93951370516a63b88f2be116e5c6de09c560e2
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up: clang-tidy: unhandled exceptions in noexcept functions
Jérémie Galarneau [Fri, 17 Jan 2025 21:52:28 +0000 (21:52 +0000)] 
Clean-up: clang-tidy: unhandled exceptions in noexcept functions

While unlikely (would require a corrupted hash table), the iteration adapter's
iterator can theoritically throw an exception during the iteration.

clang-tidy warns that this is bug prone (bugprone-exception-escape).

Change-Id: I89cae7ef662ba6b88c2826a5c8636e0a63fe9117
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up: apply suggested clang-tidy auto-fixes
Jérémie Galarneau [Fri, 17 Jan 2025 21:37:32 +0000 (21:37 +0000)] 
Clean-up: apply suggested clang-tidy auto-fixes

Change-Id: Ib5634578258b91c7a640566d4e50e891b11e4d8d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoClean-up: consumer: fix comment style
Jérémie Galarneau [Fri, 17 Jan 2025 21:36:56 +0000 (21:36 +0000)] 
Clean-up: consumer: fix comment style

Change-Id: I4742c496d4f22eecdaa503e603463214c34610bd
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 days agoabi_ref/README: rename liblttng-ctl.xml to abi.xml
Jérémie Galarneau [Fri, 17 Jan 2025 20:05:10 +0000 (15:05 -0500)] 
abi_ref/README: rename liblttng-ctl.xml to abi.xml

The ABI reference file in the tree is named abi.xml; use that name in
the examples too.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia295e1ea113e2eaf89c16e76d1334ad37bf4ad0e

12 days agoliblttng-ctl: Add XML representation of liblttng-ctl ABI from next 2.13 release
Jérémie Galarneau [Fri, 17 Jan 2025 19:43:48 +0000 (14:43 -0500)] 
liblttng-ctl: Add XML representation of liblttng-ctl ABI from next 2.13 release

2.13.15 will hide symbols that were erroneously exported by a fix
introduced since the initial 2.13.0 release.

This causes the CI to fail the master jobs as it detects breaking
changes since the latest 2.13 release.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ife0713e13efccd974de402afe93c3d678185d298

13 days agoliblttng-ctl: Add XML representation of liblttng-ctl ABI at v2.13.14
Kienan Stewart [Tue, 17 Dec 2024 20:15:42 +0000 (15:15 -0500)] 
liblttng-ctl: Add XML representation of liblttng-ctl ABI at v2.13.14

Change-Id: I24d1ce11af0eda7c76c794a32a3504bf0ad92241
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoliblttng-ctl: Hide mangled C++ symbols
Kienan Stewart [Tue, 17 Dec 2024 19:57:30 +0000 (14:57 -0500)] 
liblttng-ctl: Hide mangled C++ symbols

A number of functions in C++ have default visibility. To avoid those
symbols being erroneously available to those who load the liblttng-ctl
library, a version script has been added to set the visibility of all
name-mangled symbols to local.

Change-Id: If2df7cfbadb0d1b9d3747cdf4990cbc942118e6f
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agosession-config: Correct `config_xml_encoding_bytes_per_char`'s exported type
Kienan Stewart [Mon, 16 Dec 2024 14:36:46 +0000 (09:36 -0500)] 
session-config: Correct `config_xml_encoding_bytes_per_char`'s exported type

The ABI diff reports the following variable type change:

```
1 Changed variable:

  [C] 'const size_t config_xml_encoding_bytes_per_char' was changed to 'std::size_t config_xml_encoding_bytes_per_char' at session
-config.cpp:55:1:
    type of variable changed:
      entity changed from 'const size_t' to 'typedef std::size_t' at c++config.h:310:1
      type size hasn't changed
```

This patch also takes the opportunity to ensure that the "C" linkage
is used for the exported variables.

Change-Id: Id9739d290d1872bc803d2925ffa1d40b04c3e553
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agomi-lttng: Move deprecated symbols to liblttng-ctl
Kienan Stewart [Mon, 16 Dec 2024 14:28:18 +0000 (09:28 -0500)] 
mi-lttng: Move deprecated symbols to liblttng-ctl

The ABI diff between 2.13 and master hilights that the deprecated
variables are removed. Moving them to the deprecated-symbols file
ensures they are exported.

```
  [D] 'const char* const mi_lttng_context_type_perf_counter'    {mi_lttng_context_type_perf_counter}
  [D] 'const char* const mi_lttng_context_type_perf_cpu_counter'    {mi_lttng_context_type_perf_cpu_counter}
  [D] 'const char* const mi_lttng_context_type_perf_thread_counter'    {mi_lttng_context_type_perf_thread_counter}
  [D] 'const char* const mi_lttng_element_calibrate'    {mi_lttng_element_calibrate}
  [D] 'const char* const mi_lttng_element_calibrate_function'    {mi_lttng_element_calibrate_function}
  [D] 'const char* const mi_lttng_element_command_calibrate'    {mi_lttng_element_command_calibrate}
  [D] 'const char* const mi_lttng_element_track_untrack_pid_target'    {mi_lttng_element_track_untrack_pid_target}
  [D] 'const char* const mi_lttng_element_track_untrack_targets'
  {mi_lttng_element_track_untrack_targets}
```

Change-Id: I815556fac3281e0a4bf8ed92b8be0ce1b3276d02
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agosession-config: Move deprecated symbol
Kienan Stewart [Mon, 16 Dec 2024 14:23:40 +0000 (09:23 -0500)] 
session-config: Move deprecated symbol

This move element an ABI warning about `config_element_perf` being
removed.

```
9 Removed variables:

  [D] 'const char* const config_element_perf'    {config_element_perf}
...
```

Change-Id: I0bee12f610559edfa0718e5a7d90d06cf0c8f101
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoliblttng-ctl: Correct types for various exported strings
Kienan Stewart [Fri, 13 Dec 2024 21:14:40 +0000 (16:14 -0500)] 
liblttng-ctl: Correct types for various exported strings

Change-Id: Ib04ad688e634ce2fbc07652c835e9085e0832e4d
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoClean-up: Correct comment style in mi-lttng.cpp
Kienan Stewart [Fri, 13 Dec 2024 21:11:56 +0000 (16:11 -0500)] 
Clean-up: Correct comment style in mi-lttng.cpp

Change-Id: Idb79812ffd3933aa11f6e19b62a713408f5b0535
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoliblttng-ctl: Stub out removed variable `error_log_time`
Kienan Stewart [Tue, 7 Jan 2025 20:09:41 +0000 (15:09 -0500)] 
liblttng-ctl: Stub out removed variable `error_log_time`

Observed issue
==============

The ABI diff of liblttng-ctl between lttng-tools 2.13 and lttng-tools
master shows that this variable has been removed.

Cause
=====

The visibility of this symbol was restricted in commit
1944cedb180887d9dfe0906f930df167e714af99.

Solution
========

Add to deprecated symbols file.

Known drawbacks
===============

None.

Change-Id: I553c345c053ab39271871b68f7c2a4d1b1e1d628
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoliblttng-ctl: Re-expose several `config_str_*` variables
Kienan Stewart [Fri, 13 Dec 2024 19:14:21 +0000 (14:14 -0500)] 
liblttng-ctl: Re-expose several `config_str_*` variables

Observed issue
==============

The diff of the ABI of liblttng-ctl between lttng-tools 2.13 and
master shows the following removed variables:

```

```
7 Removed variables:

  [D] 'const char* const config_str_false'    {config_str_false}
  [D] 'const char* const config_str_no'    {config_str_no}
  [D] 'const char* const config_str_off'    {config_str_off}
  [D] 'const char* const config_str_on'    {config_str_on}
  [D] 'const char* const config_str_true'    {config_str_true}
  [D] 'const char* const config_str_yes'    {config_str_yes}
  [D] 'log_time error_log_time'    {error_log_time}
```

Cause
=====

The `const_str_*` variables were moved from `session-config.cpp` to
`ini-config.cpp`. Due to license in-compatibility (and probably lack
of immediate need), libini-config was never linked to libconfig-lgpl,
and thus to liblttng-ctl.

Solution
========

Link to libini-config to libconfig.

Known drawbacks
===============

None.

Change-Id: I4fdb15157ca4a7d4ee34dff7d1dcaa44b2e23aef
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agocommon/ini-config: Re-license to LGPL-2.1-only
Kienan Stewart [Fri, 13 Dec 2024 19:57:16 +0000 (14:57 -0500)] 
common/ini-config: Re-license to LGPL-2.1-only

Observed issue
==============

For ABI compatibility, the symbols e.g., `config_str_yes`, will need
to be included in liblttng-ctl. As the library is LGPL licensed, the
GPL code shouldn't be linked to it.

Solution
========

Re-license to LGPL-2.1-only.

Known drawbacks
===============

None.

Change-Id: Ia8163522e5dc21d44af98b03c019298019e3f05a
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agocommon: Use C ABI for exported lexer functions
Kienan Stewart [Fri, 13 Dec 2024 16:51:21 +0000 (11:51 -0500)] 
common: Use C ABI for exported lexer functions

Observed issue
==============

When examining the ABI changes between liblttng-ctl.so in lttng-tools 2.13 and
liblttng-ctl.so in lttng-tools 2.14, a large number of functions were
flagged as removed and added.

To produce the diff:

```
abidw stable-2.13/src/lib/lttng-ctl/.libs/liblttng-ctl.so.0.0.0 \
    > liblttng-ctl-stable-2.13.xml
abidw master/src/lib/lttng-ctl/.libs/liblttng-ctl.so.0.0.0 > liblttng-ctl-master.xml
abidiff \
    liblttng-ctl-stable-2.13.xml \
    liblttng-ctl-master.xml
```

Example of the removed and added functions (cut before brevity):

```
31 Removed functions:
...
  [D] 'function void lttng_yyset_in(FILE*, yyscan_t)'    {lttng_yyset_in}
  [D] 'function void lttng_yyset_lineno(int, yyscan_t)'    {lttng_yyset_lineno}
  [D] 'function void lttng_yyset_lval(yyscan_t)'    {lttng_yyset_lval}
  [D] 'function void lttng_yyset_out(FILE*, yyscan_t)'
  {lttng_yyset_out}

42 Added functions:
...
  [A] 'function void lttng_yyset_in(FILE*, yyscan_t)'    {_Z14lttng_yyset_inP8_IO_FILEPv}
  [A] 'function void lttng_yyset_lineno(int, yyscan_t)'    {_Z18lttng_yyset_linenoiPv}
  [A] 'function void lttng_yyset_lval(yyscan_t)'    {_Z16lttng_yyset_lvalP7YYSTYPEPv}
  [A] 'function void lttng_yyset_out(FILE*, yyscan_t)'    {_Z15lttng_yyset_outP8_IO_FILEPv}
  [A] 'method void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char co
nst*>(const char*, const char*, std::forward_iterator_tag)'    {_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_
M_constructIPKcEEvT_S8_St20forward_iterator_tag}
  [A] 'method void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(
char*, char*, std::forward_iterator_tag)'    {_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT
_S7_St20forward_iterator_tag}
  [A] 'method void std::vector<int, std::allocator<int> >::_M_realloc_append<int const&>()'    {_ZNSt6vectorIiSaIiEE17_M
_realloc_appendIJRKiEEEvDpOT_}
  [A] 'method void std::vector<int, std::allocator<int> >::reserve(std::__new_allocator<int>::size_type)'    {_ZNSt6vect
orIiSaIiEE7reserveEm}
```

Cause
=====

The lexer is now compiled with C++; however, the exported functions
that are explicitly marked for exportation (and end up globally visible in
liblttng-ctl), are not marked to use the C ABI.

Solution
========

Mark the exports with `extern "C" {...}` when compiling C++.

Known drawbacks
===============

None

Change-Id: I33caf05bc09315d4286682e222ee8648857e510b
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoClean-up: lttng-ctl: remove unused variable
Simon Marchi [Wed, 15 Jan 2025 19:02:23 +0000 (14:02 -0500)] 
Clean-up: lttng-ctl: remove unused variable

Fix:

      CXX      lttng-ctl.lo
    /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.cpp: In function 'int lttng_enable_channel(lttng_handle*, lttng_channel*)':
    /home/simark/src/lttng-tools/src/lib/lttng-ctl/lttng-ctl.cpp:1549:31: error: unused variable 'ret_code' [-Werror=unused-variable]
     1549 |         enum lttng_error_code ret_code;
          |                               ^~~~~~~~

Change-Id: Ie3b12eb9fba99578a677b1679147ea29daddb653
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoClean-up: clang-format fixes
Jérémie Galarneau [Thu, 16 Jan 2025 17:24:43 +0000 (17:24 +0000)] 
Clean-up: clang-format fixes

Change-Id: Ie5d2d6072290aaaedfe5990eed4f7c9baff02561
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoFix: sessiond: size-based kernel rotation doesn't trigger
Jérémie Galarneau [Thu, 16 Jan 2025 17:14:17 +0000 (17:14 +0000)] 
Fix: sessiond: size-based kernel rotation doesn't trigger

Issue observed
--------------

When a non-root user (part of the tracing group) creates a session (with kernel
domain recording channels) and sets a size-based rotation schedule, the session
daemon never performs the rotation.

Cause
-----

Size-based rotations are implemented using an internal trigger which uses a
consumed_size condition to send a notification to the session daemon.

The sessiond daemon logs indicate the following when the size threshold is crossed:

  DBG1 - 11:20:48.469994848 [Notification]: Session consumed size condition being evaluated: threshold = 1073741824, current size = 1059061760 (in evaluate_session_consumed_size_condition() at notification-thread-events.cpp:939)
  DBG1 - 11:20:48.470006990 [Notification]: Session consumed size condition being evaluated: threshold = 1073741824, current size = 1074790400 (in evaluate_session_consumed_size_condition() at notification-thread-events.cpp:939)
  DBG1 - 11:20:48.470034565 [Notification]: Enqueued action for trigger: trigger name = `(anonymous)`, work item id = 0 (in action_executor_enqueue_trigger() at action-executor.cpp:963)
  DBG1 - 11:20:48.470058161 [Notification]: Handling channel sample for channel channel0 (key = 1) in session kernel-benchmark-trace (highest usage = 1062205, lowest usage = 206058, consumed since last sample = 15728640) (in handle_notification_thread_channel_sample() at notification-thread-events.cpp:4930)
  DBG1 - 11:20:48.470069331 [Notification]: Entering poll wait (in thread_notification() at notification-thread.cpp:630)
  DBG1 - 11:20:48.470090340 [Action Executor]: Woke-up from wait (in action_executor_thread() at action-executor.cpp:754)
  DBG1 - 11:20:48.470100937 [Action Executor]: Starting execution of action work item 0 of trigger `(anonymous)` (in action_work_item_execute() at action-executor.cpp:701)
  DBG1 - 11:20:48.470111208 [Action Executor]: Policy every N = 1: execution accepted. Execution count: 1 (in lttng_rate_policy_every_n_should_execute() at actions/rate-policy.cpp:526)
  DBG1 - 11:20:48.470120044 [Action Executor]: Executing action `NOTIFY` of trigger `(anonymous)` action work item 0 (in action_executor_generic_handler() at action-executor.cpp:686)
  DBG1 - 11:20:48.470162012 [Action Executor]: Serializing session consumed size condition (in lttng_condition_session_consumed_size_serialize() at conditions/session-consumed-size.cpp:75)
  DBG1 - 11:20:48.470171532 [Action Executor]: Serializing notify action (in lttng_action_notify_serialize() at actions/notify.cpp:52)
  DBG1 - 11:20:48.470180192 [Action Executor]: Serializing notify action rate policy (in lttng_action_notify_serialize() at actions/notify.cpp:55)
  DBG1 - 11:20:48.470189784 [Action Executor]: Skipping client at it does not have the permission to receive notification for this trigger (in notification_client_list_send_evaluation() at notification-thread-events.cpp:4477)
  DBG1 - 11:20:48.470198680 [Action Executor]: Completed execution of action work item 0 of trigger `(anonymous)` (in action_work_item_execute() at action-executor.cpp:717)
  DBG1 - 11:20:48.470207436 [Action Executor]: No work items enqueued, entering wait (in action_executor_thread() at action-executor.cpp:752)
  DBG1 - 11:20:49.469998782 [Notification]: Poll wait returned (1) (in thread_notification() at notification-thread.cpp:632)

The "Skipping client at it does not have the permission to receive notification
for this trigger" hints at an invalid permission check.

Indeed, notification_client_list_send_evaluation() checks that the notification
client (on the other end of the notification channel) has the same UID as the
session on behalf of which the notification is emitted.

In this case, it is not the case. The session was created on behalf of user 1000
(part of the tracing group) while the notification client is root (uid = 0, the
session daemon performing kernel tracing).

Solution
--------

Allow notifications to go through when they target the root user.

Known drawbacks
---------------

None.

Change-Id: If66ab09523b41634e3118d6347ec500d15c70e53
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 days agoClean-up: sessiond: fix comment style
Jérémie Galarneau [Thu, 16 Jan 2025 17:10:02 +0000 (17:10 +0000)] 
Clean-up: sessiond: fix comment style

Change-Id: I269c049085c589da49868dec394be9bcc3917c2b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoTests: serial runner: fail test on abort (SIGINT and SIGTERM)
Jérémie Galarneau [Fri, 20 Dec 2024 15:02:31 +0000 (10:02 -0500)] 
Tests: serial runner: fail test on abort (SIGINT and SIGTERM)

The CI kills the test suite using SIGTERM when it remains stuck
for a given time. When this occurs, it is hard to figure out which
test was running.

Catch both SIGTERM and SIGINT signals to gracefully report a test
failure that indicates the top-level test that was running when
the signal was received.

The number of planned tests is extracted to give a "hint" to the
user that the test could not complete.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id2aa025b43e9ddc205c784cc5e100fd04b46c3b9

3 weeks agoTests: serial runner: remove unused time import
Jérémie Galarneau [Fri, 20 Dec 2024 13:52:57 +0000 (08:52 -0500)] 
Tests: serial runner: remove unused time import

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia82b0d5ddab83d129db926460d23c63e8e2c54af

3 weeks agoTests: Use `_run_lttng_cmd` instead of calling `$LTTNG_BIN` in utils
Kienan Stewart [Wed, 8 Jan 2025 14:45:22 +0000 (09:45 -0500)] 
Tests: Use `_run_lttng_cmd` instead of calling `$LTTNG_BIN` in utils

Observed issue
==============

Some commands aren't logged (e.g. `lttng_remove_trigger`) when the
verbose client environment variables are set.

Solution
========

Always pass by the `_run_lttng_cmd` helper.

Known drawbacks
===============

None.

Change-Id: I22c6c93fc9397f9d8ded5ce385ee1fa825fe1cb8
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoTests: Support redirection to identical stderr/stdout in`_run_lttng_cmd`
Kienan Stewart [Wed, 8 Jan 2025 14:22:02 +0000 (09:22 -0500)] 
Tests: Support redirection to identical stderr/stdout in`_run_lttng_cmd`

Observed issue
==============

`tests/regression/kernel/test_userspace_probe` fails with the
following error:

```
Bail out! The current `_run_lttng_cmd` implementation does not support
redirecting stdout and stderr to the same file.
```

Cause
=====

The commit aae350f3c2ac878227bae41281e7abca65e33c0f ("Tests: Add path
check to prevent incorrect redirection") introduces a
safety check to bail out if the same stderr and stdout file are used
in `_run_lttng_cmd`. This avoids some foot-gun scenarios where output
is expected in a file from both, but the implementation didn't
actually support it.

E.g.,

```
$ (echo stderr >&1 ; echo stdout) > /tmp/a 2>/tmp/a
$ cat /tmp/a
stdout

$ (echo stderr >&1 ; echo stdout) > /tmp/a 2>&1
$ cat /tmp/a
stderr
stdout
```

There has been a number of changes to both `_run_lttng_cmd` for
logging, and it's common for both `stdout_dest` and `stderr_dest` to
be set (usually to `/dev/null`).

In particular, this check ends up being triggered in
`tests/regression/kernel/test_userspace_probe`:

```
1..175
 # Userspace probe - Testing userspace probe on ELF symbol
ok 1 - 0 LTTng modules loaded, expected count = 0
 # export LTTNG_SESSION_CONFIG_XSD_PATH=/root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/common/
 # env /root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/bin/lttng-sessiond/lttng-sessiond --consumerd64-path=/root/workspace/lttng-tools_master_root_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/stable-0.14/node/sles15sp4-amd64-rootnode/platform/sles15sp4-amd64/src/lttng-tools/tests/../src/bin/lttng-consumerd/lttng-consumerd 1
ok 2 - Start session daemon
 # Userspace probe enable on non-existant file
 # Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 18167 18182
Bail out! The current `_run_lttng_cmd` implementation does not support redirecting stdout and stderr to the same file.
 # Looks like you planned 175 tests but only ran 2.
```

Solution
========

Add support for invoking `_run_lttng_cmd` with the same stderr and
stdout destinations.

Known drawbacks
===============

None.

Change-Id: I9133ccfd1f524000dbf02dfc05730feca1c59ab7
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoTests: Add path check to prevent incorrect redirection
Erica Bugden [Mon, 8 Jul 2024 16:07:17 +0000 (12:07 -0400)] 
Tests: Add path check to prevent incorrect redirection

The current implementation of `run_lttng_cmd` does not support
redirecting `stdout` and `stderr` to the same file. In the current
implementation:

    $TESTDIR/../src/bin/lttng/$LTTNG_BIN "$@" 1> "$stdout_dest" 2> "$stderr_dest"

the redirection of stderr would overwrite the redirection of stdout.

Add a check to bail out if the redirection paths are the same since the
test will not be as expected.

Change-Id: Ia8883f4978e4c0e534db1422a5aebf392403e723
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoFix: Tests: Add missing deletion of temporary folder
Erica Bugden [Mon, 8 Jul 2024 15:44:42 +0000 (11:44 -0400)] 
Fix: Tests: Add missing deletion of temporary folder

Change-Id: Ic5c66d15238bc04629fbd78b2759212784c41093
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoClean-up: Test list triggers: Remove unused tmp variables
Erica Bugden [Mon, 8 Jul 2024 15:42:13 +0000 (11:42 -0400)] 
Clean-up: Test list triggers: Remove unused tmp variables

The variables can be removed since the functions that compare the
actual and expected output for these tests, `list_triggers_matches_ok`
and `list_triggers_matches_mi_ok` define `tmp_stdout` and `tmp_stderr`
variables locally.

Change-Id: Ifa54a4034f4b6ed6ed0a1676f7c9e36d1c9affc6
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoClean-up: Test rate policy: Remove leading whitespace
Erica Bugden [Mon, 8 Jul 2024 15:27:44 +0000 (11:27 -0400)] 
Clean-up: Test rate policy: Remove leading whitespace

Change-Id: I5c55cda44afaac6cc85951e6c82425a58e21b82f
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoDocs: CodingStyle: Move error management guidelines to separate section
Erica Bugden [Mon, 8 Jul 2024 18:20:32 +0000 (14:20 -0400)] 
Docs: CodingStyle: Move error management guidelines to separate section

Move error management guidelines to separate section to group and highlight
them in the coding style.

Change-Id: I0d0ba0f8ea8a4c74c73bb28217a81b4efeb9a35f
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 weeks agoDocs: README: Specify how to run all the tests
Erica Bugden [Mon, 8 Jul 2024 18:25:31 +0000 (14:25 -0400)] 
Docs: README: Specify how to run all the tests

Change-Id: I082cc40ad362266c4813bc15b8c08ff5d209b03e
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 weeks agoTests: serial runner: FileExistsError not from pathlib
Jérémie Galarneau [Fri, 20 Dec 2024 13:45:23 +0000 (08:45 -0500)] 
Tests: serial runner: FileExistsError not from pathlib

The FileExistsError exception is not defined in the pathlib
module; it is a built-in exception.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1c6fd640d03cc7bad7afd32bf9eaaa28a838455a

6 weeks agoTests: Bail out of shell-based tests if bash version is not supported
Kienan Stewart [Wed, 11 Dec 2024 15:09:21 +0000 (10:09 -0500)] 
Tests: Bail out of shell-based tests if bash version is not supported

Change-Id: Ibb3b6d3b6069dae522a00273dd5b2f7990c095f3
Signed-off-by: Kienan Stewart <kstewart@effiicios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: lttng: Replace `exit()` with `return`
Kienan Stewart [Thu, 28 Nov 2024 20:49:03 +0000 (15:49 -0500)] 
Clean-up: lttng: Replace `exit()` with `return`

This also cleans-up from signal handlers that don't do any useful work.

Change-Id: If11cf6a55fc5902e4a7a2399d8550025e2f0c2be
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: lttng-consumerd: Replace `exit()` with `return`
Kienan Stewart [Thu, 28 Nov 2024 20:35:06 +0000 (15:35 -0500)] 
Clean-up: lttng-consumerd: Replace `exit()` with `return`

Change-Id: I64f4c24780ef7cb5fd016dfb8f43cbb6a6f1dfb0
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: lttng-crash replace `exit()` with `return`
Kienan Stewart [Thu, 28 Nov 2024 20:30:53 +0000 (15:30 -0500)] 
Clean-up: lttng-crash replace `exit()` with `return`

Use `return` to avoid running into issues in the future when using
`lttng::scope_exit` objects to perform clean-up.

Change-Id: I11d9585a2e3fb5c5453220a07c29f166016d46b9
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: sessiond: Replace `exit()` with `return`
Kienan Stewart [Thu, 28 Nov 2024 20:25:28 +0000 (15:25 -0500)] 
Clean-up: sessiond: Replace `exit()` with `return`

Use `return` to avoid running into issues in the future when using
`lttng::scope_exit` objects to perform clean-up.

Change-Id: Id4e4250c7f34355b953702ff8353300acca98ac8
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Use serial runner
Kienan Stewart [Thu, 7 Nov 2024 17:20:58 +0000 (12:20 -0500)] 
Tests: Use serial runner

Observed issue
==============

Running `make check -jN` with N greater than 1 will fail a number of
different checks.

Cause
=====

The majority of the tests aren't designed to work in
isolation (e.g. using `LTTNG_HOME` and `LTTNG_RUNDIR`), and some tests
that exercise global system resources (e.g. kernel modules) will never
work reliably in parallel.

Solution
========

Create a serial test runner that can execute all the tests that
require global resources while the other tests that are defined as
'safe to parallelize' can be run concurrently.

Known drawbacks
===============

None.

Change-Id: I0b87d2cd5e870ee7f9241ec78390ed96a01efb38
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests/Docs: Update recommendations on waiting on applications
Kienan Stewart [Thu, 14 Nov 2024 21:14:08 +0000 (16:14 -0500)] 
Tests/Docs: Update recommendations on waiting on applications

Change-Id: I0d79924b45f3cfa032348f2c90ffb8f80aa2b42c
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Track PIDs of started lttng-sessiond instances
Kienan Stewart [Thu, 14 Nov 2024 22:38:46 +0000 (17:38 -0500)] 
Tests: Track PIDs of started lttng-sessiond instances

Change-Id: I2f5538a7e94da77a6792974b0a5fa37bc5412009
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: Tests: Remove duplicate lttng-sessiond start
Kienan Stewart [Wed, 4 Dec 2024 14:56:45 +0000 (09:56 -0500)] 
Clean-up: Tests: Remove duplicate lttng-sessiond start

Change-Id: I3ec9fa964133b90a0480f852b8b8cbae5d05b8e2
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Do not use `lttng_pgrep` when testing working directory
Kienan Stewart [Thu, 14 Nov 2024 16:47:15 +0000 (11:47 -0500)] 
Tests: Do not use `lttng_pgrep` when testing working directory

This allows the tests to avoid modifying other lttng-relayds that may
be running on the system (e.g., during parallel testing).

Change-Id: I3736d96f54f3da2b887d88526f60056a020528a2
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Track PIDs of started lttng-relayd instances
Kienan Stewart [Thu, 14 Nov 2024 21:08:40 +0000 (16:08 -0500)] 
Tests: Track PIDs of started lttng-relayd instances

Change-Id: I88af6660c59175b2bec992cd45a6800b51166450
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: Tests: Provide default cwd when testing relayd working dir
Kienan Stewart [Thu, 28 Nov 2024 18:41:06 +0000 (13:41 -0500)] 
Clean-up: Tests: Provide default cwd when testing relayd working dir

In `tap.sh`, `is()` ends up aborting the test script if it is passed
an empty (null) value. When, for example, lttng-relayd fails to start,
the `cwd` will be empty as `readlink` will fail.

E.g. Output when a test fails and limits the runs:

```
...
ok 4 - lttng-relayd already started
  ---
    duration_ms: 12.914679
  ...

not ok 5 - Found lttng-relayd
  ---
    duration_ms: 49.119194
  ...

./tests/regression/tools/working-directory//../../..//utils/tap/tap.sh: line 288: 1: parameter null or not set
```

Change-Id: I54ac5c23a6d2604d261e8240679a827a12a57a1a
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Wait for specific PIDs of background applications
Kienan Stewart [Thu, 14 Nov 2024 19:28:06 +0000 (14:28 -0500)] 
Tests: Wait for specific PIDs of background applications

When running lttng-relayd or any other SUT from utils.sh in a fashion
that doesn't take it out of the test's process tree (e.g. when started
without '-d' or '-b'), `wait` will hang on those processes are well.

Change-Id: I82e0365d5165088980c0fce8e451fa0557ee201a
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agolttng-relayd: Add `--sig-parent` parameter
Kienan Stewart [Fri, 15 Nov 2024 15:55:39 +0000 (10:55 -0500)] 
lttng-relayd: Add `--sig-parent` parameter

Change-Id: I3a456f43de7ba2e557c1ca1c98466421e78e2f2e
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agolttng-relayd: Add `--pid-file` parameter
Kienan Stewart [Tue, 12 Nov 2024 20:23:06 +0000 (15:23 -0500)] 
lttng-relayd: Add `--pid-file` parameter

Intended to be used a mechanism to get the PID of the process when
starting with `-b` or `-d`.

`lttng-sessiond` writes to a well-known path inside `$LTTNG_HOME`
instead.

The exit for the lttng-relayd `main()` function is changed from
`exit()` to `return`. When using `exit()` or `std::exit()`, the
end-of-scope objects (e.g. from `lttng::make_scope_exit()` do not
fire.

Change-Id: I1ce6fd316356ac251cb3a0c0039c565f1ca1210f
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoerror: Add `PWARN_FMT` and `PERROR_FMT` macros
Kienan Stewart [Wed, 11 Dec 2024 15:53:59 +0000 (10:53 -0500)] 
error: Add `PWARN_FMT` and `PERROR_FMT` macros

Change-Id: Ib46fbed81c429f54793c9787a537950faa5552e0
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agocommon: Add arm() function to scope_exit objects
Kienan Stewart [Wed, 11 Dec 2024 15:53:23 +0000 (10:53 -0500)] 
common: Add arm() function to scope_exit objects

Change-Id: Ib8bc147f0fb7f884de4005af9bb372362af41850
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Start sessiond in python test environments with `--no-kernel`
Kienan Stewart [Thu, 7 Nov 2024 13:44:36 +0000 (08:44 -0500)] 
Tests: Start sessiond in python test environments with `--no-kernel`

Observed issue
==============

One of the goals of the lttngtest Environment is to be able to produce
separate test environments for each run in order to eventually run
some tests in parallel.

Solution
========

If `lttng-sessiond` is run as root, by default it will attempt to load
the lttng-modules kernel modules.

The session daemon is now started with `--no-kernel` to disable the
kernel domain and prevent that instance from loading the kernel
modules. This behaviour can be changed for specific tests that
exercise kernel tracing.

Known drawbacks
===============

The `--no-kernel` start is less representative of the default usage of
the session daemon.

Change-Id: Iacb85d0a33d6981bd038d57bf629d61117f9344d
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Use dynamically allocated ports for relayd
Kienan Stewart [Tue, 29 Oct 2024 18:33:05 +0000 (18:33 +0000)] 
Tests: Use dynamically allocated ports for relayd

Change-Id: I671885ef178e31abd8ffe7ca34a528da43f8044b
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoTests: Check python version before using signal.strsignal
Kienan Stewart [Thu, 7 Nov 2024 13:38:13 +0000 (08:38 -0500)] 
Tests: Check python version before using signal.strsignal

Observed issue
==============

When running CI tests against sles12sp5 (with python 3.4) the clean-up
of a stalled test produced the following output:

```
Traceback (most recent call last):
  File "./tools/live/test_early_inactive_app.py", line 111, in <module>
    log=tap.diagnostic, with_relayd=True, with_sessiond=True
  File "/usr/lib64/python3.4/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1192, in test_environment
    with_sessiond, log, with_relayd, extra_env_vars, skip_temporary_lttng_home
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 677, in __init__
    self._launch_lttng_relayd() if with_relayd else None
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 933, in _launch_lttng_relayd
    time.sleep(0.1)
  File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1044, in _handle_termination_signal
    signal_name=signal.strsignal(signal_number)
AttributeError: 'module' object has no attribute 'strsignal'
```

Cause
=====

`signal.strsignal` is introduced in Python 3.8[1].

Solution
========

Check the system version and fall back to using `str(signal_number)`
which will give the numeric signal (e.g. signal.SIGKILL -> 9).

Known drawbacks
===============

None.

References
==========
[1]: https://docs.python.org/3/library/signal.html#signal.strsignal

Change-Id: I04d0560225f8332364d2da2ecd77be2802569cc9
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agolttng-relayd: Write control, data, and live ports to rundir
Kienan Stewart [Fri, 25 Oct 2024 20:58:46 +0000 (20:58 +0000)] 
lttng-relayd: Write control, data, and live ports to rundir

Change-Id: I7ff61e5dc6612de80641ac36fa98abdce3da97b4
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agolttng-relayd: Add option to delegate port choice to OS
Kienan Stewart [Fri, 25 Oct 2024 20:18:53 +0000 (20:18 +0000)] 
lttng-relayd: Add option to delegate port choice to OS

Change-Id: I8fdbfac5511f404eb6868c0f5b9de7bbb1ad7623
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoutils: Add generic helper to create value files
Kienan Stewart [Mon, 25 Nov 2024 16:06:39 +0000 (11:06 -0500)] 
utils: Add generic helper to create value files

Change-Id: Ie814a4ddd22d9af578a194b73ed52b65df5128e4
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: lttng-relayd: Correct typo in error message
Kienan Stewart [Fri, 1 Nov 2024 14:58:08 +0000 (10:58 -0400)] 
Clean-up: lttng-relayd: Correct typo in error message

Change-Id: I53f2900f2233fcdd8723457d4cec8e8a0ef10391
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoClean-up: lttng-relayd: Correct variable name typo
Kienan Stewart [Tue, 29 Oct 2024 15:31:37 +0000 (15:31 +0000)] 
Clean-up: lttng-relayd: Correct variable name typo

Change-Id: Id62a4e621c3e1d1cd138f85903143b7acd1197fb
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agomisc: Allow users to override the location of clang-format
Jérémie Galarneau [Thu, 12 Dec 2024 19:16:22 +0000 (19:16 +0000)] 
misc: Allow users to override the location of clang-format

Since the coding imposes a specific version of clang-format (16),
the pre-commit hook can fail for reasons out of the contributor's
control.

Local git config settings are used to allow the user to specify
the location of these tools.

  git config --local hooks.clangFormatPath /path/to/clang-format-16

The settings are retrieved by the script and used if they were
specified.

Note that we should probably do the same for `black` as they
change the formatting from version to version. Right now I
feel we imply "use the latest version", but we should probably
impose one and update it on a release-to-release basis.

Change-Id: Iabb3e3964dc137075474ae4a240f30e0ecf4ec0d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agomisc: Add pre-commit hook for common checks
Kienan Stewart [Tue, 10 Dec 2024 17:11:37 +0000 (12:11 -0500)] 
misc: Add pre-commit hook for common checks

The initial version of the pre-commit hook, if installed, will check
the changed with clang-format, clang-tidy, and
python-black. Furthermore, C/C++ source files will be parsed using
python-clang and the comment style (starting with `/*` and ending with
`*/`) will be validated.

This pre-commit hook will check only the staged files.

To install the pre-commit hook:

    ln -s ../../extras/pre-commit.py .git/hooks/pre-commit

Example:

```
$ git hook run pre-commit 2>&1
ERROR:root:Failed rule 'cpp-comment-style'
Wrong comment style at <SourceRange start <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 109, column 1>, end <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 109, column 6>>
// hi
Wrong comment style at <SourceRange start <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 111, column 1>, end <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 111, column 12>>
/** hey **/
Wrong comment style at <SourceRange start <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 113, column 1>, end <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 113, column 11>>
/* sup **/
Wrong comment style at <SourceRange start <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 115, column 1>, end <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 115, column 3>>
//
Wrong comment style at <SourceRange start <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 117, column 1>, end <SourceLocation file 'src/bin/lttng-sessiond/main.cpp', line 117, column 5>>
/**/

ERROR:root:Failed rule 'clang-format'
src/bin/lttng-sessiond/main.cpp:1516:63: error: code should be clang-formatted [-Wclang-format-violations]
        /* Queue of rotation jobs populated by the sessiond-timer. */
                                                                     ^
src/bin/lttng-sessiond/main.cpp:1518:47: error: code should be clang-formatted [-Wclang-format-violations]
        struct lttng_thread *client_thread = nullptr;
                                                     ^

ERROR: root:Failed rule 'python-black'
would reformat asdf.py

Oh no! 💥 💔 💥
1 file would be reformatted.

Change-Id: I91f287a41f242d70aa4feb2b8ca8a6fd46ef708e
--- asdf.py     2024-12-10 19:56:34.558499+00:00
+++ asdf.py     2024-12-10 20:48:24.892474+00:00
@@ -1,4 +1,4 @@
 #!/usr/bin/python3

-if __name__ == '__main__':
+if __name__ == "__main__":
     pass

WARNING:root:Passed: 1
ERROR:root:Failed: 3
ERROR:root:Failed rule: cpp-comment-style
ERROR:root:Failed rule: clang-format
ERROR:root:Failed rule: python-black
```

Known drawbacks
===============

This operates on the whole files instead of the diffs.

The following supplementary tools are required for the pre-commit hook
to run:

 * clang-format
 * clang-tidy
 * python-blacken
 * python-clang (shipped with some clang releases)

Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Change-Id: Icc5e7c9324ebc937cf295619f53557649797d914
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 weeks agoCodingStyle.md: update clang-format version to 16
Jérémie Galarneau [Thu, 12 Dec 2024 19:09:32 +0000 (19:09 +0000)] 
CodingStyle.md: update clang-format version to 16

The formating script and .clang-format both require clang-format 16.

Change-Id: Icfbf96fc0e31715cc988b5413d8c100442bab44a
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 weeks agoClean-up: Remove checkpatch
Kienan Stewart [Tue, 10 Dec 2024 17:04:51 +0000 (12:04 -0500)] 
Clean-up: Remove checkpatch

The project rarely sees e-mail contributions and has moved to C++ as
the main programming language, so checkpatch.pl is not longer very
pertinent.

Change-Id: I799ecc6884e80e078c2cd46c284f1c50d3b332b6
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 weeks agoClean-up: docs: Correct typos in contributing documentation
Kienan Stewart [Tue, 10 Dec 2024 20:53:30 +0000 (15:53 -0500)] 
Clean-up: docs: Correct typos in contributing documentation

Change-Id: I3b4c25a5c53ec2ce7c24f7f3a7b674ce07354cd5
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 weeks agosessiond: document the types contained by the ust_app_channel HTs
Jérémie Galarneau [Thu, 5 Dec 2024 19:56:02 +0000 (19:56 +0000)] 
sessiond: document the types contained by the ust_app_channel HTs

Change-Id: I6b694da52ac35eeb046b9e33b143ecb01b42baf5
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 weeks agoClean-up: sessiond: remove unused ust_app_channel::ctx_list
Jérémie Galarneau [Thu, 5 Dec 2024 19:52:14 +0000 (19:52 +0000)] 
Clean-up: sessiond: remove unused ust_app_channel::ctx_list

Change-Id: Ice55acc6a40fd307e34ba952abd51b957768d131
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agolttng: Tests: Add test for shm size warning
Kienan Stewart [Wed, 13 Nov 2024 16:28:03 +0000 (11:28 -0500)] 
lttng: Tests: Add test for shm size warning

Change-Id: I20c5bc97f47288f308028d4c3c067a19e913a878
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agolttng: Warn on session start when client-visible shm path is too small
Kienan Stewart [Fri, 8 Nov 2024 20:59:43 +0000 (15:59 -0500)] 
lttng: Warn on session start when client-visible shm path is too small

Observed issue
==============

When adding one or more channels to a session, it is possible to
configure sessions such that the minimum memory required to
successfully trace exceeds the size of the shared memory location.

There is no user feedback when starting sessions that are configured
in such a way that they will never work. It therefore leads to
user confusion when no events are recorded.

Steps to reproduce
==================

On a system with 4 cpus:

```
sudo mount -t tmpfs -o size=64M tmpfs /mnt
lttng create --shm-path=/mnt
lttng enable-channel -u --subbuf-size=8M a0
lttng enable-event -u --all -c a0
lttng start

lttng stop
```

Cause
=====

As allocations are made lazily, there is no feedback for this type of
scenario visible to an lttng client. The session can successfully
start; however, there will be allocation errors visible in the
consumer daemon logs.

Solution
========

When starting a session, the minimum shared memory size required is
estimated using the configured non-kernel channels. This assumes
per-PID or per-UID buffers with a single PID or a single UID. An extra
set of buffers are estimated when the session is configured in
snapshot mode.

E.g.

```
$ lttng create
Session auto-20241112-102937 created.
Traces will be output to
/home/kstewart/src/efficios/lttng/master/home//lttng-traces/auto-20241112-102937

$ lttng enable-channel -u --subbuf-size=256M --num-subbuf=8 a2
user space channel `a2` enabled for session `auto-20241112-102937`

$ lttng start
Warning: The estimated minimum shared memory size for all non-kernel channels of session 'auto-20241112-102937' is greater than the total shared memory allocated to the default shared memory location (8192MiB >= 7873MiB). Tracing for this session may not record events due to allocation failures.
Tracing started for session `auto-20241112-102937`

$ lttng list
Available recording sessions:
  1) auto-20241112-102937 [active]
    Trace output:
    /home/kstewart/src/efficios/lttng/master/home//lttng-traces/auto-20241112-102937
```

Known drawbacks
===============

The intention of this change is to be backwards compatible, and
therefore doesn't stop the session from being started.

With per-PID or per-UID sub-buffers, the estimate is based only a
single PID or UID. Additional PIDs or UIDs could cause allocation
failures later on in the runtime which will continue to only be
visible in the consumer daemon logs.

The shm path is estimated by the lttng client rather than the consumer
daemon. It is possible for the consumer daemon be running in a
different container whose shared memory path maps to a different
backing storage.

This checks only against the total size of the shared memory storage -
not the current available usage. It does not take into account other
current enabled sessions.

Change-Id: I589ec461ec4a89b72bcdf1271065591ac471acca
Signed-off-by: Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agolttng-ctl/lttng: Move enable-channel memory check to client
Kienan Stewart [Wed, 13 Nov 2024 20:37:36 +0000 (15:37 -0500)] 
lttng-ctl/lttng: Move enable-channel memory check to client

Change-Id: I855284c3f2a6910363a075e6a7bb4c6d55b22685
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agolttng-ctl: Use max possible CPUs for per-CPU memory estimation
Kienan Stewart [Wed, 13 Nov 2024 19:55:44 +0000 (14:55 -0500)] 
lttng-ctl: Use max possible CPUs for per-CPU memory estimation

As of 2.13.4, LTTng-UST uses the max possible CPU count for per-CPU
allocations.

See lttng-ust commit 66dbdc3448a77043d0fd59f47b17e77a8d59fddb
("fix: num_possible_cpus() with hot-unplugged CPUs").

Change-Id: Ia4eb25988a268f48065903617ed59a5fdecb2ab9
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agocommon: Add helper to get max possible CPU count
Kienan Stewart [Wed, 13 Nov 2024 19:53:03 +0000 (14:53 -0500)] 
common: Add helper to get max possible CPU count

`get_max_possible_cpu_id()` is adapted from lttng-ust[1].

[1]: https://github.com/lttng/lttng-ust/blob/c0de10a2dab6d5cc6568e12c0ad3b97d85e0dc6b/src/common/smp.c#L197

Change-Id: I2697be51b21dad424c74d7397c1e6649ca7456bb
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agolttng-ctl: Add session shm_path to extended session attributes
Kienan Stewart [Fri, 8 Nov 2024 20:59:00 +0000 (15:59 -0500)] 
lttng-ctl: Add session shm_path to extended session attributes

Observed issue
==============

Once a session is created, any lttng clients have no way of checking
what the current shared memory path setting for a session is.

Solution
========

Expose the configure path via an attribute in the extended structure
of lttng sessions.

Known drawbacks
===============

None.

Change-Id: Ie257bcedfc913e09fc6a60e6b9387d2e8d4cb828
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agoTests: Add skip_all_remaining helper to python tap-generator
Kienan Stewart [Wed, 13 Nov 2024 17:03:11 +0000 (12:03 -0500)] 
Tests: Add skip_all_remaining helper to python tap-generator

`skip_all` can only be used if a plan hasn't been emitted yet.

Change-Id: Ib2f132edf496495068f6679d563a8a35de38a33a
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agoTests: Support multi-line diagnostic messages
Kienan Stewart [Wed, 13 Nov 2024 15:58:26 +0000 (10:58 -0500)] 
Tests: Support multi-line diagnostic messages

Change-Id: Icf16a39814b70ae9a9548add78135118477254ff
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agoTests: Add option to set session shm path
Kienan Stewart [Wed, 13 Nov 2024 15:58:06 +0000 (10:58 -0500)] 
Tests: Add option to set session shm path

Change-Id: I0a5b2b32351438d37c47f3e9920e5cebbf1bdf50
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agoTests: Add subbuf_size and subbuf_count options for channels
Kienan Stewart [Wed, 13 Nov 2024 15:56:50 +0000 (10:56 -0500)] 
Tests: Add subbuf_size and subbuf_count options for channels

Change-Id: I374dd4d1f9c501570dacd5f6e1abd90d6f383f62
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 weeks agoTests: Add pre-delete callbacks to TemporaryDirectory destructor
Kienan Stewart [Wed, 13 Nov 2024 15:53:18 +0000 (10:53 -0500)] 
Tests: Add pre-delete callbacks to TemporaryDirectory destructor

This will allow certain test clean-up operations (e.g., `umount`) to
be run before trying to to remove the directory.

Change-Id: I193030dfe4aeb0eeebc4370849681cbd9dcf500e
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agotests: Test that no LTTng modules are loaded before and after kernel tests
Kienan Stewart [Thu, 4 Jul 2024 13:28:32 +0000 (09:28 -0400)] 
tests: Test that no LTTng modules are loaded before and after kernel tests

Observed issue
==============

If a test or a component in LTTng fails to unload the modules
properly, the state of the system is polluted.

Solution
========

Use a helper test function and check before and after each of the
kernel tests.

Known drawbacks
===============

None.

Change-Id: I0cce0d9e280bd66535af490c9a111526ab78373c
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agotests: Add helper functions to validate if lttng modules are loaded
Kienan Stewart [Thu, 4 Jul 2024 13:25:51 +0000 (09:25 -0400)] 
tests: Add helper functions to validate if lttng modules are loaded

Observed issue
==============

Regression tests exercising kernel modules don't validate before and
after the test execution that there are no LTTng kernel modules
loaded.

Solution
========

Add convenient tap helper functions that may be used by shell TAP
tests.

Known drawbacks
===============

None.

Change-Id: I8244358137c2d049ed72e6dc7d9290cb9dda10e3
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: Update lttng-modules load list
Kienan Stewart [Wed, 3 Jul 2024 19:51:29 +0000 (15:51 -0400)] 
Fix: Update lttng-modules load list

Observed issue
==============

When starting a root sessiond, after stopping it there would still be
lttng-modules modules loaded in the kernel.

```
$ lsmod | grep lttng || echo "nothing"
nothing

$ lttng-sessiond -b

$ killall lttng-sessiond

$ lsmod | grep lttng || echo "nothing"
lttng_statedump       757760  0
lttng_wrapper          16384  1 lttng_statedump
lttng_uprobes          12288  0
lttng_clock            12288  0
lttng_kprobes          12288  0
lttng_lib_ring_buffer    90112  0
lttng_kretprobes       12288  0
```

Cause
=====

Not all modules are listed in the core/data modules in `modprobe.cpp`.

Solution
========

Add missing modules.

Known drawbacks
===============

None.

Change-Id: I28525c55eadb95467f77ffac0b9152ac8576e0fc
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: sessiond: notification-thread: add to pollset fails silently
Jérémie Galarneau [Wed, 20 Nov 2024 16:44:12 +0000 (16:44 +0000)] 
Fix: sessiond: notification-thread: add to pollset fails silently

Noticed when reviewing the code, so I don't have a reproducer
for the issue. However, the "ADD_TRACER_EVENT_SOURCE" command
returns LTTNG_OK even when the notification thread fails to add
the tracer event source to the poll set.

The error path properly performs the requisite clean-up, but
the command emitter will be under the impression that the command
succeeded. In doing so, it will most likely use the
"REMOVE_TRACER_EVENT_SOURCE" at a later point which will cause
a failed assertion to hit when the `source_element` isn't found.

Change-Id: I4a400d6affa21d2c2247ecfb845ca1e4aa730b5d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agodocs: Fix up test documentation
Kienan Stewart [Tue, 29 Oct 2024 12:40:33 +0000 (08:40 -0400)] 
docs: Fix up test documentation

Observed issue
==============

Principally `LTTNG_TEST_GDBSERVER_SESSIOND` was listed twice in the
table, and `LTTNG_TEST_GDBSERVER_SESSIOND_WAIT` was no listed.

Solution
========

The duplicate `LTTNG_TEST_GDBSERVER_SESSIOND` has been removed and
`LTTNG_TEST_GDBSERVER_SESSIOND_WAIT` added.

The wording on the `*_GDBSERVER_WAIT` variables has been clarified.

The ordering of the new entries was modified to preserve alphabetical ordering.

Known drawbacks
===============

None.

Change-Id: I932a892a6aa78f37bb9a3a1c5ddaf8fadb552f56
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agodocs: Update coding standard blurb in contributions readme
Kienan Stewart [Tue, 29 Oct 2024 12:48:45 +0000 (08:48 -0400)] 
docs: Update coding standard blurb in contributions readme

Observed issue
==============

The CodingStyle document now includes style guidelines for Python,
Shell (bash), and legacy C code.

Solution
========

* Fix wording in the first sentence and use a relative link to the file
* Remove paragraph that other languages do not have a coding style
* Add a link to the test README

Known drawbacks
===============

None.

Change-Id: I057ae8d51afaa07892aa40b47c2f1716574b3b06
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoClean-up: sessiond: document ownership of agent
Jérémie Galarneau [Tue, 26 Nov 2024 15:44:52 +0000 (15:44 +0000)] 
Clean-up: sessiond: document ownership of agent

`agent` instances are lazily created at various sites and their
ownership can be confusing for both analysis tools and meat bags.

Document that the ownership of the instance is transferred by the
`agent_add` function.

Change-Id: I709d2908611bdebd88c82261d1e5d5ee3bde3a09
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: sessiond: cmd_add_ctx: leak of internal channel members
Jérémie Galarneau [Tue, 26 Nov 2024 15:27:10 +0000 (15:27 +0000)] 
Fix: sessiond: cmd_add_ctx: leak of internal channel members

lttng_channel instances must be released using channel_attr_destroy.
However, an error path of cmd_add_ctx uses free() directly, which causes
internal structures of lttng_channel to be leaked.

Wrap the lttng_channel instance to use a unique_ptr which invokes
channel_attr_destroy on release.

Change-Id: I77443c8a57475437dbb11792869e70840680492f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoClean-up: sessiond: enable_event: use unique_ptr to manage memory
Jérémie Galarneau [Tue, 26 Nov 2024 15:07:53 +0000 (15:07 +0000)] 
Clean-up: sessiond: enable_event: use unique_ptr to manage memory

Simplify the error paths used to create the internal events associated
with agent events as copies of the filter bytecode and expressions are
performed.

Change-Id: I260bcabb8965e4c86cbc9e40fdd056a294ced676
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: sessiond: leak of filter_expression, bytecode, and exclusion
Jérémie Galarneau [Tue, 26 Nov 2024 14:56:53 +0000 (14:56 +0000)] 
Fix: sessiond: leak of filter_expression, bytecode, and exclusion

The filter_expression, bytecode, and exclusion arguments are leaked
whenever a client omits the transmission of an event-rule as part of an
enable-event command (a protocol error).

Ensure the three arguments are automatically managed using smart
pointers before performing the protocol consistency check.

Change-Id: I4c4f1d5d7b6acdd215ef34e1fc8f2c4bc81a674a
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: lttng-ctl: Validate lttng_enable_event_with_exclusions inputs at beginning of...
Mathieu Desnoyers [Tue, 26 Nov 2024 14:41:18 +0000 (14:41 +0000)] 
Fix: lttng-ctl: Validate lttng_enable_event_with_exclusions inputs at beginning of function

Checking for ev == nullptr after having dereferenced ev triggers this
Coverity warning:

    CID 1566411:  Null pointer dereferences  (REVERSE_INULL)
    Null-checking "ev" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

Move the handle and ev nullptr checks before the LTTNG_EVENT_ALL
special-case. This is relevant because within LTTNG_EVENT_ALL, after
modifying the event type, lttng_enable_event_with_exclusions is invoked
again with the modified type, which will end up doing the input
validation anyway.

Move the original_filter_expression before the LTTNG_EVENT_ALL event
type check for the same reason: it will end up being checked with the
modified event type in the nested call anyway, so favor early checking
of input arguments.

Change-Id: Id1c931300aa49477a9f480698f5dad645240b904
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoFix: sessiond: uninitialized ust_app event_notifier_group
Kienan Stewart [Thu, 21 Nov 2024 20:03:56 +0000 (15:03 -0500)] 
Fix: sessiond: uninitialized ust_app event_notifier_group

Observed issue
==============

On SLES12SP5 (gcc 4.8.5), occasional crashes were observed with the
following log entry:

```
DBG1 - 18:49:41.084261033 [Notification]: Poll wait returned (1) (in thread_notification() at notification-thread.cpp:632)
DBG1 - 18:49:41.084264635 [Notification]: Handling fd (28) activity (1) (in thread_notification() at notification-thread.cpp:656)
DBG1 - 18:49:41.084269451 [Notification]: Received `REMOVE_TRACER_EVENT_SOURCE` command (in handle_notification_thread_command() at notification-thread-events.cpp:3178)
lttng-sessiond: notification-thread-events.cpp:2228: int
handle_notification_thread_command_remove_tracer_event_source(notification_thread_state*,
int, lttng_error_code*): Assertion `source_element' failed
```

The easiest reproduce was to comment out most all tests in
`regression/ust/ust-app-ctl-paths/test_ust_app_ctl_paths` except
`test_trace_self_default_paths`. Then run a loop until a failure is
detected, e.g.

```
make -j4 && \
ITER=0 && \
while true ; do LTTNG_UST_DEBUG=1 LTTNG_TEST_LOG_DIR=- LTTNG_TEST_VERBOSE_SESSIOND=1 ./tests/regression/ust/ust-app-ctl-paths/test_ust_app_ctl_paths 2>&1 | tee sessiond.log ; if grep -qE '^not ok' sessiond.log ; then break; fi ; ITER=$((ITER+1)) ; echo "Done $ITER iterations" ; sleep 1 ; done
```

Cause
=====

After investigation, it appears to be that `lta = new ust_app;` may
occasionally return the address multiple times when previous
allocation is rapidly de-allocated.

For example, in the following snippet of a log tracking an application
address that shows re-use:

```
DBG1 - 19:47:29.103043500 [UST registration dispatch]: Create new ust app allocation 0x7fce14001da0 for pid 23256 sock 53 (in ust_app_create() at ust-app.cpp:4061)
DBG1 - 19:47:29.115347169 [UST registration dispatch]: wait_node_in_queue looked up app 0x7fce14001da0 pid 23256 (in thread_dispatch_ust_registration() at dispatch.cpp:362)
DBG1 - 19:47:29.115933991 [UST registration dispatch]: ust app version app 0x7fce14001da0 pid 23256 (in thread_dispatch_ust_registration() at dispatch.cpp:392)
DBG1 - 19:47:29.115954872 [UST registration dispatch]: Added ust app 0x7fce14001da0 pid 23256 (in thread_dispatch_ust_registration() at dispatch.cpp:403)
DBG1 - 19:47:29.115958125 [UST registration dispatch]: ust_app_setup_event_notifier_group app 0x7fce14001da0 pid 23256 (in ust_app_setup_event_notifier_group() at ust-app.cpp:4226)
DBG1 - 19:47:29.116367064 [UST registration dispatch]: app 0x7fce14001da0 add tracer event source in setup_event_notifier_group fd 60 ret 10 (in ust_app_setup_event_notifier_group() at ust-app.cpp:4279)
DBG1 - 19:47:29.117653161 [UST registration dispatch]: app 0x7fce14001da0 pid 23256 return from setup trace event notifier group ret 0, event notifier group 0x7fce14003180 (in ust_app_setup_event_notifier_group() at ust-app.cpp:4313)
DBG1 - 19:47:29.152058781 [23308/23332]: delete_ust_app 0x7fce14001da0 pid 23256 sock 53 (in delete_ust_app() at ust-app.cpp:1021)
DBG1 - 19:47:29.152076408 [23308/23332]: No event notifier group object remove tracer event source fd 60 app 0x7fce14001da0 (in delete_ust_app() at ust-app.cpp:1075)
DBG1 - 19:47:29.191427936 [UST registration dispatch]: Create new ust app allocation 0x7fce14001da0 for pid 23371 sock 71 (in ust_app_create() at ust-app.cpp:4061)
DBG1 - 19:47:29.204450310 [UST registration dispatch]: wait node 0x7fce14001d10, app 0x7fce14001da0 (in sanitize_wait_queue() at dispatch.cpp:144)
DBG1 - 19:47:29.204454373 [UST registration dispatch]: Culling app from wait queue: pid=23371 app 0x7fce14001da0 (in sanitize_wait_queue() at dispatch.cpp:146)
DBG1 - 19:47:29.259291727 [23308/23332]: delete_ust_app 0x7fce14001da0 pid 23371 sock 71 (in delete_ust_app() at ust-app.cpp:1021)
DBG1 - 19:47:29.590230014 [23308/23332]: No event notifier group object remove tracer event source fd 81 app 0x7fce14001da0 (in delete_ust_app() at ust-app.cpp:1075)
lttng-sessiond: notification-thread-events.cpp:2233: int handle_notification_thread_command_remove_tracer_event_source(notification_thread_state*, int, lttng_error_code*):
Assertion `source_element' failed.
```

As this variable is default initialized[1], the memory contents are
indeterminate. In `ust_app_create`, many fields are manually
initialized; however `lta->event_notifier_group.object` is not set
explicitly.

The next time `event_notifier_group.object` is set is when the the
`notification_thread_command_add_tracer_event_source` succeeds. If the
app dies before than, or if that registration fails, the
`ust_app.event_notifier_group.object` may be non-NULL. When this
object passes to `delete_ust_app`, the only check made before trying
to remove the tracer event
source (`notification_thread_command_remove_tracer_event_source`) is
if `event_notifier_group.object` is NULL or not.

If the file descriptor hasn't been previously registered, the assert
is triggered.

While I haven't confirmed my hypothesis, it is possible that the
behaviour of GCC regarding default initialization has changed between
GCC 4.8.5 and now.

Solution
========

Use an explicit initialization for the new allocation.

Known drawbacks
===============

None.

References
==========

[1]: https://en.cppreference.com/w/cpp/language/default_initialization (See case 2)

Change-Id: I12de1864d2995be014d5526283fb843d0f99093e
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 months agoDocs: Correct `LTTNG_RUNDIR` environment variable name
Kienan Stewart [Fri, 1 Nov 2024 15:33:39 +0000 (11:33 -0400)] 
Docs: Correct `LTTNG_RUNDIR` environment variable name

Change-Id: I13c803f946bf25cc9c622e2d4d156ecc3af3457d
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.052254 seconds and 4 git commands to generate.