lttng-tools.git
3 years agoUpdate version to v2.13.0-rc2 v2.13.0-rc2
Jérémie Galarneau [Sat, 15 May 2021 03:32:57 +0000 (23:32 -0400)] 
Update version to v2.13.0-rc2

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: expected procname should not have -ust suffix
Mathieu Desnoyers [Sat, 15 May 2021 00:57:33 +0000 (20:57 -0400)] 
Fix: expected procname should not have -ust suffix

commit ("Fix: ustcomm: application name uses the '-ust'-suffixed thread
name") in LTTng-UST removes "-ust" suffix from procname, which appears
in the output trace directory hierarchy.

Adapt tests to not expect this quirk.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I96c3944124bbe154875085a37a51ba2bd458f83b

3 years agoFix: Tests: leftover temporary files after tests
Francis Deslauriers [Fri, 14 May 2021 19:45:15 +0000 (15:45 -0400)] 
Fix: Tests: leftover temporary files after tests

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie0c66d45a00e890c1f1e8dc8db7b1baa2cca50f1

3 years agoFix: trigger: abort() when adding `--notify` action with python event rule matches
Francis Deslauriers [Wed, 12 May 2021 15:28:26 +0000 (11:28 -0400)] 
Fix: trigger: abort() when adding `--notify` action with python event rule matches

Issue
=====
Adding the following trigger makes the sessiond abort:
  lttng add-trigger --condition=event-rule-matches --domain=python --action=notify

With the following stacktrace:
  (gdb) bt
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x00007ffff7a71859 in __GI_abort () at abort.c:79
  #2  0x00000000004a1eeb in event_notifier_error_accounting_register_event_notifier (trigger=0x7fffe0000f50, error_counter_index=0x7fffefffde38) at event-notifier-error-accounting.c:1075
  #3  0x00000000004743e6 in setup_tracer_notifier (state=0x7fffefffe3e8, trigger=0x7fffe0000f50) at notification-thread-events.c:2606
  #4  0x000000000046dacb in handle_notification_thread_command_register_trigger (state=0x7fffefffe3e8, trigger=0x7fffe0000f50, is_trigger_anonymous=false, cmd_result=0x7fffedfdd6e8) at notification-thread-events.c:2751
  #5  0x000000000046d083 in handle_notification_thread_command (handle=0x601460, state=0x7fffefffe3e8) at notification-thread-events.c:3112
  #6  0x00000000004687bd in thread_notification (data=0x601460) at notification-thread.c:710
  #7  0x0000000000486703 in launch_thread (data=0x601550) at thread.c:66
  #8  0x00007ffff7c47609 in start_thread (arg=<optimized out>) at pthread_create.c:477
  #9  0x00007ffff7b6e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

This happens because the LTTNG_DOMAIN_PYTHON domain is not handled by
the switch-case.

Fix
===
Add LTTNG_DOMAIN_PYTHON (all other agent domains) as a fallthrough
LTTNG_DOMAIN_UST.

Note
====
Add a basic test case for python agent.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9971cdad8bbc6adca8f6ba49964483c42a25be7d

3 years agoTests: move `list_triggers_matches_ok` to utils.sh
Francis Deslauriers [Wed, 12 May 2021 15:09:37 +0000 (11:09 -0400)] 
Tests: move `list_triggers_matches_ok` to utils.sh

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4cd3816fa7cbc1032582b2a99f67a3b14222f972

3 years agoTests: Move python test app to `tests/utils/testapp` directory
Francis Deslauriers [Thu, 13 May 2021 01:21:28 +0000 (21:21 -0400)] 
Tests: Move python test app to `tests/utils/testapp` directory

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9bc55c0fc0b8de42157d64884c7e1ee08b800525

3 years agoFix: validate whether event notifiers are supported by UST application
Mathieu Desnoyers [Wed, 12 May 2021 20:05:29 +0000 (16:05 -0400)] 
Fix: validate whether event notifiers are supported by UST application

Considering that lttng-sessiond interacts with older (2.12) applications
as well as 2.13+, it needs not to send event notifiers related commands
to an older UST, because the unknown command will cause the protocol to
become out of sync on the communication socket, because the older
lttng-ust does not know how many bytes must be read when receiving the
unknown command. So even though it can return that the command is
unknown, the communication socket becomes out of sync.

Depends-on: lttng-ust: If048c739dd37147ffb2a54715c2101177d2df4f7
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If9cbc7a7cd6cb957134bf3a2e284ab99ef20e93b

3 years agoFix: ust: keep using lttng-ust-sock-8 and lttng-ust-wait-8 filenames
Mathieu Desnoyers [Wed, 12 May 2021 18:09:00 +0000 (14:09 -0400)] 
Fix: ust: keep using lttng-ust-sock-8 and lttng-ust-wait-8 filenames

Replicate a change from a lttng-ust header for which there is an
internal copy within lttng-tools for building without lttng-ust.

lttng-ust commit 6a359b8a4006 ("Bump LTTNG_UST_ABI version from 8.1 to
9.0") attempted to ensure that a session daemon linked against an old
lttng-ust-ctl (2.12) would not attempt to interact with newer
applications.

This was done by increasing the major ABI version number, but
introducing LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE (set to 8) as
a mean to allow session daemon to accept both major versions 8 and 9.

Unfortunately, changing LTTNG_UST_ABI_MAJOR_VERSION means the filenames
used for communication changed as well, meaning that applications linked
against older lttng-ust 2.12 cannot interact with lttng sessiond linked
against lttng-ust-ctl 2.13, which is unintended.

Therefore, go back to using the previous filenames: lttng-ust-sock-8,
and lttng-ust-wait-8 for communication.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I121c6e5aa13637f13b996dd9e31e06d060b52ca6

3 years agoFix: Handle SIGBUS in sessiond and consumerd
Mathieu Desnoyers [Wed, 7 Oct 2020 20:42:05 +0000 (16:42 -0400)] 
Fix: Handle SIGBUS in sessiond and consumerd

There is an issue with the security model of lib ring buffer (lttng-ust)
vs SIGBUS handling by consumer daemon. We do not handle SIGBUS in the
consumer daemon. An application using ftruncate on a ring buffer shm
could cause the consumer to be killed with SIGBUS.

Wire up SIGBUS handling in the session daemon as well given that it also
uses liblttng-ust-ctl.

This depends on "liblttng-ust-ctl: Implement SIGBUS handling" in
lttng-ust, which extends the API of liblttng-ust-ctl, which requires
the user application to define the TLS sigbus state with
DEFINE_LTTNG_UST_SIGBUS_STATE(). It therefore needs to be introduced in
locked-step between lttng-ust and lttng-tools.

Considering that this change in liblttng-ust-ctl modifies the ABI, it is
done with a major soname version bump of the library, so it is allowed
to break the API.

Depends-on: lttng-ust: I7ade988e3e68a87930fbcee3e14e59c3fb66e755

Fixes: #1284
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I76a91616bd35b21c5e891c8306c73ed5e8725ebb

3 years agoClean-up: rename double 'lttng' prefixed functions
Jérémie Galarneau [Thu, 13 May 2021 19:45:43 +0000 (15:45 -0400)] 
Clean-up: rename double 'lttng' prefixed functions

Rename `lttng_lttng_ust_ctl_flush_buffer` to `lttng_ust_flush_buffer`
since the double prefix is odd, but needed to work-around a clash
with symbols introduced in liblttng-ust-ctl as part of 2.13.

Two functions stubs are not used are removed:
  - lttng_lttng_ust_ctl_get_mmap_read_offset,
  - lttng_lttng_ust_ctl_get_mmap_base.

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

3 years agolttng-{enable-event(1),event-rule(7)}: `--filter` is not always avail.
Philippe Proulx [Thu, 13 May 2021 02:59:59 +0000 (22:59 -0400)] 
lttng-{enable-event(1),event-rule(7)}: `--filter` is not always avail.

The `--filter` option of both lttng-enable-event(1) and a common event
rule specification is not available with the Linux kprobe, kretprobe,
and user space probe instrumentation point types.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2cea488359bbe8ac8494d785fe3282419ee66d46

3 years agolttng(1)/lttng-create(1): document `--relayd-path`
Philippe Proulx [Thu, 13 May 2021 02:52:25 +0000 (22:52 -0400)] 
lttng(1)/lttng-create(1): document `--relayd-path`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I83d65e13834593c97e296db2505dc97f6a8e4568

3 years agodoc/man: document `LTTNG_SESSIOND_PATH` env. var. like `--sessiond-path`
Philippe Proulx [Thu, 13 May 2021 02:51:41 +0000 (22:51 -0400)] 
doc/man: document `LTTNG_SESSIOND_PATH` env. var. like `--sessiond-path`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie6ff3f2f1003d506e5d4a351af0f811b4ca8b556

3 years agolttng-save(1): document `--all` option in "SYNOPSIS" and "DESCRIPTION"
Philippe Proulx [Thu, 13 May 2021 02:24:09 +0000 (22:24 -0400)] 
lttng-save(1): document `--all` option in "SYNOPSIS" and "DESCRIPTION"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I895e2c8277cb8c1b7644f6d8607cd77230706515

3 years agoFix: snapshot path have domain subdir duplicate "ust/ust" or "kernel/kernel"
Jonathan Rajotte [Tue, 1 Dec 2020 17:19:53 +0000 (12:19 -0500)] 
Fix: snapshot path have domain subdir duplicate "ust/ust" or "kernel/kernel"

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

lttng-ivc observed unexpected path generated for streamed snapshot:

  joraj-alpa/
   test-20190319-120000-20210113-110101/
    snapshot-1-20210113-110102-0/
*     ust/
*      ust/
        pid/
         app-ust-2362198-20210113-110101/
           channel_0
           channel_1
           metadata
           channel_2
           channel_3

"ust" the domain subdir is present two-time instead off only one time.

The same problem is seen for kernel snapshots.

Cause
=====

Based on dissection the problem was introduced by commit
5da88b0f58d7f838068037ea449ddfb25d3e85ad [1]

For snapshots, the consumer output object of the snapshot output and
information is fetched from the *original* consumer output.
(code block around src/bin/lttng-sessiond/cmd.c:4748)

The snapshot consumer output does not contains the necessary information
to populate domain_subdir on copy (domain_subdir is '\0').

This would lead to a len evaluation of 1 for the consumer_path_offset in
setup_channel_trace_path:70. This would end up not "skipping" the "ust"
and "kernel" part of the path.

Solution
========

Part of the solution is to copy the domain_subdir from the original
session consumer output to the snapshot output.

Still, the problem was still present since that now that the
domain_subdir was not "\0", the value was suffixed to the passed
session_path. In the snapshot code path, "ust/" and "kernel/" were
already present in the session_path passed to setup_channel_trace_path.

A quick modification at the caller level in the snapshot code path fixes
the issues once and for all.

Tests
=======

The test suit is augmented for certain key tests to validate the
complete path of a trace.

Path validation is based on crude bash pattern matching.

Known drawbacks
=========
None

References
==========
[1] https://github.com/lttng/lttng-tools/commit/5da88b0f58d7f838068037ea449ddfb25d3e85ad

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7cd2d5471ee3a942fa511e2f4cab09e3aa499e4

3 years agoFix: error: remove trailing period from error descriptions
Jérémie Galarneau [Tue, 11 May 2021 18:37:02 +0000 (14:37 -0400)] 
Fix: error: remove trailing period from error descriptions

Trailing periods in some error descriptions cause the client to print
two dots at the end of some error messages:

Error: Failed to register trigger: Tracing the kernel requires a root
lttng-sessiond daemon, as well as "tracing" group membership or root
user ID for the lttng client..

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

3 years agoMake the subitems array a part of action_work_item
Jérémie Galarneau [Mon, 10 May 2021 19:02:51 +0000 (15:02 -0400)] 
Make the subitems array a part of action_work_item

Make the subitems array a part of action_work_item instead of allocating
it dynamically when a trigger is enqueued for a given action executor.

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

3 years agoTest: fix: firing policy name has changed
Jérémie Galarneau [Tue, 11 May 2021 19:52:50 +0000 (15:52 -0400)] 
Test: fix: firing policy name has changed

The firing policy name from "after every" to "every" in 4edabba83. The
tests are adapted to reflect this change.

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

3 years agolttng-add-trigger(1): add usage examples
Philippe Proulx [Thu, 6 May 2021 20:50:28 +0000 (16:50 -0400)] 
lttng-add-trigger(1): add usage examples

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iac386141968106e648da67498696ecba9524491e

3 years agolttng-add-context(1): add usage examples
Philippe Proulx [Thu, 6 May 2021 20:50:17 +0000 (16:50 -0400)] 
lttng-add-context(1): add usage examples

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8ce928325a659676210ea9d2647ce7223f9527aa

3 years agolist_triggers.c: replace "after every" -> "every"
Philippe Proulx [Thu, 6 May 2021 20:19:39 +0000 (16:19 -0400)] 
list_triggers.c: replace "after every" -> "every"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If6121fda5bb6d7cf5c941c1ca134191c72518422

3 years agoFix: add_trigger.c: `goto error` with a wrong UID for `--owner-uid`
Philippe Proulx [Thu, 6 May 2021 20:10:01 +0000 (16:10 -0400)] 
Fix: add_trigger.c: `goto error` with a wrong UID for `--owner-uid`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8650af1f43e8ed8bad58a928cfcdf78d382212f1

3 years agolttng-add-context(1): use a description list to explain `--channel`
Philippe Proulx [Thu, 6 May 2021 19:15:29 +0000 (15:15 -0400)] 
lttng-add-context(1): use a description list to explain `--channel`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie2d701820bf1e086205254c0712fe088c3295b2d

3 years agodoc/man/manpage.xsl: indent the body of formal (example) blocks
Philippe Proulx [Thu, 6 May 2021 19:09:58 +0000 (15:09 -0400)] 
doc/man/manpage.xsl: indent the body of formal (example) blocks

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I184b1bc54728cf0d770bc44f9f0923b9f8724396

3 years agodoc/man: lttng(1) command pages: always include `common-footer.txt`
Philippe Proulx [Thu, 6 May 2021 18:45:26 +0000 (14:45 -0400)] 
doc/man: lttng(1) command pages: always include `common-footer.txt`

The end of an lttng(1) command manual page source now looks like this:

    include::common-lttng-cmd-help-options.txt[]

    include::common-lttng-cmd-after-options.txt[]

    include::common-footer.txt[]

`common-lttng-cmd-after-options.txt` contains the "EXIT STATUS",
"ENVIRONMENT", and "FILES" sections.

`common-footer.txt` begins with the "RESOURCES" section.

This will make it possible to insert an "EXAMPLES" section between
`common-lttng-cmd-after-options.txt` and `common-footer.txt`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1eee42d7386f4671d9825e9d3e131e54f868ee39

3 years agodoc/man: follow man-pages(7) for section names/order and for "SEE ALSO"
Philippe Proulx [Thu, 6 May 2021 18:14:08 +0000 (14:14 -0400)] 
doc/man: follow man-pages(7) for section names/order and for "SEE ALSO"

Changes, following the "Sections within a manual page" section of
man-pages(7):

* Rename the "ENVIRONMENT VARIABLES" section to "ENVIRONMENT".

* Rename the "COPYRIGHTS" section to "COPYRIGHT".

* Move the "EXIT STATUS" section immediately after the "OPTIONS"
  section.

* Remove the "BUGS" section.

  Such a section indicates known bugs (why would you ever have such
  a section anyway?).

  The "RESOURCES" section now contains the URL of our bug tracker.

* Sort the manual pages by section, and then by name in the "SEE ALSO"
  section.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d91073ec876efd98dcc723ddf40272c814663dd

3 years agoFix: action-executor: leak of `work_item::subitems` field
Francis Deslauriers [Fri, 7 May 2021 21:44:52 +0000 (17:44 -0400)] 
Fix: action-executor: leak of `work_item::subitems` field

This leak can be reproduced by adding a trigger and looking at the used
memory of the lttng-sessiond process.

Valgrind reports the following leak:
  ==2472== 7,087,968 bytes in 147,666 blocks are definitely lost in loss record 24 of 24
  ==2472==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==2472==    by 0x191C37: zmalloc (macros.h:45)
  ==2472==    by 0x195234: action_executor_enqueue_trigger (action-executor.c:913)
  ==2472==    by 0x171AD7: dispatch_one_event_notifier_notification (notification-thread-events.c:4626)
  ==2472==    by 0x171D1E: handle_one_event_notifier_notification (notification-thread-events.c:4715)
  ==2472==    by 0x171DA4: handle_notification_thread_event_notification (notification-thread-events.c:4730)
  ==2472==    by 0x164EA6: handle_event_notification_pipe (notification-thread.c:591)
  ==2472==    by 0x1656C3: thread_notification (notification-thread.c:727)
  ==2472==    by 0x17BD16: launch_thread (thread.c:66)
  ==2472==    by 0x5F086DA: start_thread (pthread_create.c:463)
  ==2472==    by 0x624188E: clone (clone.S:95)

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d98e3ae18c5b2d7f400407842a7de17716f680c

3 years agolttng: change a few instances of trigger "id" to "name"
Simon Marchi [Tue, 27 Apr 2021 22:00:28 +0000 (18:00 -0400)] 
lttng: change a few instances of trigger "id" to "name"

The term trigger "id" has been changed to trigger "name", these are
leftovers. Fix them.

Change-Id: Ic05925af1cd25917de75a0a4d061324604e5a599
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoChange "event rule hit" to "event-rule matches" in user interface strings
Simon Marchi [Tue, 27 Apr 2021 18:51:08 +0000 (14:51 -0400)] 
Change "event rule hit" to "event-rule matches" in user interface strings

The condition name was changed from "event rule hit" to "event rule
matches", but there are some leftover user-visible strings with the old
name. Fix them.

Change-Id: I619c9265d68ca6bf4a3ac11ef38cabc715b01110
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: relayd: live: data is missing between viewer attach and retry
Jonathan Rajotte [Thu, 6 May 2021 15:14:52 +0000 (11:14 -0400)] 
Fix: relayd: live: data is missing between viewer attach and retry

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

Data produced between the time a live viewer attach and a viewer
subsequent "polling" is missing from the point of view of the viewer.

Using the following reproducer:

  # A lttng-sessiond is already running
  lttng-relayd -b -vvv > relayd.log 2>&1
  lttng create live --live
  lttng enable-event -u "hello_world:*"
  lttng start

  date
  # Set the "polling" interval at ~30 seconds
  babeltrace2 --retry-duration=30000000 -i lttng-live net://localhost/host/$HOSTNAME/live &
  pid=$!

  # Make sure we are in the retry phase of bt2
  date
  sleep 2

  # Produce events
  # Note here that hello perform a sleep of 1 seconds before generating
  # 10 events to make sure lttng-ust had time to register. A total of
  # 100 events is generated.
  date
  for i in `seq 1 10`; do
   ./hello
  done

  # Here we expect to see 100 events outputted at some point (~18
  # seconds (30 - 2 - 10) from that time).
  # No events are received by babeltrace2.
  date
  sleep 40
  date

  # We retry the same exercise a second time.
  echo "Moving to phase 2"
  date
  for i in `seq 1 10`; do
   ./hello
  done

  # Here data is received correctly.
  date
  sleep 40
  date

  kill $pid
  wait

  lttng destroy live
  pkill lttng-relayd

Cause
=====

At the moment the viewer attach is done, no streams exist. On the
following viewer_get_new_streams (~30 seconds later), streams now exist
since they were allocated lazily following the first application
registration, but LTTNG_VIEWER_SEEK_LAST is used. This essentially
"discards" any events in the stream that happened between the attach
time and the viewer_get_new_stream execution.

Note that the same problem would happen if a new UID (in per-uid mode)
would happen to begin tracing in between viewer retry.

Solution
========

Always use `LTTNG_VIEWER_SEEK_BEGINNING` during
`viewer_get_new_streams`.

Known drawbacks
=========

This does not fix the per-pid problem where an app run and die in between
the viewer retries.

References
==========

https://lists.lttng.org/pipermail/lttng-dev/2021-May/029953.html

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I92fbe6511fb93e31d20922b4eef5c9a221e07716

3 years agoBuild fix: filter-grammar-test: incorrect inclusion flag
Jérémie Galarneau [Thu, 6 May 2021 22:43:44 +0000 (18:43 -0400)] 
Build fix: filter-grammar-test: incorrect inclusion flag

Including src/common causes LTTng files that clash with system headers
to be included before the system headers and breaks the build on
multiple platforms and architectures.

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

3 years agoTests: fix: test_tp_fail: bail out on non-existing relay daemon
Jérémie Galarneau [Thu, 6 May 2021 19:48:02 +0000 (15:48 -0400)] 
Tests: fix: test_tp_fail: bail out on non-existing relay daemon

Fatal thread errors simulated by the tp_fail test cause the relay
daemon to shutdown. This is unexepected by stop_lttng_relayd_notap
which bails out, causing the test to fail.

We bail-out when the daemon is already dead to catch crashes
during the test suite since a0f8e310.

Use the clean-up variant so that we don't fail the tests for this
expected outcome.

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

3 years agobuild system: support rotation example
Jonathan Rajotte [Wed, 28 Apr 2021 00:13:13 +0000 (20:13 -0400)] 
build system: support rotation example

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Icf5f88dcc725967b7fda66db6e047cdf18a89f01

3 years agoAdd trigger on event rule matches application example
Jonathan Rajotte [Fri, 14 Feb 2020 23:26:39 +0000 (18:26 -0500)] 
Add trigger on event rule matches application example

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ice78e15aa1f4380925a272def8bcc7ca331c0aa0

3 years agoUpdate the remaining manual pages for LTTng-tools 2.13
Philippe Proulx [Thu, 29 Apr 2021 21:00:07 +0000 (17:00 -0400)] 
Update the remaining manual pages for LTTng-tools 2.13

This patch updates the remaining manual pages for LTTng-tools 2.13.

This patch:

* Improves the consistency of some command descriptions in
  `configure.ac`.

* Adds `common-daemon-cfg.txt` which is a section explaining how to
  configure a daemon (session or relay).

  lttng-sessiond(8) and lttng-relayd(8) include this file.

* Adds `lttng-concepts.7.txt` which is an adapted copy of the
  "Core concepts" section of the online LTTng Documentation.

  This centralizes all the LTTng theory into a single manual page
  instead of having this information split into multiple lttng(1)
  command manual pages.

  Many manual pages now refer to lttng-concepts(7), making it possible
  to cut a lot of text in those.

* Updates existing manual pages to:

  * Have a style and voice which is more consistent with the LTTng
    Documentation (website) for 2.13.

  * Fix various terminology ambiguities.

  * Use more textual variables and lists to explain more complex logic
    and processes.

  * Always use the same pattern to specify the behaviour of an lttng(1)
    command depending on the `SESSION` argument or the `--session`
    option.

  * For the commands which can perform more than one task, list their
    available tasks at the beginning of the "DESCRIPTION" section.

  * For some lttng(1) commands which can operate on all tracing sessions
    (for example, lttng-clear(1) and lttng-destroy(1)), always indicate
    that they target all your Unix user's tracing sessions or, if your
    Unix user is `root`, the tracing sessions of all the Unix users
    within the root session daemon.

  * Clean the "SEE ALSO" sections.

  * Always have "LTTng" in the "NAME" section of a manual page.

  More specifically:

  lttng-create(1):
      * Clarify the tracing session modes.

      * Clarify how the command adds (or not) a snapshot output for a
        snapshot mode tracing session.

      * Specify that `--output=DIR` is equivalent to
        `--set-url=file://DIR`.

  lttng-enable-channel(1):
      Include the `--discard`, `--buffers-uid`, and `--buffers-global`
      options in the "SYNOPSIS" section even if they are the current
      defaults.

  lttng-list(1):
      Explain what this command does exactly using a tree of options
      and arguments.

  lttng-load(1):
      Clarify how LTTng finds tracing session configurations.

  lttng-relayd(8):
      * Document the missing `--group` option.

      * Rework the text in general.

      * Add a daemon configuration section with an INI file example.

      * Add more cross-references between options and equivalent
        environment variables.

  lttng-rotate(1):
      Specify that the `rotate-session` trigger action can also rotate
      a tracing session.

  lttng-save(1):
      Clarify the output path.

  lttng-sessiond(8):
      Add more cross-references between options and equivalent
      environment variables.

  lttng-shapshot(1):
      * Clarify everything related to the snapshot output of a tracing
        session, including when and how the lttng-create(1) command adds
        an initial snapshot output.

      * Specify that the `snapshot-session` trigger action can also take
        a snapshot of a tracing session.

  lttng-track(1):
  lttng-untrack(1):
      * Simply refer to allowing processes to record events and to
        process attribute inclusion sets instead of using the vague
        "tracker" terminology.

      * Restate that those commands control an implicit condition of
        a recording event rule, as per lttng-concepts(7).

      * Improve the documentation of each inclusion set selection
        option.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iac7498ee979fe077f0927a9b8335f6c07f203989

3 years agodoc/man/manpage.xsl: do not indent the title of an admonition block
Philippe Proulx [Mon, 3 May 2021 19:46:51 +0000 (15:46 -0400)] 
doc/man/manpage.xsl: do not indent the title of an admonition block

See the new comment in `manpage.xsl` for more details.

I copied and modified some upstream DocBook XSL (as found in
`xsl/manpages/block.xsl`).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I765ce37957907edb4088a4212c1b12af8b485e60

3 years agoFix: lttng: add-trigger: invalid access past end of exclusions buffer
Jérémie Galarneau [Thu, 29 Apr 2021 23:01:44 +0000 (19:01 -0400)] 
Fix: lttng: add-trigger: invalid access past end of exclusions buffer

The following command causes the `lttng` client to SEGFAULT on 32-bit
machines:
  lttng add-trigger \
    --condition event-rule-matches --domain=user \
                '--name=jean-*' \
                --exclude-name jean-chretien -x jean-charest \
    --action notify

Running with valgrind results in the following report:

Invalid read of size 8
   at 0x12EEA4: validate_exclusion_list (enable_events.c:354)
   by 0x149018: parse_event_rule (add_trigger.c:964)
   by 0x148356: handle_condition_event (add_trigger.c:1222)
   by 0x147EC3: parse_condition (add_trigger.c:1300)
   by 0x147702: cmd_add_trigger (add_trigger.c:2107)
   by 0x154067: handle_command (lttng.c:237)
   by 0x1534D1: parse_args (lttng.c:426)
   by 0x152C54: main (lttng.c:475)

validate_exclusion_list expects a NULL terminated array of exclusions
while handle_condition_event prepares an array of exclusions using
the dynamic pointer array facilities (which doesn't need to
null-terminate arrays).

The code that deals with exclusions "lists" mixes various conventions
(null-terminated vs explicit size) in different places leading to this
kind of errors.

All the code that references exclusion lists, along with the string
utils, are adapted to make use of the common dynamic pointer array
facilities.

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

3 years agoFix: tests: extra arguments are not passed to the remove trigger command
Jonathan Rajotte [Wed, 5 May 2021 17:34:00 +0000 (13:34 -0400)] 
Fix: tests: extra arguments are not passed to the remove trigger command

Observed issue
==============
CI root jobs fails on the remove trigger operation for the user_trigger
trigger during the test_ust_notifier_discarded_count_multi_uid test.

Cause
=====
The `--owner uid` option and its argument are not passed during the
command execution.

Solution
========
Pass all extra parameters for the command execution.

Known drawbacks
=========

None.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic7b5d46b6793cda16a474c5459f9bf533812fe61

3 years agoFix: lttng-ctl: erroneous check if user is part of the tracing group
Jérémie Galarneau [Mon, 3 May 2021 16:50:25 +0000 (12:50 -0400)] 
Fix: lttng-ctl: erroneous check if user is part of the tracing group

in_tgroup is set to `-1` whenever the current user is not part of the
tracing group _or_ if an error occurred while looking up if the user
is part of the tracing group. In other words, the value '0' is unused.

in_tgroup must be explicitly checked against '1' and can't be assumed
to behave as a boolean value.

This is _not_ a security issue: if the user is not part of the tracing
group, she will fail to open the root session damon's socket because
of the kernel-side permission checking. However, the behaviour of the
lttng client (and error reporting) will be confusing.

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

3 years agoBuild fix: kernel-consumerd: merge conflict left in file
Jérémie Galarneau [Mon, 3 May 2021 15:52:51 +0000 (11:52 -0400)] 
Build fix: kernel-consumerd: merge conflict left in file

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

3 years agoClean-up: consumerd: use a specific status code for get_next_subbuffer
Jérémie Galarneau [Fri, 30 Apr 2021 16:12:44 +0000 (12:12 -0400)] 
Clean-up: consumerd: use a specific status code for get_next_subbuffer

The implementation of "get next subbuffer" of the user space and kernel
tracers return different error codes (-ENODATA and -EAGAIN) which are
are confusing to handle in the generic code.

Since the difference between -ENODATA and -EAGAIN makes no material
difference in the current consumerd implementation, those conditions
are abstracted by a common GET_NEXT_SUBBEFFER_STATUS_NO_DATA.

Otherwise, the callers handle 'OK' and the generic 'ERROR' condition
which makes the transport of more specific "errno" values useless for
the moment.

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

3 years agoFix: kernel consumer: get next subbuffer EAGAIN handling
Mathieu Desnoyers [Fri, 30 Apr 2021 16:02:47 +0000 (12:02 -0400)] 
Fix: kernel consumer: get next subbuffer EAGAIN handling

The caller of get next subbuffer (data and metadata) callbacks only
expects -ENODATA when there is no data to read. However, the kernel
tracer distinguishes between no data for a finalized stream (-ENODATA)
and no data for a non-finalized stream (-EAGAIN).

Given that the consumer daemon uses the POLLHUP returned by epoll to
detect stream end of life, it does not care about the distinction
between -EAGAIN and -ENODATA when streaming.

However, taking a snapshot of a metadata stream uses the distinction
between nodata and again. Change this so it considers a return value of
0 from lttng_consumer_read_subbuffer to mean there is no more data to
read, so we can combine -EAGAIN and -ENODATA within get next subbuffer
callbacks and return -ENODATA for both.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I30786985c2389570dd342e55d4faf7c552532f8b

3 years agoFix: kernel consumer: signal metadata ready condition variable
Mathieu Desnoyers [Fri, 30 Apr 2021 14:44:44 +0000 (10:44 -0400)] 
Fix: kernel consumer: signal metadata ready condition variable

The behaviour of the kernel consumer does not match that of the user
space consumer. When a live metadata stream goes back to "sleep", it
must broadcast on the metadata_rdv to wake-up any thread that is
performing a metadata sync.

This mismatch causes a hang in the kernel consumer during the kernel
clear tests.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ief15fc2b7c92582ea36bf64d185720e48d2c94d5

3 years agoFix: consumerd: unbalanced subbuffer 'get' when checking operation availability
Jérémie Galarneau [Thu, 29 Apr 2021 20:17:45 +0000 (16:17 -0400)] 
Fix: consumerd: unbalanced subbuffer 'get' when checking operation availability

A WARN_ON in lttng-modules is hit in the get_subbuf ioctl, which
pointed to an unbalanced get/put pair when accessing the subbuffers
of a channel.

517716.168856] ------------[ cut here ]------------
[517716.171559] WARNING: CPU: 1 PID: 19313 at /home/efficios/git/lttng-modules/src/lib/ringbuffer/ring_buffer_frontend.c:1263 lib_ring_buffer_get_subbuf+0x24f/0x260 [lttng_lib_ring_buffer]
[517716.180096] Modules linked in: lttng_test(O) lttng_probe_x86_exceptions(O) lttng_probe_x86_irq_vectors(O) lttng_probe_writeback(O) lttng_probe_workqueue(O) lttng_probe_vmscan(O) lttng_probe_udp(O) lttng_probe_timer(O) lttng_probe_sunrpc(O) lttng_probe_statedump(O) lttng_probe_sock(O) lttng_probe_skb(O) lttng_probe_signal(O) lttng_probe_scsi(O) lttng_probe_sched(O) lttng_probe_regulator(O) lttng_probe_regmap(O) lttng_probe_rcu(O) lttng_probe_random(O) lttng_probe_printk(O) lttng_probe_power(O) lttng_probe_net(O) lttng_probe_napi(O) lttng_probe_module(O) lttng_probe_kmem(O) lttng_probe_jbd2(O) lttng_probe_irq(O) lttng_probe_i2c(O) lttng_probe_gpio(O) lttng_probe_ext4(O) lttng_probe_compaction(O) lttng_probe_btrfs(O) lttng_probe_block(O) lttng_counter_client_percpu_32_modular(O) lttng_counter_client_percpu_64_modular(O) lttng_counter(O) lttng_ring_buffer_event_notifier_client(O) lttng_ring_buffer_metadata_mmap_client(O) lttng_ring_buffer_client_mmap_overwrite(O)
[517716.180815]  lttng_ring_buffer_client_mmap_discard(O) lttng_ring_buffer_metadata_client(O) lttng_ring_buffer_client_overwrite(O) lttng_ring_buffer_client_discard(O) lttng_tracer(O) lttng_statedump(O) lttng_wrapper(O) lttng_uprobes(O) lttng_clock(O) lttng_kprobes(O) lttng_lib_ring_buffer(O) lttng_kretprobes(O) [last unloaded: lttng_wrapper]
[517716.213228] CPU: 1 PID: 19313 Comm: lttng-consumerd Tainted: G           O      5.11.2 #80
[517716.215573] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
[517716.220341] RIP: 0010:lib_ring_buffer_get_subbuf+0x24f/0x260 [lttng_lib_ring_buffer]
[517716.222579] Code: 50 f0 ff 00 0f 0b 49 03 5f 28 44 8b 85 80 00 00 00 49 8b 77 30 45 85 c0 48 89 d9 0f 85 4f ff ff ff e9 25 ff ff ff f0 ff 45 00 <0f> 0b b8 f0 ff ff ff e9 a6 fe ff ff 0f 1f 44 00 00 0f 1f 44 00 00
[517716.227610] RSP: 0018:ffffbafd09023e88 EFLAGS: 00010202
[517716.229147] RAX: 0000000000000000 RBX: ffff9906ed069a00 RCX: ffff9905c4e4a400
[517716.231186] RDX: ffffdafcffc4ec90 RSI: 0000000000200000 RDI: ffffdafcffc4e9f0
[517716.233265] RBP: ffff9905c4e4a400 R08: 0000000000300000 R09: 0000000000200000
[517716.235284] R10: 0000000000200000 R11: 0000000000000000 R12: 0000000000000000
[517716.237333] R13: 0000000000000000 R14: 000000000000005e R15: 0000000000000000
[517716.239360] FS:  00007ff327fff700(0000) GS:ffff9905a7a40000(0000) knlGS:0000000000000000
[517716.241634] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[517716.243262] CR2: 000055b91cf07730 CR3: 000000076f45e003 CR4: 00000000001706e0
[517716.245316] Call Trace:
[517716.246281]  lib_ring_buffer_ioctl+0x181/0x300 [lttng_lib_ring_buffer]
[517716.248301]  lttng_stream_ring_buffer_ioctl+0x1a3/0x200 [lttng_tracer]
[517716.252621]  __x64_sys_ioctl+0x8e/0xd0
[517716.253931]  do_syscall_64+0x33/0x80
[517716.255016]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[517716.256448] RIP: 0033:0x7ff3372f46d7
[517716.257586] Code: b3 66 90 48 8b 05 b1 47 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 47 2d 00 f7 d8 64 89 01 48
[517716.262472] RSP: 002b:00007ff327ffe2c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[517716.264634] RAX: ffffffffffffffda RBX: 00007ff310002740 RCX: 00007ff3372f46d7
[517716.266674] RDX: 0000000000000000 RSI: 000000000000f605 RDI: 000000000000005e
[517716.268713] RBP: 00007ff327ffe310 R08: 00007ff310002870 R09: a002000000000000
[517716.270732] R10: 000055992b0a6530 R11: 0000000000000246 R12: 000055992c47da70
[517716.272768] R13: 00007ff318005e80 R14: 00007ff310002740 R15: 000055992b0a6528
[517716.274800] irq event stamp: 4526705
[517716.275897] hardirqs last  enabled at (4526713): [<ffffffff9016a474>] console_unlock+0x4b4/0x5b0
[517716.278320] hardirqs last disabled at (4526722): [<ffffffff9016a3d0>] console_unlock+0x410/0x5b0
[517716.280759] softirqs last  enabled at (4526658): [<ffffffff9120030f>] __do_softirq+0x30f/0x432
[517716.285125] softirqs last disabled at (4526653): [<ffffffff91001052>] asm_call_irq_on_stack+0x12/0x20
[517716.287648] ---[ end trace 506e55b312b731bf ]---

The check for the availability of the 'get_next_check_metadata'
operation attempts to use the operation at the creation of the metadata
stream. Most of the time this occurs before any metadata could be
generated.

However, the check will sometimes (very rarely) occur after the
generation of some metadata causing the 'get' to succeed and,
consequently, a subbuffer to be acquired. In those cases, the subbuffer
must be released immediately.

Fixes #1313

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

3 years agosessiond: remove commented-out logging
Jérémie Galarneau [Wed, 28 Apr 2021 21:50:41 +0000 (17:50 -0400)] 
sessiond: remove commented-out logging

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

3 years agosessiond: Remove [.*-thread] logging prefix
Jérémie Galarneau [Wed, 28 Apr 2021 21:44:52 +0000 (17:44 -0400)] 
sessiond: Remove [.*-thread] logging prefix

The logger now logs the thread name making this prefix useless.

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

3 years agorun-as: reduce verbosity of fd sending error paths
Francis Deslauriers [Mon, 26 Apr 2021 22:18:11 +0000 (18:18 -0400)] 
run-as: reduce verbosity of fd sending error paths

Issue
=====

A testcase in `tests/regression/tools/save-load/test_save` tests that
saving a session on an already existing configuration file fails.

The test case fails as expected but it is a bit noisy in terms of error
reporting:
  ok 9 - Enable channel chan-save for session save-42
  ok 10 - Enable ust event tp:tptest for session save-42
  Error: Attempt to send invalid file descriptor to master (fd = -1)
  PERROR - 09:57:10.893683118 [Client management]: Could not create configuration file: File exists (in save_session() at save.c:2706)
  PERROR - 09:57:10.893714862 [Main]: Failed to close result file descriptor: Bad file descriptor (in send_fds_to_master() at runas.c:824)
  ok 11 - Session failed to be saved. Expected!

We see that 3 error statements are printed by the sessiond but only the
second is really relevant.

Fix
===

This commit:
- changes the first `ERR()` statement to a `DBG()` statement, and
- only call `close()` on seemingly valid FDs.

Notes
=====

This commit also removes the mention of "master" in the first `DBG()`
statement as this function is used by both the master and the runas
process.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie77d44233a770610f8a3f4412b84c0fd70c0812e

3 years agoSet thread name of run-as worker process
Francis Deslauriers [Mon, 26 Apr 2021 22:09:54 +0000 (18:09 -0400)] 
Set thread name of run-as worker process

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifd89ad19a17d96975f712bcd298588f2fc28d04f

3 years agoUse new ioctl macros with fixed ioctl direction
Francis Deslauriers [Tue, 27 Apr 2021 18:26:09 +0000 (14:26 -0400)] 
Use new ioctl macros with fixed ioctl direction

Update the ioctl commands to follow the changes in this commit:
  commit 8c71721f7a868b575b05e24bc3a3dcc967e6d5d6
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Tue Apr 20 11:05:19 2021 -0400

      Fix: LTTng-modules ABI ioctl wrong direction

This commit uses the new command first, and if -ENOSYS is returned by
the LTTng kernel tracer it falls back to the old command.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2604ea5902fec3bf574c7a249cb65784685a0ae8

3 years agoSync lttng-modules ABI in internal kernel-ioctl.h
Francis Deslauriers [Tue, 27 Apr 2021 16:13:57 +0000 (12:13 -0400)] 
Sync lttng-modules ABI in internal kernel-ioctl.h

This commit bumps the modules minor version number in `kernel-ioctl.h`
and applies the following renames:

define renames:
  `LTTNG_KERNEL_x` -> `LTTNG_KERNEL_ABI_x`
  `RING_BUFFER_x` -> `LTTNG_KERNEL_ABI_RING_BUFFER_x`

struct renames:
  `struct lttng_kernel_x` -> `struct lttng_kernel_abi_x`

No behavior change intended.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0bb0ac6bca56b6740ea2d543a6d1bd618d39b36c

3 years agoFix: data reception is called event when only FDS are expected for reception
Jonathan Rajotte [Tue, 27 Apr 2021 01:09:35 +0000 (21:09 -0400)] 
Fix: data reception is called event when only FDS are expected for reception

In non blocking mode, the FDs reception code can hit EAGAIN. In such
cases, skip the data reception completely when performing the reception.

The same behavior could have been implemented with a noop at the
`lttcomm_recv_unix_sock_non_block` level when the passed `len` is equal
to 0. The handling of it at the notification thread reception level was
chosen to be explicit with regards to the expected behaviour and not
rely on implicit functionality of `lttcomm_recv_unix_sock_non_block`.

While there, augment assertions for code in unix.c

Change-Id: I0fa6df1c9630caa6e877a39372bdfd3d3a01b648
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: FDs are added to payload despite not being received
Jonathan Rajotte [Tue, 27 Apr 2021 01:08:18 +0000 (21:08 -0400)] 
Fix: FDs are added to payload despite not being received

`lttcomm_recv_fds_unix_sock_non_block` can return zero on EAGAIN.

It is important not to add the raw_fds array to the payload in such case
since concretely no FDs have been received.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I551457856c885098bf0de2388936e97456051f93

3 years agoFix: initialize temporary fd array element to -1
Jonathan Rajotte [Tue, 27 Apr 2021 01:07:08 +0000 (21:07 -0400)] 
Fix: initialize temporary fd array element to -1

These are FDs, an initialization value of zero is a valid FD number
hence we must initialize the element to -1.

This allows us to be more strict in `add_fds_to_payload` and assert that
the passed FDs are actual FDs and not only bare zero-initialized
element.

Change-Id: Icc05d98d51906636362a67588d7c42b58cf33ded
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: common: hide shm* util symbols
Jérémie Galarneau [Mon, 26 Apr 2021 23:21:53 +0000 (19:21 -0400)] 
Fix: common: hide shm* util symbols

Internal symbols that are part of libcommon must be marked as "hidden".
Otherwise, the symbols are exported as part of liblttng-ctl.so.

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

3 years agoFix: mark channel as disabled even if the session is inactive
Francis Deslauriers [Thu, 25 Feb 2021 23:19:37 +0000 (18:19 -0500)] 
Fix: mark channel as disabled even if the session is inactive

Observed issue
==============
When the session is stopped, disable-channel commands are no-op.

The following commands reproduce the issue:
  lttng create
  lttng enable-event -u -a
  lttng start
  sleep 4
  lttng stop

  lttng disable-channel -u channel0
  sleep 10
  lttng start
  sleep 4
  lttng stop

  lttng view

Note that the sleep command there are to give the UST application time
to produce events.

Even after disabling the channel, we can see that events are still
traced.

This is due to the fact that the `channel_ust_disable()` function
returns early if the session is inactive and omits to set the channel as
disabled.

Proposed fix
============
Move this following line before the check:
uchan->enabled = 0;

Test
====
Add a test case to exercise this exact scenario.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9660064ac6eb99f2aea8851dc98a94cfc1b810e6

3 years agoFix: condition: buffer-usage: use double instead of fixed point
Francis Deslauriers [Fri, 23 Apr 2021 18:45:31 +0000 (14:45 -0400)] 
Fix: condition: buffer-usage: use double instead of fixed point

Issue observed
==============

When running the test_notification_ust_buffer_usage test on x86
(32 bit), the session daemon and test client both crash. The session
daemon dies while attempting to lock a NULL client list during the
execution of an enqueued action in the action executor.

See the following backtrace:

 #0  0xf7c6c756 in __GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:67
 #1  0x565afe96 in notification_client_list_send_evaluation (client_list=0x0, trigger=0xf0f225e0, evaluation=0xf330c830, source_object_creds=0xf330e5cc, client_report=0x565cf81b <client_handle_transmission_status>, user_data=0xf330c320) at notification-thread-events.c:4372
 #2  0x565cfb41 in action_executor_notify_handler (executor=0xf330c320, work_item=0xf330e5b0, item=0xf330c7b0) at action-executor.c:269
 #3  0x565d1a58 in action_executor_generic_handler (executor=0xf330c320, work_item=0xf330e5b0, item=0xf330c7b0) at action-executor.c:696
 #4  0x565d1b7f in action_work_item_execute (executor=0xf330c320, work_item=0xf330e5b0) at action-executor.c:715
 #5  0x565d212f in action_executor_thread (_data=0xf330c320) at action-executor.c:797
 #6  0x565b9d0e in launch_thread (data=0xf330c390) at thread.c:66
 #7  0xf7c69fd2 in start_thread (arg=<optimized out>) at pthread_create.c:486
 #8  0xf7b7f6d6 in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:108

This crash causes an assertion to fail in the test client; checking for
data pending was not expected to return a negative value. In this case,
the negative return value is justified as it is -LTTNG_ERR_NO_SESSIOND.

Cause
=====

Equipped with coffee, a debugger, and a healthy dose of print
statements, it appeared that the following was taking place:

- Register a trigger (T1): high buffer usage (0.99) -> notify (succeeds)
- Subscribe to high buffer usage (0.99) notifications (succeeds)
- Subscribe to high buffer usage (0.99) notifications
  (fails duplicate, expected)
- Unregister trigger (fails unexpectedly)
- Notification client destroys its channel, causing the condition to be
  unsubscribed-from

- Another test registers a trigger (T2): high buffer usage (0.90) ->
  notify (succeeds)
- Session daemon evaluates a channel sample against T1's condition,
  which evaluates to true and produces an "evaluation" to send to
  clients
- The client list associated to T1's condition is not found (but this
  isn't checked)
- An action executor work item is queued to run T1's actions (notify),
  but without a client list, resulting in the crash when it is executed.

We could confirm that the client list associated to T1's condition was
created and never destroyed making the failure to find it rather
puzzling.

It turns out that the hash of T1's condition did not match the hash of
the client list's condition. This is unexpected as both conditions are
copies of one another.

It turns out that, on x86, the scheme being used to transmit the
condition's buffer usage threshold floating point value is not compiled
to numerically stable code. Serializing such a buffer condition and
creating it from the resulting payload in a loop showed that the
threshold value gradually drifted. This isn't the case on the other
architectures we support.

On x86-64, gcc makes use of SSE instructions to perform the conversion
to an integral value (with double precision). However, on x86, it makes
use of the x87 fpu stack instructions which carry 80-bit of precision
internally, resulting in a loss of precision as the value is
transformed, back and forth, between 80-bit to double precision
representations.

Solution
========

Since conditions are not carried between hosts (only between clients
and the session daemon), a fixed-point conversion scheme is unnecessary.
The 'double' value provided by the client is carried directly which
bypasses the problem completely.

Drawbacks
=========

None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie524e7362626406327f4f56e1dba5c8cf469df31

3 years agoTests: notification: fail on trigger unregistration failure
Jérémie Galarneau [Wed, 28 Apr 2021 17:16:12 +0000 (13:16 -0400)] 
Tests: notification: fail on trigger unregistration failure

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

3 years agoUpdate version to v2.13.0-rc1 v2.13.0-rc1
Jérémie Galarneau [Sat, 24 Apr 2021 01:28:58 +0000 (21:28 -0400)] 
Update version to v2.13.0-rc1

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoSet the 2.13 release codename and description
Jérémie Galarneau [Fri, 23 Apr 2021 15:21:13 +0000 (11:21 -0400)] 
Set the 2.13 release codename and description

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

3 years agoTests: fix: test_notification_notifier_discarded_count missing renames
Jérémie Galarneau [Fri, 23 Apr 2021 22:30:22 +0000 (18:30 -0400)] 
Tests: fix: test_notification_notifier_discarded_count missing renames

Some options of lttng-add-trigger were renamed without adapting the
test since that part is only ran when destructive tests are enabled.

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

3 years agoDocs: lttng-add-trigger and lttng-remove-trigger refer to owner-id
Jérémie Galarneau [Fri, 23 Apr 2021 22:29:29 +0000 (18:29 -0400)] 
Docs: lttng-add-trigger and lttng-remove-trigger refer to owner-id

The proper name of the option is --owner-uid.

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

3 years agoFix: tests: test case using old condition syntax
Francis Deslauriers [Fri, 23 Apr 2021 21:15:28 +0000 (17:15 -0400)] 
Fix: tests: test case using old condition syntax

This commit also changes "on-event" -> "event-rule-matches"

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0b9ff1302ca5a3e8bbdddc8a626890c527dcbd59

3 years agolttng-add-trigger(1): clarify the `--rate-policy` documentation
Philippe Proulx [Fri, 23 Apr 2021 21:12:12 +0000 (17:12 -0400)] 
lttng-add-trigger(1): clarify the `--rate-policy` documentation

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6144521f3186e33c52d7ac20b64cf3e8f7663a55

3 years agoUpdate some manual pages for LTTng-tools 2.13
Philippe Proulx [Wed, 3 Mar 2021 20:18:30 +0000 (15:18 -0500)] 
Update some manual pages for LTTng-tools 2.13

This patch updates some manual pages for LTTng-tools 2.13. A few pages
still remain to be updated, a task which is reserved for a subsequent
patch.

This patch:

* Improves the consistency of the the command descriptions in
  `configure.ac`.

* Adds `common-help-option.txt` which is the description of any
  `--help` option.

* Adds `common-intro.txt` which is a common description introduction for
  the top-level manual pages.

* Adds `lttng-event-rule.7.txt` which describes the common way to
  specify an event rule on the command-line.

  lttng-event-rule(7) has a "Migration from a recording event rule
  specification" section with a table which shows the relationship
  between lttng-enable-event(1) command-line arguments and
  lttng-event-rule(7) options.

  As of this patch, only `lttng-add-trigger.1.txt` references it,
  for the `event-rule-matches` trigger condition.

  `Makefile.am` is also updated to build and include manual pages of
  section 7.

* Updates existing manual pages to:

  * Have a style and voice which is more consistent with the
    LTTng Documentation (website) for 2.13.

  * Fix various terminology ambiguities.

  * Use more textual variables and lists to explain more complex logic
    and processes.

  More specifically:

  lttng-add-context(1):
      Specify that this command adds context fields to be recorded
      to the event records of one or more channels.

      In other words, this is a recording-related command. You don't
      need to use it to access context fields with the filter expression
      of an event rule, for example.

  lttng-add-trigger(1):
      * Update the "NAME" section.

      * Add internal option links where missing.

      * Improve the description.

        Add links to the lttng-remove-trigger(1) and
        lttng-list-triggers(1) manual pages and explain what those
        commands are used for.

        Use "condition specifier" and "action specifier" terms to
        describe those groups of options.

        For condition and action specifiers, use localized synopses.

        For action specifiers, add links to the corresponding LTTng
        command manual pages.

      * Document the `--owner-id` option.

      * Group option descriptions.

      * Use "name" instead of "ID".

      * Refer to the new lttng-event-rule(7) manual page.

      * Remove the "no context field" limitation for `ERSPEC`.

      * Fix verse blocks nested in lists.

  lttng-create(1):
      * Add more documentation about tracing sessions.

      * Specify that the `create` command can spawn a session daemon.

      * Add the "Current tracing session" section to explain this
        concept and where it applies.

      * Clarify the "URL format" section.

  lttng-disable-event(1):
      Explain how this command can only find recording event rules
      to disable by instrumentation point type and event name condition.

  lttng-enable-event(1):
      I more or less completely rewrote this page.

      The document now clearly explains the related core concepts, shows
      the explicit and implicit conditions of a recording event rule,
      has one section for each condition explaining how an event can
      satisfy it, and more.

      The synopsis is more accurate.

      I added an "Event record name" section to indicate what's the name
      of a matched event depending on the instrumentation point type and
      some command-line arguments.

      I also added an "Enable a disabled recording event rule" section
      to explain how the `enable-event` command enables existing,
      disabled events.

      This manual page now documents all the options, even if they're
      the default, as defaults may change in the future.

      The new lttng-event-rule(7) manual page is based on this one, but
      with its own ways to specify event rule conditions.

  lttng-remove-trigger(1):
      * Use "name" instead of "ID".
      * Use `--owner-id` instead of `--user-id`.

  lttng-sessiond(8):
      * Explain what an LTTng session daemon does.

      * Clarify everything related to the tracing group and root
        session daemon.

      * Add a "Daemon configuration" section which explains the
        INI configuration files and the `--config` option.

      * Make the "Tracing session configuration loading" section
        (renamed) much more straightforward, with less text.

      * Specify that the `--daemonize` and `--background` options
        make `lttng-sessiond` only exit when the daemon is ready to
        receive client commands.

  lttng-set-session(1):
      List which commands rely on the current tracing session
      concept.

  lttng(1):
      * Add a "Session daemon connection" section which shows how the
        `lttng` tool (or any LTTng tracing control application) connects
        to a session daemon (user-specific vs. root session daemon).

      * Use tables to list the available commands.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6b98f4907d94763f3bfcb6576e4add9cfc59a2e3

3 years ago.gitignore: add register-some-triggers trigger test utility
Jérémie Galarneau [Fri, 23 Apr 2021 20:21:08 +0000 (16:21 -0400)] 
.gitignore: add register-some-triggers trigger test utility

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

3 years agoFix: event-expr.c: use-after-free and NULL ptr deref in error path
Francis Deslauriers [Thu, 22 Apr 2021 22:50:57 +0000 (18:50 -0400)] 
Fix: event-expr.c: use-after-free and NULL ptr deref in error path

use-after-free
==============
The following functions are affected:
  `lttng_event_expr_app_specific_context_field_create()`, and
  `lttng_event_expr_array_field_element_create()`.

In one error path we call `lttng_event_expr_destroy()` with the
`&expr->parent` pointer (which is dynamically allocated) and this
function then calls free() on that pointer. Right after that function
call we return the pointer that was just freed.

Fix that by adding a `ret_parent_expr` pointer that is set to NULL on
the error path;

Null pointer dereference
========================
The following functions are affected:
  `lttng_event_expr_app_specific_context_field_create()`,
  `lttng_event_expr_array_field_element_create()`, and
  `create_field_event_expr()`.

We dereference a NULL pointer if the argument sanity check fails.

Fix that by checking if `expr` is non-null before dereferencing it.

Found with scan-build.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5fdde462d7345d0dae7ecd2e4f46473a92cd11a9

3 years agoAdapt to namespaced liblttng-ust-ctl symbols
Michael Jeanson [Thu, 22 Apr 2021 22:46:06 +0000 (18:46 -0400)] 
Adapt to namespaced liblttng-ust-ctl symbols

The liblttng-ust ABI bump gave us the opportunity to namespace all
public symbols under the 'lttng_ust_' prefix. All of liblttng-ust-ctl
public symbols were renamed from 'ustctl_' to 'lttng_ust_ctl_'. Adapt
the tools codebase for this API change.

Depends-on: lttng-ust: Ic2b9da019e7776b24b98824ae63d16b86c5a5742

Change-Id: I64b61a7fad86a1c0b4734a4a181f6ea7a9de7e24
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoCleanup: ust-app.c: Dead assignment
Francis Deslauriers [Thu, 22 Apr 2021 21:39:33 +0000 (17:39 -0400)] 
Cleanup: ust-app.c: Dead assignment

Found using scan-build.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8920ee21d8202e9b94b95f517c8e1fbe8c9224a0

3 years agoFix: tests: gen-ust-events-ns: Uninitialized argument value
Francis Deslauriers [Thu, 22 Apr 2021 21:24:57 +0000 (17:24 -0400)] 
Fix: tests: gen-ust-events-ns: Uninitialized argument value

If both `if (snprintf(...` of the `get_ns_inum()` function fail, the
function will not uninitialize the `ns_inum` output parameter and still
return 0. Leading to the argument `ns1` of debug_printf() being used
uninitialized.

Reported-by: scan-build.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I47286312095ca0f6a889eb0faa93661f92156ec1

3 years agoFix: consumerd: strlen called on uninitialized path
Jérémie Galarneau [Thu, 22 Apr 2021 23:54:47 +0000 (19:54 -0400)] 
Fix: consumerd: strlen called on uninitialized path

closed_trace_chunk_path is uninitialized when relayd_id != 0.

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

3 years agoFix: sessiond: notification: leak of condition on duplicate subscription
Jérémie Galarneau [Thu, 22 Apr 2021 23:33:02 +0000 (19:33 -0400)] 
Fix: sessiond: notification: leak of condition on duplicate subscription

An lttng_condition is leaked when a notification channel client attempts
to subscribe to a condition she is already subscribed to.

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

3 years agoFix: action executor: deadlock on session_list_lock
Jonathan Rajotte [Thu, 22 Apr 2021 02:01:02 +0000 (22:01 -0400)] 
Fix: action executor: deadlock on session_list_lock

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

A dead lock is observed during the start-stop test suite for triggers.

Cause
=====

A start session action is executed by the action executor, the
`cmd_start_trace` function is called and effectively holds the
`session_list_lock.`. During `cmd_start_trace` a call to
`notification_thread_command_add_channel` is performed to inform the
notification thread of the new channel presence.

At the same time, a tracer event notification is received by the
notification thread. The actions are queued up and the sample of the
session id take place and a call to `session_lock_list` is performed and
blocks on the lock operation.

The notification thread wait on the `session_list_lock` and the
`session_list_lock` holder, the action executor, waits on the completion
of a command the be run by the notification thread: deadlock.

The backtrace:

 Thread 6 (Thread 0x7f831c8a6700 (LWP 3046458)):
 #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
 #1  0x000000000053b852 in futex (uaddr=0x7f831c8a45e0, op=0, val=0, timeout=0x0, uaddr2=0x0, val3=0) at /home/joraj/lttng/master/install/include/urcu/futex.h:72
 #2  0x000000000053b4f9 in futex_noasync (uaddr=0x7f831c8a45e0, op=0, val=0, timeout=0x0, uaddr2=0x0, val3=0) at /home/joraj/lttng/master/install/include/urcu/futex.h:81
 #3  0x000000000053af10 in lttng_waiter_wait (waiter=0x7f831c8a45d8) at waiter.c:55
 #4  0x000000000046b0f2 in run_command_wait (handle=0xe60520, cmd=0x7f831c8a4588) at notification-thread-commands.c:49
 #5  0x000000000046b270 in notification_thread_command_add_channel (handle=0xe60520, session_name=0x7f8300006c30 "my_triggered_session", uid=1000, gid=1000, channel_name=0x7f82dc00be04 "channel0", key=1, domain=LTTNG_DOMAIN_UST, capacity=2097152) at notification-thread-commands.c:184
 #6  0x00000000004c7f65 in create_channel_per_uid (app=0x7f82d8000bf0, usess=0x7f8300000bb0, ua_sess=0x7f82dc002600, ua_chan=0x7f82dc00bde0) at ust-app.c:3360
 #7  0x00000000004c6f98 in ust_app_channel_send (app=0x7f82d8000bf0, usess=0x7f8300000bb0, ua_sess=0x7f82dc002600, ua_chan=0x7f82dc00bde0) at ust-app.c:3514
 #8  0x00000000004c6bde in ust_app_channel_create (usess=0x7f8300000bb0, ua_sess=0x7f82dc002600, uchan=0x7f8300005a90, app=0x7f82d8000bf0, _ua_chan=0x7f831c8a48b0) at ust-app.c:4771
 #9  0x00000000004c6968 in find_or_create_ust_app_channel (usess=0x7f8300000bb0, ua_sess=0x7f82dc002600, app=0x7f82d8000bf0, uchan=0x7f8300005a90, ua_chan=0x7f831c8a48b0) at ust-app.c:5610
 #10 0x00000000004c4f09 in ust_app_synchronize_all_channels (usess=0x7f8300000bb0, ua_sess=0x7f82dc002600, app=0x7f82d8000bf0) at ust-app.c:5820
 #11 0x00000000004b958c in ust_app_synchronize (usess=0x7f8300000bb0, app=0x7f82d8000bf0) at ust-app.c:5886
 #12 0x00000000004b8500 in ust_app_global_update (usess=0x7f8300000bb0, app=0x7f82d8000bf0) at ust-app.c:5960
 #13 0x00000000004b7ec2 in ust_app_start_trace_all (usess=0x7f8300000bb0) at ust-app.c:5520
 #14 0x0000000000444e86 in cmd_start_trace (session=0x7f8300006c30) at cmd.c:2707
 #15 0x00000000004a5af9 in action_executor_start_session_handler (executor=0x7f8314004410, work_item=0x7f8314005100, item=0x7f83140050b0) at action-executor.c:342
 #16 0x00000000004a537f in action_executor_generic_handler (executor=0x7f8314004410, work_item=0x7f8314005100, item=0x7f83140050b0) at action-executor.c:696
 #17 0x00000000004a4dbc in action_work_item_execute (executor=0x7f8314004410, work_item=0x7f8314005100) at action-executor.c:715
 #18 0x00000000004a37e6 in action_executor_thread (_data=0x7f8314004410) at action-executor.c:797
 #19 0x0000000000486193 in launch_thread (data=0x7f83140044b0) at thread.c:66
 #20 0x00007f8320b60609 in start_thread (arg=<optimized out>) at pthread_create.c:477
 #21 0x00007f8320a87293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

 Thread 5 (Thread 0x7f831d0a7700 (LWP 3046457)):
 #0  __lll_lock_wait (futex=futex@entry=0x5e1c10 <ltt_session_list>, private=0) at lowlevellock.c:52
 #1  0x00007f8320b630a3 in __GI___pthread_mutex_lock (mutex=0x5e1c10 <ltt_session_list>) at ../nptl/pthread_mutex_lock.c:80
 #2  0x00000000004378c3 in session_lock_list () at session.c:156
 #3  0x00000000004a871c in add_action_to_subitem_array (action=0x7f830001a730, subitems=0x7f83140051d0) at action-executor.c:1081
 #4  0x00000000004a8578 in add_action_to_subitem_array (action=0x7f830001a620, subitems=0x7f83140051d0) at action-executor.c:1025
 #5  0x00000000004a4922 in populate_subitem_array_from_trigger (trigger=0x7f830001a950, subitems=0x7f83140051d0) at action-executor.c:1116
 #6  0x00000000004a416e in action_executor_enqueue_trigger (executor=0x7f8314004410, trigger=0x7f830001a950, evaluation=0x7f8314005190, object_creds=0x0, client_list=0x7f8314004980) at action-executor.c:924
 #7  0x0000000000479481 in dispatch_one_event_notifier_notification (state=0x7f831d0a63e8, notification=0x7f8314005160) at notification-thread-events.c:4613
 #8  0x0000000000472324 in handle_one_event_notifier_notification (state=0x7f831d0a63e8, pipe=65, domain=LTTNG_DOMAIN_UST) at notification-thread-events.c:4702
 #9  0x0000000000472271 in handle_notification_thread_event_notification (state=0x7f831d0a63e8, pipe=65, domain=LTTNG_DOMAIN_UST) at notification-thread-events.c:4717
 #10 0x00000000004695a3 in handle_event_notification_pipe (event_source_fd=65, domain=LTTNG_DOMAIN_UST, revents=1, state=0x7f831d0a63e8) at notification-thread.c:591
 #11 0x000000000046849b in thread_notification (data=0xe60520) at notification-thread.c:727
 #12 0x0000000000486193 in launch_thread (data=0xe60610) at thread.c:66
 #13 0x00007f8320b60609 in start_thread (arg=<optimized out>) at pthread_create.c:477
 #14 0x00007f8320a87293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Solution
========

Instead of using session_find_by_name() which requires the
`session_list_lock`, we introduce `sample_session_id_by_name` that uses
a urcu backed data structure. This allows the sampling of the session
id without holding the session list lock. We accept the small window
where a session object is still accessible but concretely not valid
since the actual execution context will be validated at the moment of
execution. The execution side already handles the possibility that the
session is removed at that point or is not the same session. The
execution side acquires the session_list_lock for validation.

Known drawbacks
=========

None

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5ad2c57acc0d03d2814dda59f8ecf2d831fd961e

3 years agolttng add-trigger: replace --exclude-names with --exclude-name
Simon Marchi [Tue, 20 Apr 2021 02:13:28 +0000 (22:13 -0400)] 
lttng add-trigger: replace --exclude-names with --exclude-name

Implement the proposal to make the --exclude-names option singular. The
user can specify it multiple times to specify multiple exclusions,
rather than specifying a comma-separated list.

Change-Id: Id95313bb5576a8d6cecb73b61b537ae190554cd0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agosessiond: refcount `ust_error_accounting_entry`
Francis Deslauriers [Fri, 16 Apr 2021 15:14:21 +0000 (11:14 -0400)] 
sessiond: refcount `ust_error_accounting_entry`

Keep a reference count of the `ust_error_accounting_entry` to reclaim
memory and cleanup handles as we go.

Triggers on a sessiond target all applications regardless of the UID of
both the trigger and the application. This means that whenever a new UST
counter is created for a UID, we need to keep it around as long as there
is 1. an application from that UID, or 2. an event notifier registered.

This commit achieves that by keeping a count of the registered event
notifiers. If the count is above zero, we keep a reference on every UID
entries. When the count reaches zero, we put that reference on every
entries.

The event notifier count is guarded by a mutex since it's accessed by
both the notification thread and UST registration thread.

Here is the pseudo code for the relevant error accounting events:
App registration:
  lookup entry for application UID in hashtable
  if found:
    get a reference on that existing entry
  else:
    create a new entry for that UID
    get a reference on that new entry
    if event_notifier_count > 0:
      get an extra reference on the behalf of the event notifiers

Event notifier registration:
  increment event_notifier_count
  if event_notifier_count == 1:
    get a reference on all existing UID entries

App unregistration:
  put reference on application UID entry

Event notifier unregistration:
  decrement event_notifier_count
  if event_notifier_count == 0:
    put ref on all existing UID entries

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I74667d30a5b6975bad7975b82f6819e263199cd0

3 years agoaction list: missing renames from previous name "group"
Jérémie Galarneau [Thu, 22 Apr 2021 18:56:59 +0000 (14:56 -0400)] 
action list: missing renames from previous name "group"

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

3 years agoFix: error-query: uninitialized action_index value
Jérémie Galarneau [Thu, 22 Apr 2021 18:50:55 +0000 (14:50 -0400)] 
Fix: error-query: uninitialized action_index value

action_index will be used uninitialized if the user passes an action
that is not part of the trigger (an API use error).

CID 1452662 (#2 of 2): Uninitialized scalar variable (UNINIT)
14. uninit_use: Using uninitialized value action_index.is_set.

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

3 years agoFix: sessiond: leak of config_path on duplicate --config option
Jérémie Galarneau [Thu, 22 Apr 2021 18:47:14 +0000 (14:47 -0400)] 
Fix: sessiond: leak of config_path on duplicate --config option

1452207 Resource leak

The system resource will not be reclaimed and reused, reducing the
future availability of the resource.

CID 1452373 (#3 of 3): Resource leak (RESOURCE_LEAK)
26. overwrite_var: Overwriting config_path in config_path =
utils_expand_path(optarg) leaks the storage that config_path points to.

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

3 years agoFix: tests: base notification client: unchecked sscanf return value
Jérémie Galarneau [Thu, 22 Apr 2021 18:43:02 +0000 (14:43 -0400)] 
Fix: tests: base notification client: unchecked sscanf return value

CID 1407934 (#2 of 2): Unchecked return value (CHECKED_RETURN)
8. check_return: Calling sscanf without checking return value (as is
done elsewhere 17 out of 19 times).

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

3 years agoFix: argpar: Error out when passing an argument to long option that takes no argument
Simon Marchi [Fri, 9 Apr 2021 16:48:30 +0000 (12:48 -0400)] 
Fix: argpar: Error out when passing an argument to long option that takes no argument

If the user defines a long option `--foo` and passes `--foo=arg`, the
current behavior is that the option foo is recognized and the argument
is ignored.  Change that to be an error.

It is currently not possible to pass arguments to short options using an
equal sign, so this doesn't apply to short options.

Equivalent accepted change in argpar: https://review.lttng.org/c/argpar/+/5361

Change-Id: I6fd6271abb7e271704db1e60f680729931a1fbe1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoClean-up: sessiond: identation fix
Jérémie Galarneau [Thu, 22 Apr 2021 16:37:37 +0000 (12:37 -0400)] 
Clean-up: sessiond: identation fix

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

3 years agoFix: tests: health thread stall: only stop consumerd when required
Jérémie Galarneau [Thu, 22 Apr 2021 16:32:26 +0000 (12:32 -0400)] 
Fix: tests: health thread stall: only stop consumerd when required

Since a0f8e3109, stop_lttng_consumerd will report a failure when
there is no consumer daemon to kill. This fix ensures it is only
invoked for tests that launch a consumer daemon.

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

3 years agoFix: tests: notification: update kernel testcase count
Francis Deslauriers [Thu, 22 Apr 2021 15:07:26 +0000 (11:07 -0400)] 
Fix: tests: notification: update kernel testcase count

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib65e4ea8ced397bdd3b30f1401121adbfeeff23a

3 years agoFix: tests: integer truncation warning on 32-bit platforms
Jérémie Galarneau [Thu, 22 Apr 2021 14:17:04 +0000 (10:17 -0400)] 
Fix: tests: integer truncation warning on 32-bit platforms

large integer implicitly truncated to unsigned type [-Woverflow]

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

3 years agoFix: sessiond: triggers: failure to insert trigger is fatal
Jérémie Galarneau [Wed, 21 Apr 2021 04:41:09 +0000 (00:41 -0400)] 
Fix: sessiond: triggers: failure to insert trigger is fatal

Inserting a trigger by name/owner should succeed if it could be added
to the top-level triggers_ht.

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

3 years agosessiond: notification-thread: switch logging to debug on GET_TRIGGER
Jérémie Galarneau [Wed, 21 Apr 2021 03:57:11 +0000 (23:57 -0400)] 
sessiond: notification-thread: switch logging to debug on GET_TRIGGER

Not finding a trigger is not necessarily an error (espeacially during
the execution of tests).

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

3 years agoTests: add trigger name/unnamed backwards compatibility test
Jérémie Galarneau [Mon, 19 Apr 2021 21:44:55 +0000 (17:44 -0400)] 
Tests: add trigger name/unnamed backwards compatibility test

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

3 years agolttng-ctl: separate support of named/unnamed trigger registration
Jérémie Galarneau [Tue, 20 Apr 2021 02:38:49 +0000 (22:38 -0400)] 
lttng-ctl: separate support of named/unnamed trigger registration

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

3 years agosessiond: add support for anonymous triggers
Jérémie Galarneau [Tue, 20 Apr 2021 04:43:22 +0000 (00:43 -0400)] 
sessiond: add support for anonymous triggers

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

3 years agoFix: lttng-ctl: assertion failure during unregistration of trigger
Jérémie Galarneau [Tue, 20 Apr 2021 16:48:05 +0000 (12:48 -0400)] 
Fix: lttng-ctl: assertion failure during unregistration of trigger

Issue observed
==============

lt-trigger_name: trigger.c:302: int lttng_trigger_serialize(const struct lttng_trigger *, struct lttng_payload *): Assertion `(creds->uid).is_set' failed.

Program terminated with signal SIGABRT, Aborted.
 #0  0x00007fb74129eef5 in raise () from /usr/lib/libc.so.6
 #1  0x00007fb741288862 in abort () from /usr/lib/libc.so.6
 #2  0x00007fb741288747 in __assert_fail_base.cold () from /usr/lib/libc.so.6
 #3  0x00007fb741297646 in __assert_fail () from /usr/lib/libc.so.6
 #4  0x00007fb74169bab7 in lttng_trigger_serialize (trigger=0x5616f6f70060, payload=0x7ffe5819d140) at trigger.c:302
 #5  0x00007fb74169cef0 in lttng_trigger_copy (trigger=0x5616f6f70060) at trigger.c:859
 #6  0x00007fb74164302e in lttng_unregister_trigger (trigger=0x5616f6f70060) at lttng-ctl.c:3350
 #7  0x00005616f50c675f in register_named_trigger () at trigger_name.c:295
 #8  0x00005616f50c6879 in main (argc=1, argv=0x7ffe581a07d8) at trigger_name.c:343

Cause
=====

When creating a trigger instance and using it to unregister an existing
trigger, its credentials are unset (meaning 'default'). Expecting this,
lttng_unregister_trigger() copies the source trigger to change its
credentials to those of the caller.

Unfortunately, the trigger copy operation expects credentials to be set.

We don't run into this situation typically since the trigger instance
used to perform the unregistration is sourced from a listing or is the
same instance that was used to perform the registration (which sets the
credentials before serializing).

Solution
========

A proper implementation of "copy" is provided for the trigger object
itself. For its condition and action, we still use the same "trick"
of leveraging the serdes code to perform a deep-copy, keeping the change
small

Drawbacks
=========

None really, except that we lose some of the code sharing between
copy and serdes.

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

3 years agoRename group action files to list files
Jonathan Rajotte [Tue, 20 Apr 2021 02:06:33 +0000 (22:06 -0400)] 
Rename group action files to list files

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iea4c2fe0a2d7001e8c05b4bb33c24e5641b193b0

3 years agoRename action group to action list
Jonathan Rajotte [Tue, 20 Apr 2021 01:57:13 +0000 (21:57 -0400)] 
Rename action group to action list

This is necessary to convey that the `group` an ordered sequence of
actions. We use the term `list` to put an emphasis on the ordered nature
of the group.

Files rename follows.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idb85d8ca5b60947d8dc3d43d98c8d915bf34c3f2

3 years agoRename on-event to event-rule-matches
Jonathan Rajotte [Tue, 20 Apr 2021 01:22:09 +0000 (21:22 -0400)] 
Rename on-event to event-rule-matches

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Icb596abdd0c291643f144ce274919b4094828e95

3 years agoMove on-event*.* to event-rule-matches*.*
Jonathan Rajotte [Tue, 20 Apr 2021 01:03:40 +0000 (21:03 -0400)] 
Move on-event*.* to event-rule-matches*.*

Code renaming follows.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ifb2de118546d39877e77ba30ba8720f75240eb39

3 years agoIntroduce emission site for syscall event rule
Jonathan Rajotte [Fri, 16 Apr 2021 21:24:20 +0000 (17:24 -0400)] 
Introduce emission site for syscall event rule

The tracer support multiple emission site configuration: entry, exit,
both.

On the CLI, the emission site is exposed directly on the event rule type
with the following syntax:

 --type=syscall:entry
 --type=syscall:exit
 --type=syscall:entry+exit

`--type=syscall` is equivalent to `--type=syscall:entry+exit`.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I65faea6872f121b98b781d931b6cc7301f20a0b6

3 years agolttng list-triggers: handle all condition types
Simon Marchi [Thu, 15 Apr 2021 13:07:31 +0000 (09:07 -0400)] 
lttng list-triggers: handle all condition types

At the moment, only the event-rule-matches condition is handled by the
list-triggers commands. Change it to handle all existing condition
types.

Because these other condition types can't be created using the
command-line interface, add a util program that creates and registers
triggers for the purpose of the test. The test triggers with the
event-rule-matches condition are kept as is, created using the
command-line interface.

Change-Id: I6a2b0442800c93f7e8815dce96d1cf1928d5725a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agoFix: sessiond: trigger with condition not requiring event notifier cannot be listed
Jonathan Rajotte [Mon, 19 Apr 2021 18:04:53 +0000 (14:04 -0400)] 
Fix: sessiond: trigger with condition not requiring event notifier cannot be listed

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

The lttng-sessiond process aborts when an lttng error query is performed
against a trigger that uses a condition other than "event-match".

Cause
=====

The trigger's condition is a LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE
which does not have a "domain type".

This results in the call to `abort()` in
`event_notifier_error_accounting_get_count` of the default case.

Solution
========

Check if the trigger "needs" or at least "depends" on tracer notifier.

Known drawbacks
=========

None

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d5f09617f95315060a611b464d1df95cb80c5bd

3 years agolttng add-trigger: remove support for conditions other than event-rule-matches
Simon Marchi [Thu, 15 Apr 2021 11:49:16 +0000 (07:49 -0400)] 
lttng add-trigger: remove support for conditions other than event-rule-matches

We initially only want to support the event-rule-matches condition, so
remove any trace of the other ones. They'll be added later as needed.

Change-Id: I66b79bea89257187865ebf599ef0341279629ec6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agolttng {add,list,remove}-trigger: rename user id to owner uid
Simon Marchi [Thu, 15 Apr 2021 11:31:01 +0000 (07:31 -0400)] 
lttng {add,list,remove}-trigger: rename user id to owner uid

Implement the proposal to rename the --user-id option to --owner-uid in
the add-trigger and remove-trigger commands.  Update the output of
list-triggers as well.

Change-Id: I79977a0efe80d96917fcaf55909a78c81047c388
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agolttng add-trigger: replace log level options with --log-level
Simon Marchi [Thu, 15 Apr 2021 02:28:07 +0000 (22:28 -0400)] 
lttng add-trigger: replace log level options with --log-level

Implement the proposal to replace the --loglevel and --loglevel-only
options with a single --log-level option.

The syntax of the argument to --log-level is:

 - `LEVEL`: to specify only this level
 - `LEVEL..`: to specify from this level up to the most critical level
 - `..`: to specify any level. Basically the same as no `--log-level`
         option.

The intent is to keep the door open to fully support ranges with the
`LEVEL1..LEVEL2` syntax.  The loglevel_parse_range_string function and
friends are implement this, but their caller in add_trigger.c,
parse_log_level_string, artificially restricts it to the two cases
shown above.

Change-Id: Id8607b3dae2db5aace263f0c56ada2e822db907c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 years agolttng add-trigger: replace event rule type options with --type
Simon Marchi [Wed, 14 Apr 2021 02:21:56 +0000 (22:21 -0400)] 
lttng add-trigger: replace event rule type options with --type

Implement the proposal to replace the --function, --probe,
--userspace-probe, --syscall and --tracepoint options, used to select an
event rule type, with a single --type option.

The --probe, --userspace-probe and --function options used to take an
argument, the name of the location.  For these types, the --location
option is introduced to specify that information.

Change-Id: Ib62e502beb6832a3d26cb135ca6b2746382f2075
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.053828 seconds and 4 git commands to generate.