Jérémie Galarneau [Tue, 18 Feb 2020 01:13:49 +0000 (20:13 -0500)]
Fix: directory-handle: use of free'd handle on fstat() error
On an error to fstat a directory handle, a directory handle is
released and is still initialized as if the error had not occurred.
Return NULL early from lttng_directory_handle_create_from_dirfd()
to prevent those erroneous accesses.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2a3bb1cfe8c90d3f7f87a68286a9b8524694d3c
Jérémie Galarneau [Tue, 18 Feb 2020 01:05:22 +0000 (20:05 -0500)]
Fix: relayd: use of relay_session ref count before initialization
The relay_session's reference count is used before it is initialized
on multiple code paths of session_create(). The initialization of the
reference count, mutexes, and intrusive data structure nodes are
initialized earlier to make their use safe in the event of an error.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1be53ad88a3e783b85b4c568527df1a75ce58d3a
Jérémie Galarneau [Tue, 18 Feb 2020 00:32:54 +0000 (19:32 -0500)]
Fix: relayd: unchecked return value when opening relay socket
fd_tracker_open_unsuspendable_fd may fail because the underlying
socket() call fails or there may be too many open file descriptors at
the time of the call. In both cases, these errors must be logged and
handled.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8b8c4fcc9de08746a91778b58c74b2118e98667b
Simon Marchi [Tue, 11 Feb 2020 22:29:09 +0000 (17:29 -0500)]
configure: add --enable-Werror
If one wants to build with -Werror, it's not possible to simply
configure with -Werror in the CFLAGS. This makes a bunch of configure
checks fail, which would have otherwise passed.
This patch adds an --enable-Werror option to configure, which has the
effect of adding -Werror to AM_CFLAGS. It therefore ends up in the
CFLAGS used to build the project, but it doesn't interfere with the
configure checks.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I18c33125c717305aac8f1d8a19fee7e065d70c31
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Fri, 31 Jan 2020 18:05:20 +0000 (13:05 -0500)]
configure: use AX_APPEND_COMPILE_FLAGS to detect supported warning flags
I would eventually like to enable some additional warnings by default
when building lttng-tools. However, some warnings are
compiler-specific or are not present in older versions of some compilers
we need to support. We can therefore not add them unconditionally to
CFLAGS.
This patch uses the AX_APPEND_COMPILE_FLAGS macro to address that. This
macro tests each individual flag we pass it with the current compiler.
If it finds that the flag is supported (the compiler exits with status 0
when compiling a file with that flag), it appends it to the given
variable, WARN_CFLAGS in our case). WARN_CFLAGS is then added to
AM_CFLAGS.
With time, we'll be able to throw any warning flag in there that we
think is useful, even if just available in a recent version of one
compiler.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Id2ae4b4e8882af788c835ce89a979544531370e9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Mon, 3 Feb 2020 22:38:23 +0000 (17:38 -0500)]
tests: append to AM_CFLAGS instead of overriding it
The Makefiles modified by this patch currently override the AM_CFLAGS
value, which means that anything put in AM_CFLAGS by configure (for
example, the warning flags) is lost.
I believe the intention is to add some flags to CFLAGS, so modify them
such that they append instead of override.
notification/Makefile.am overrides AM_LDFLAGS with nothing. It feels
like it was not the intention to actually clear that variable, but
rather that it is just the by-product of a copy paste. If it was really
the intention to clear the value of AM_LDFLAGS, there would have been a
comment to explain it, right?
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I4ef926d9135b16200e5f17d09461506a5e955068
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 12 Feb 2020 00:27:05 +0000 (19:27 -0500)]
Tests: gen-ust-nevents: use options instead of arguments
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I59c648c650304e12b30bf8a3eaedaf9727c48700
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 12 Feb 2020 00:17:36 +0000 (19:17 -0500)]
Tests: Cleanup: test_exclusion: more detailed output
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I97baaf30385b644766f2e825d8884ea75770b330
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 11 Feb 2020 23:27:35 +0000 (18:27 -0500)]
Fix: Tests: `test_exclusion` passing for the wrong reason
Issue
=====
The following commit added `-i` and `-w` flags to the test app arguments
of the `test_exclusion` tests:
commit
6c4a91d639747f260ab46decebc50998ef063712
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Mon Aug 26 14:22:06 2019 -0400
tests: gen-ust-events: use options instead of arguments
Remove argument dependency and ease usage of features individually.
The `gen-ust-nevents` was not modified to support those flags. I suspect this
mistake was caused by the name similarity of the `gen-ust-nevents` and the
`gen-ust-events` test applications.
We ended up calling the following command:
./gen-ust-nevents -i 100 -w -1
When called with such arguments the `gen-ust-nevents` parsed the first
argument (`-i`) using `atoi()` which retuned 0. This was interpreted as
the number of iterations requested by the user so the app immediately
exited without generating any events.
So, the test was not seeing any of the excluded events in the trace
which was then considered as a successful result but no events were ever
excluded because none were generated in the first place.
Solution
========
Remove the use of `-i` and `-w` flags.
I also added a `dry_run` test to confirm that we do indeed get events
when exclusions are not used to prevent this error from happening in the
future.
Notes
=====
- I changed the wildcard used in the enable-event command so to only
enable events from the testapp and not the `lttng_ust_statedump:` events
as those are generated even if we didnt' ask for them.
- I add a stderr redirection to `/dev/null` in the trace reading
pipeline because we now end up with traces with no events. This has
changed because we now only enable events from the application (see
previous note).
- In a future commit, I will change the `gen-ust-nevents` application to
take those `-i` and `-w` flags.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id37dcd59a18b3401d97439bce1191a8c5cac87d5
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Tue, 11 Feb 2020 20:51:52 +0000 (15:51 -0500)]
Tests: notification.c: remove extra space
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iee893ab9d4aeb59e335af83b068adf716ac869f8
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 18 Feb 2020 00:51:54 +0000 (19:51 -0500)]
Fix: trace-chunk: useless assignment to 'ret'
'ret' is not used to report error in
lttng_trace_chunk_rename_path_no_lock(); status is used. Therefore,
this assignment is useless.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1804d616a24c41d3956b021f90bb77d0e6efef1a
Jérémie Galarneau [Tue, 18 Feb 2020 00:49:04 +0000 (19:49 -0500)]
Fix: lttng: track-untrack: error assigned to wrong variable
CMD_ERROR is assigned to 'ret' rather than 'command_ret' when
an unknown left-over argument is passed to the track/untrack
command.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5889a934d9859d0499eb26555658bf15af73f927
Jérémie Galarneau [Tue, 18 Feb 2020 00:46:18 +0000 (19:46 -0500)]
Fix: relayd: live: unchecked poll set creation return value
The fd_tracker_util_poll_create function can fail because of fd
exhaustion or because the underlying epoll call fails.
In both cases, report and handle the error.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie79fdc011afda43395ac883c6648f983118cfddb
Jérémie Galarneau [Tue, 18 Feb 2020 00:40:47 +0000 (19:40 -0500)]
Fix: relayd: live: unchecked return value when opening relay socket
fd_tracker_open_unsuspendable_fd may fail because the underlying
socket() call fails or there may be too many open file descriptors at
the time of the call. In both cases, these errors must be logged and
handled.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3205896a5e8c83ceba02005a2b73f9466d26427c
Jérémie Galarneau [Tue, 18 Feb 2020 00:35:52 +0000 (19:35 -0500)]
Fix: relayd: unchecked poll set creation return value
The fd_tracker_util_poll_create function can fail because of fd
exhaustion or because the underlying epoll call fails.
In both cases, report and handle the error.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id1e35d43442e74dd6784a9a4e235576a5bf135e2
Jérémie Galarneau [Fri, 14 Feb 2020 22:09:58 +0000 (17:09 -0500)]
Fix: lttng: uninitialized pointer free'd when no sessiond is present
The error path of get_schedules assumes that schedules_comm is !NULL,
which is not the case currently.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I16e2d9d45cd3df9cfa80214abe03bcc782fa1f11
Jérémie Galarneau [Wed, 12 Feb 2020 23:52:41 +0000 (18:52 -0500)]
Fix: tracker: inclusion of internal header in public header
common/macros.h is an internal header which should not be used
publicly. It doesn't seem used anyhow so it is simply removed here.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie385dba2dc03506db2e075c15969836303470b56
Francis Deslauriers [Tue, 11 Feb 2020 02:46:34 +0000 (21:46 -0500)]
Tests: Fix: `wait_on_file()` returns too early
Issue
=====
With the current implementation, when calling the `wait_on_file()`
function with the `file_exist` parameter set to false the function will
return even if the target file exists.
In a scenario where we enter the loop and the targer file exist, the
first call to `stat()` will return 0 and will not enter any of the `if`
and break from the loop directly.
Solution
========
If the file exists, only break from the loop if it's the desired exit
condition.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia3e9c41a2a515815d3ff931d8f7c1c14a52b31ae
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Fri, 7 Feb 2020 19:56:50 +0000 (14:56 -0500)]
Fix: Tests: utils.sh: fix unbound variable
When loading `utils.sh`, we test the `LTTNG_TEST_TEARDOWN_TIMEOUT` and
define it to a default value if it's not defined already.
When running bash test scripts with the `-u` option to error out when
encountering unset variables it prints an error and exit
This commit uses a trick found here:
https://stackoverflow.com/questions/
3601515/how-to-check-if-a-variable-is-set-in-bash
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id24937f974ffd1ab3250296499da9360f97d393d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 10 Feb 2020 22:18:48 +0000 (17:18 -0500)]
Tests: Fix typo: registerd -> registered
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I74f6956d732c41168dfdfa101c6fcad0af6ecebe
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 10 Feb 2020 22:43:21 +0000 (17:43 -0500)]
Tests: Cleanup: remove unused bash variable
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie200a8b5044e2199526aac4a138f0c2e5ee5b0d8
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Thu, 6 Feb 2020 15:26:05 +0000 (10:26 -0500)]
Typo: 'toogle' -> 'toggle'
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id3c9a1942b21a66b626512e8378c517d48949582
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 5 Feb 2020 16:41:23 +0000 (11:41 -0500)]
Fix: lttng-sessiond: control reaches end of non-void function warning
Fixes the following error when building with GCC 7.4.0 with the
following CFLAGS: "-g -fsanitize=address":
tracker.c: In function ‘lttng_tracker_id_lookup_string’:
tracker.c:405:1: error: control reaches end of non-void function [-Werror=return-type]
}
^
At first glance, this seems like a false positive. I don't see how we
can reach the end of the function without passing by a return statement.
Even considering that, removing the `break` statement makes sense
because it's superfluous.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I0b596d328bc38183f21bd3a6f8419a63207953f3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 4 Feb 2020 21:03:00 +0000 (16:03 -0500)]
Fix: possible null dereference
lttng_inode_create can return null.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I70be9ebabe097d10fb3ee5f46f0b299c02d08ce0
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 4 Feb 2020 21:03:40 +0000 (16:03 -0500)]
Fix: string might be uninitialized
lttng_dynamic_appen_buffer accepts NULL buf as long as len is zero when
called. This is the case for when the id is a numeric value.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ia1a121dcc2448378a4ad873ac159a89221e4c637
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 4 Feb 2020 21:04:41 +0000 (16:04 -0500)]
Fix: force the use of our _FORTIFY_SOURCE definition
Some toolset (ubuntu) already defined the _FORTIFY_SOURCE.
This removes the warning we see if this is the case. Unset the variable and
reset it.
The warning:
make[3]: Entering directory '/home/joraj/lttng/master/lttng-tools/tests/regression/kernel'
CC select_poll_epoll-select_poll_epoll.o
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
CCLD select_poll_epoll
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I2fa0482afa8941705a992f62a2e63657ea9e2b87
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 4 Feb 2020 19:59:41 +0000 (14:59 -0500)]
Update version to v2.12.0-rc1
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6845405f0d59270181ab67f27f8acab5d83633d7
Jérémie Galarneau [Tue, 4 Feb 2020 00:51:08 +0000 (19:51 -0500)]
Tests: fix: test_relayd_working_directory fails as user
A formating issue introduced by
15da468cd causes the temporary
directory of the a test to be initialized incorrectly, causing it to
fail when it is not skipped (executed as a non-root user).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idd09f27fa2ce0f5991056ab52bc1718080122151
Jérémie Galarneau [Mon, 3 Feb 2020 22:33:28 +0000 (17:33 -0500)]
Fix: sessiond: snapshot errors don't clear session's trace chunk
The snapshot record command is implemented by creating and setting
a new trace chunk on the target session, capturing the snapshot, and
closing the session's trace chunk once it is complete.
On some error paths, the session's newly created trace chunk is not
cleared. This means that the session is seen to have a
'current_trace_chunk' on the next attempt to record a snapshot; an
unexpected condition for which an assert() exists.
This results in the following crash:
lttng-sessiond: /home/smarchi/src/lttng-tools/src/bin/lttng-sessiond/cmd.c:4685: snapshot_record: Assertion `!session->current_trace_chunk' failed.
Ensure that the session's current trace chunk is closed and cleared
when an error occurs during the command's execution.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4f78e3c324bee873349ed5b4d8e189a000458a07
Jérémie Galarneau [Mon, 3 Feb 2020 22:25:58 +0000 (17:25 -0500)]
Fix: sessiond: bounded snapshot record fails when no streams exist
Attempting to record a snapshot with a `--max-size` fails when no
streams exist. For instance, attempting to record a snapshot for a
user space session when no applications are running will fail with the
following output:
Error: Invalid snapshot size. Cannot fit at least one packet per stream.
Error: Snapshot max size is invalid
The function get_session_nb_packets_per_stream() computes an
approximation of the number of packets to capture to honor the maximal
size specified. However, at the end, it doesn't distinguish between
'0' meaning that "no packets can be captured" (no streams exist) and
'0' meaning that "the max size is too small to accomodate one packet".
Those two cases can be distinguished by checking if the 'size_left' is
still the 'max_size', meaning that not even the size of one packet was
substracted from 'max_size'.
Reported-by: Simon Marchi <simark@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5caef9ce926bbc7143a90667749ffaed972590c1
Jérémie Galarneau [Mon, 3 Feb 2020 20:56:43 +0000 (15:56 -0500)]
Tests: fix: test_relayd_working_directory fails as root
From the original bug report:
This test succeeds as user, but fails as root:
not ok 23 - Warning about missing write permission is present
Failed test 'Warning about missing write permission is present'
in tools/working-directory/test_relayd_working_directory:test_relayd_debug_permission() at line 182.
The warning does not trigger because root always has access.
Skip this test since the permission check will succeed and the relay
daemon won't produce the expected error message.
Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4eb29958aaca78405e1fdd2392d73472af0d5912
Jérémie Galarneau [Mon, 3 Feb 2020 19:34:53 +0000 (14:34 -0500)]
Fix: trace-chunk: dereference after NULL check
old_path is used directly even though it is checked for NULL. The
situation highlighted by Coverity does not appear to be possible given
the current use of the API. However, it should still be checked to
catch future errors (or current bugs).
1412200 Dereference after null check
Either the check against null is unnecessary, or there may be a null
pointer dereference.
In lttng_trace_chunk_rename_path_no_lock: Pointer is checked against
null but then dereferenced anyway (CWE-476)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I991231cc636eaed98cb84eec08a5072748ff9ef4
Jérémie Galarneau [Fri, 31 Jan 2020 23:22:22 +0000 (18:22 -0500)]
Clean-up: mi: remove logically dead code
1412199 Logically dead code
The indicated dead code may have performed some action; that action
will never occur.
In mi_lttng_id_target: Code can never be reached because of a logical
contradiction (CWE-561)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8279cd1e6ab5bc86bd4ea4ca8ac721ad1e31e02b
Jérémie Galarneau [Fri, 31 Jan 2020 23:20:18 +0000 (18:20 -0500)]
Fix: trace-chunk: dereference after null check of old_path
1412200 Dereference after null check
Either the check against null is unnecessary, or there may be a null
pointer dereference.
In lttng_trace_chunk_rename_path_no_lock: Pointer is checked against
null but then dereferenced anyway (CWE-476)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I33088fecc62141bd6092a7ab8c0a8c29a36347e8
Jérémie Galarneau [Fri, 31 Jan 2020 23:06:09 +0000 (18:06 -0500)]
Clean-up: unchecked return value
The return value of lttng_dynamic_buffer_set_size() is ignored in
lttng_dynamic_array_clear(). It is okay as
lttng_dynamic_buffer_set_size(..., 0) can't fail. However, it
results in a Coverity Scan warning.
1412201 Unchecked return value
If the function returns an error value, the error value may be
mistaken for a normal value.
In lttng_dynamic_array_clear: Value returned from a function is not
checked for errors before being used (CWE-252)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1943e299e4cb5752711f2d25b0dd9a5c44a28a18
Jérémie Galarneau [Fri, 31 Jan 2020 23:04:49 +0000 (18:04 -0500)]
Fix: unchecked return value of cds_lfht_destroy()
1412202 Unchecked return value
If the function returns an error value, the error value may be
mistaken for a normal value.
In lttng_tracker_list_destroy: Value returned from a function is not
checked for errors before being used (CWE-252)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I85c994440bc2cd5df0545fd1364dab462f98bc1c
Jérémie Galarneau [Fri, 31 Jan 2020 22:58:56 +0000 (17:58 -0500)]
Fix: relayd: return from function without unlocking session lock
Some error paths in relay_close_trace_chunk() skip the unlock
of the relay_session's lock.
412203 Missing unlock
May result in deadlock if there is another attempt to acquire the
lock.
In relay_close_trace_chunk: Missing a release of a lock on a
path (CWE-667)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I43187959abf00e761f7a255f4af7cd53e0c451fb
Jérémie Galarneau [Fri, 31 Jan 2020 22:56:26 +0000 (17:56 -0500)]
Clean-up: consumerd: remove unreachable code
1412204 Logically dead code
The indicated dead code may have performed some action; that action
will never occur.
In consumer_clear_unmonitored_channel: Code can never be reached
because of a logical contradiction (CWE-561)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I116ba5127bf30d3cee1e5f002d7360bc4bc22098
Jérémie Galarneau [Fri, 31 Jan 2020 22:51:04 +0000 (17:51 -0500)]
Clean-up: trace-chunk: remove unreachable code
`path` can never be NULL in this code path; it is unnecessary to check
it.
There may be a null pointer dereference, or else the comparison
against null is unnecessary.
In lttng_trace_chunk_rename_path_no_lock: All paths that lead to this
null pointer comparison already dereference the pointer
earlier (CWE-476).
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4d850b0b8686300268d85f577ae5f14a96d66348
Jérémie Galarneau [Fri, 31 Jan 2020 22:41:08 +0000 (17:41 -0500)]
Fix: unchecked return value of lttng_directory_handle_create()
Although unlikely in this case (as the path was just created), the
creation of a directory handle can fail and this should always be
accounted-for.
1415129 Dereference null return value
If the function actually returns a null value, a null pointer
dereference will occur.
In lttng_unlinked_file_pool_add_inode: Return value of function which
returns null is dereferenced without checking (CWE-476)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I914802c25b569320e08265aae251e062bccbd50e
Jérémie Galarneau [Fri, 31 Jan 2020 22:38:23 +0000 (17:38 -0500)]
Tests: fd-tracker: fix: leak of test paths
Leak of memory or pointers to system resources (CWE-404)
Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id57254c990ee43dc6901c7778655830e0564e975
Simon Marchi [Fri, 31 Jan 2020 19:22:24 +0000 (14:22 -0500)]
session-descriptor: fix comment typos in session-descriptor.h
Change-Id: Idafd16fd2851798a47bd95a7887f5bf9ba7828d0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 31 Jan 2020 21:48:20 +0000 (16:48 -0500)]
Fix: directory-handle: typo in equals method breaks compat build
The 'path' member does not exist in a directory handle; 'base_path'
should be used instead. This breaks the build on platforms that
lack dirfd support (e.g. Solaris 10).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1cedf36520960c575b470d4306755dfeb9417cb4
Jérémie Galarneau [Fri, 31 Jan 2020 21:33:26 +0000 (16:33 -0500)]
Fix: potential use of uninitialized return value
lttng_tracker_ids_serialize() can return an uninitialized value
when 0 ids are being tracked by a tracker. This is not currently
reachable, but generates a warning on some compilers.
'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia54f5276d6a89d39badfc6c718ad0032edb98ec8
Jérémie Galarneau [Fri, 31 Jan 2020 21:25:14 +0000 (16:25 -0500)]
Clean-up: remove instances of loop initial declarations
Loop initial declarations are not permitted by the project's
coding standard and cause the build to fail on Solaris platforms.
tracker.c: In function 'lttng_tracker_ids_serialize':
tracker.c:314:2: error: 'for' loop initial declarations are only allowed in C99 mode
for (unsigned int i = 0; i < count; i++) {
^
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I627974ef82ca26586c96d354f217f9943db9d67c
Jérémie Galarneau [Fri, 31 Jan 2020 21:12:24 +0000 (16:12 -0500)]
Fix: relayd: register listener threads as rcu readers
Both live and consumer listener threads are now RCU readers as
they use the fd_tracker which makes use of RCU.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8aab8615b8db1f1fea48deb1ae03ad5beeaa6f32
Jérémie Galarneau [Thu, 30 Jan 2020 16:45:07 +0000 (11:45 -0500)]
relayd: track directory handles through the fd-tracker
Track directory handles through the fd-tracker as unsuspendable
file descriptors. New fd-tracker utils are introduced to wrap
the creation and registration of the file descriptors to the
fd-tracker.
Note that file descriptors only need to be tracked when the
dirfd-backed implementation of the directory handles is used.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I754af1943f5d6f02a6219d48c8fc4b8106de1c13
Michael Jeanson [Thu, 7 Mar 2019 19:54:57 +0000 (14:54 -0500)]
tests: Move to kernel style SPDX license identifiers
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.
See https://spdx.org/ids-how for details.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I89cd4b4b7440f71f52426a5508252932bb46e796
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Wed, 15 Jan 2020 20:42:31 +0000 (15:42 -0500)]
Fix: include stdlib.h in compat/string.h
Fixes:
CC uuid.lo
In file included from /home/smarchi/src/lttng-tools/src/common/uuid.c:19:0:
/home/smarchi/src/lttng-tools/src/common/compat/string.h: In function ‘lttng_strndup’:
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: error: implicit declaration of function ‘malloc’ [-Werror=implicit-function-declaration]
ret = malloc(navail);
^~~~~~
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: error: incompatible implicit declaration of built-in function ‘malloc’ [-Werror]
/home/smarchi/src/lttng-tools/src/common/compat/string.h:78:8: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
Note that this is in fallback code when the system doesn't provide
strndup (or, in my case, the system provides it but configure failed to
find it).
Change-Id: I5817b0b2436573b7d8fecb2956577a7b183d6296
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Thu, 30 Jan 2020 21:12:35 +0000 (16:12 -0500)]
Cleanup: remove superfluous tests.txt
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I0f9a505c5e9c22fbcebe534b9750d25645813174
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Thu, 30 Jan 2020 23:33:57 +0000 (18:33 -0500)]
fix: add include guards to compat/path.h
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ifb0672dcaf9b98715742546d71e54c5f4cd8dff6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Thu, 7 Mar 2019 19:53:45 +0000 (14:53 -0500)]
Move to kernel style SPDX license identifiers
The SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.
See https://spdx.org/ids-how for details.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Sun, 26 Jan 2020 22:21:33 +0000 (17:21 -0500)]
Sync ax_have_epoll.m4 with autoconf-archive
This updates gets rid of an unused variable warning at configure time,
so removes one hurdle to configure with CFLAGS="-Werror".
Change-Id: I7adfed3f821409d7ea36c79e19e96b1977e32804
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 21 Jan 2020 23:27:53 +0000 (18:27 -0500)]
.gitignore: ignore gen-kernel-test-events
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I668b8f9ed7066a1e10ec542773b7ab346d9c8710
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Fri, 17 Jan 2020 20:09:21 +0000 (15:09 -0500)]
Fix: lttng: sanity check of `--probe` description
Issue
=====
Run the following command:
lttng enable-event -k --probe "\do_fork" my_do_fork_event
currently fails and that is expected.
But it does not fail for the right reason. In the `parse_probe_opts()`
function, during the last step of parsing the probe description we assume
it's a raw address and pass the string directly to the `strtoul()`
function. So if the probe description is not an address at all (e.g.
"\do_fork"), the `strtoul()` call will return 0 in the `addr` field of
the probe struct. This is then passed to the kernel tracer that asks the
kernel to instrument that address with a kprobe. This fails because 0x0
is not an address that can be instrumented.
Solution
========
Check that the first character of the tentative address is a digit
before trying to convert the string to an integer. This is not perfect
but at least it prevents some errors.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I444f0e7694098b1cdb56ecbf5d92be8974e406dc
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 30 Jan 2020 17:40:08 +0000 (12:40 -0500)]
lttng-view: make babeltrace2 the default viewer
Use the `babeltrace2` binary to view traces by default rather than
the legacy `babeltrace`. As the install base of Babeltrace 2.x is
rather small at this point, silently fallback to Babeltrace 1.x
when it is not found on the system.
The man page is updated to reflect this change in behaviour.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7cd7424f8af1e25238fcc4bb1aa3ee8226da023
Jérémie Galarneau [Thu, 30 Jan 2020 17:12:45 +0000 (12:12 -0500)]
lttng-view: clean-up: remove unneeded empty line
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I358abf4e41ac248a4c422772ebdfc4ffdc7fe196
Jérémie Galarneau [Thu, 30 Jan 2020 17:10:18 +0000 (12:10 -0500)]
lttng-view: clean-up: static struct viewers array should be const
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I538bebf471eb15202908c27ab108e27f7f990103
Jérémie Galarneau [Thu, 30 Jan 2020 17:01:57 +0000 (12:01 -0500)]
lttng-view: clean-up: remove commented and unused references to lttv
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I207c1a00c37b61bd7bd76a265e17e1e4bdf53d93
Jérémie Galarneau [Thu, 30 Jan 2020 06:51:10 +0000 (01:51 -0500)]
relayd: register fd tracker instance to all created trace chunks
Provide a reference to 'the_fd_tracker' to trace chunks during their
creation. This causes file descriptors created through the relay
daemon's trace chunks to be tracked by the daemon's fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c96851ef06bb7f0be0c7f3e8b7f01638f13fbda
Jérémie Galarneau [Thu, 28 Jun 2018 05:16:56 +0000 (01:16 -0400)]
relayd: track relayd control connection sockets
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If5b0f85aac48bb04a08c95b76398b8f1b2ad98d8
Jérémie Galarneau [Thu, 28 Jun 2018 05:16:43 +0000 (01:16 -0400)]
relayd: track relayd data connection sockets
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I510f2ca49995e56735408d14562cf1d45fef842e
Jérémie Galarneau [Thu, 30 Jan 2020 06:27:16 +0000 (01:27 -0500)]
relayd: replace uses of block FDs by the fs_handle interface
Replace all usage of "raw" block-device file descriptors for
relay_streams, viewer_streams, and index files by the fs_handle.
Wrappers are introduced for read, write, seek and truncate operations
in order to reduce code duplication as all uses of fs_handles implies
getting an fd, using it, and putting it back. Those operations allow
the fd-tracker to suspend and restore fs_handles as needed.
The stream_fd util is eliminated as it is completely replaced by
the fs_handle interface.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iedff88d27aeba3891d4e8818b9e08e4b16a927cc
Jérémie Galarneau [Wed, 29 Jan 2020 04:53:49 +0000 (23:53 -0500)]
fd-tracker: restore suspended handles from their inode's path
In order to support session rotations and, to a lesser degree, the
"clear" command, the fd-tracker internals (lttng_inode and fs_handle)
need to recover from files being renamed while the handle to it is
suspended.
This refactor introduces a "location" to the lttng_inode which is
updated anytime an unlink or rename is performed on an fs_handle.
Keep in mind that multiple independent fs_handles can refer to the
same lttng_inode (a unique tuple of device id and inode number).
This location is used to restore the fs_handle whenever it is needed.
Moreover, since the session rotation/clear operations sometimes rely
on directories having been emptied after rename/unlink, the current
scheme of renaming unlinked files to the form
"filename-deleted-suffix" no longer works.
The renaming scheme is replaced by a new "unlinked file pool", which
is an hidden directory at the base of the output directory which
contains the files which were unlinked to which
references (fs_handles) are still being held. The API of the
fd-tracker itself had to be changed slightly and the tests are adapted
as a consequence. New tests targeting this new behaviour are also
added.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9b1344da1966c85bdd6b51838507d3208e1d9a42
Jérémie Galarneau [Wed, 29 Jan 2020 04:39:01 +0000 (23:39 -0500)]
directory-handle: query if instance is backed by a file descriptor
Allow a user of a directory handle to know if a given instance is
backed by a file descriptor. This is needed to ensure the fd-tracker
can accurately track the number of file descriptors in use at a given
moment.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I64aeeae2623a35ed07964432bb18b16aeeeb89ec
Jérémie Galarneau [Wed, 29 Jan 2020 04:37:49 +0000 (23:37 -0500)]
directory-handle: make lttng_directory_handle_stat public
Allow users of the directory handle API to perform stat() calls
relative to a directory handle (through statat() or stat(), depending
on the implementation).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4415da6d719999ad051678d0defd9e3edf93c19a
Jérémie Galarneau [Thu, 23 Jan 2020 22:10:32 +0000 (17:10 -0500)]
fd-tracker: replace custom optional implementation by LTTNG_OPTIONAL
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id38724f701ee8aca8f0fecf231d8d4027f0bd885
Jérémie Galarneau [Thu, 23 Jan 2020 22:09:13 +0000 (17:09 -0500)]
directory-handle: add an equals method
Add an "equals" method to both implementations of directory-handle.
The "directory fd" implementation uses the underlying inode of
the directory to perform comparisons.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c97f75ea6a79168d772268fca490aee7c333ae2
Jérémie Galarneau [Fri, 20 Dec 2019 04:49:28 +0000 (23:49 -0500)]
trace chunk: allow associating an fd_tracker to a trace chunk
Introduce lttng_trace_chunk_set_fd_tracker() which may be used
to associate an fd-tracker to a trace chunk instance. An fd-tracker
must be set before any directory handle or files are created
through the trace chunk.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5b3302e26ace2babadba286ca8bd4a016014bdd8
Jérémie Galarneau [Tue, 21 Jan 2020 00:44:07 +0000 (19:44 -0500)]
fd-tracker: refactor: extract fs_handle interface from fd_tracker
Make the fs_handle interface a proper abstract interface containing
overridable callbacks. The objective of this refactor is to make it
possible for lttng_trace_chunk to return fs_handles which are tracked
by an fd_tracker (or not) depending on the execution context (which
daemon).
In effect, the relay daemon will provide a trace chunk with an
fd_tracker to use and then rely on the fs_handle interface to track
the use of file descriptors.
The other daemons using the lttng_trace_chunk interface will use a
dummy implementation of fs_handle which basically directly returns the
underlying file descriptor and performs the unlink/close operations
directly.
This makes is possible to share code interacting with files between
the various daemons without carrying a plethora of optional parameters
in every util.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaafa0f4442442bdfdaf220ce33a966978877df23
Jérémie Galarneau [Wed, 15 Jan 2020 23:41:34 +0000 (18:41 -0500)]
fd-tracker: remove use of VLA for unsuspendable_fd APIs
fd_tracker_open_unsuspendable_fd() and
fd_tracker_close_unsuspendable_fd() make use of variable-length arrays
to track unsuspendable entries to open/close. These uses of VLA can
easily be replaced by using dynamic allocations. This is not expected
to cause any performance problem as it is used in slow paths.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4d4e95e23eb6df9a66663ecabad40162c321525b
Jérémie Galarneau [Fri, 20 Dec 2019 06:41:37 +0000 (01:41 -0500)]
relayd: share the same output directory handle accross sessions
Now that lttng_directory_handles are reference counted, they can be
shared by multiple sessions and trace chunks. These modifications
cause sessions that share a trace chunk to share their session output
directory handle.
Moreover, the session output directory handle is now created on
session creation. Hence, a directory handle (fd) is not created
everytime a trace chunk is created.
The goal of this modification is to make it easier to track file
descriptors in the relay daemon, but it is also more efficient
overall (less opening of file descriptors) and will error-out during
the creation of a session rather than a trace chunk which is handled
more gracefully accross the toolchain.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I47e46ee253db646da1490380612def741c2f4102
Jérémie Galarneau [Fri, 20 Dec 2019 05:59:56 +0000 (00:59 -0500)]
Fix: relayd: fail to create session when trace chunk is not found
When a session is created by a peer with a trace chunk id already
set, it means that the session daemon has already created that
trace chunk at some point in the past. Hence, it should be found
in the sessiond trace chunk registry.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8c6d19371d322cf7079d7a01c4c24b585b4b3ea1
Jérémie Galarneau [Wed, 27 Nov 2019 06:37:41 +0000 (01:37 -0500)]
relayd: track the health unix socket with the fd-tracker
Open the health thread's unix socket through the fd-tracker to
track it as an unsuspendable file descriptor.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9638a91f8632063ac854489927fae1681723283f
Jérémie Galarneau [Wed, 27 Nov 2019 06:36:34 +0000 (01:36 -0500)]
relayd: track the health thread's poll fd with fd-tracker
Create the health thread's lttng_poll_event structure through
the fd-tracker to track the resulting file descriptor for
builds configured to use the epoll interface.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I81ba9cbe69d885dbdade03e581a4d69572de50eb
Jérémie Galarneau [Thu, 5 Jul 2018 01:28:18 +0000 (21:28 -0400)]
LTTNG-RELAYD(8): document the --fd-pool-size option
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie8d791d15ba4186dc862d048d20afff7d128cea3
Jérémie Galarneau [Wed, 27 Nov 2019 06:11:02 +0000 (01:11 -0500)]
relayd: rename fd-cap parameter to fd-pool-size
Rename the fd-cap parameter and change its default behaviour.
The minimum number of file descriptor is raised to 100 and a
"reserve" amount of 10 fds is allowed to accomodate transient
fd uses that can't be tracked by the relay daemon.
The --fd-pool-size will accept parameters in the
[100, fileno soft limit] interval.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c7bf344344901b4d6f0d95620210ebda5fd0196
Jérémie Galarneau [Wed, 27 Nov 2019 06:01:28 +0000 (01:01 -0500)]
relayd: track the live client connections socket
Track all live client connection socket file descritptors through the
fd-tracker. Those file descriptors, being TCP connections, are
unsuspendable.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iacc958b0f8d168d13165e44ec8432ad29ef881f5
Jérémie Galarneau [Wed, 27 Nov 2019 05:57:08 +0000 (00:57 -0500)]
relayd: track the control and data listener socket
Create the control and data listener sockets through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I58e66386c195b78a44d88d3592d7b1d75ff091a3
Jérémie Galarneau [Wed, 27 Nov 2019 05:42:00 +0000 (00:42 -0500)]
relayd: track the live listener socket
Create the live listener socket through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I12c831967b0b33aa3d58c2319cdaf0dc3ccda7e3
Jérémie Galarneau [Wed, 27 Nov 2019 05:32:24 +0000 (00:32 -0500)]
relayd: track stdio output file descriptors
Track the stdout and stderr file descriptors through the fd
tracker. These file descriptors are considered unsuspendable
since they can't be re-opened.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibd80fb1ba1b21ee152bae6047a5dd176d1d2c051
Jérémie Galarneau [Wed, 27 Nov 2019 05:30:24 +0000 (00:30 -0500)]
relayd: track the live viewer worker thread's epoll fd
Create the live worker threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I60b386b90e274283c566d94cfd4abcf57e0c1985
Jérémie Galarneau [Wed, 27 Nov 2019 05:28:51 +0000 (00:28 -0500)]
relayd: track the live listener thread's epoll fd
Create the live listener threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If93fe5b1cc85d5d3950941edd47910697727ced9
Jérémie Galarneau [Wed, 27 Nov 2019 05:23:15 +0000 (00:23 -0500)]
relayd: track the live_conn_pipe with the fd-tracker
Create the relayd live connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.
The close of the pipe is also performed through the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I967c2fbecfb5dacfb8c41cad113604bad78dad65
Jérémie Galarneau [Tue, 26 Nov 2019 23:22:29 +0000 (18:22 -0500)]
relayd: track listener's epoll fd using the fd-tracker
This addresses the bogus fd report mentionned in a previous patch of
this series as the clean-up of the listener thread's epoll fd now
occurs through the fd-tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I56bdc7f0f7c43993e44bcfc220bc09af561ace56
Jérémie Galarneau [Tue, 26 Nov 2019 23:14:57 +0000 (18:14 -0500)]
relayd: track worker thread's epoll fd using the fd-tracker
This commit introduces an fd leak report (bogus) which is caused
by another thread using the same poll initialization functions as
the worker thread.
The fd is cleaned-up by that other thread, but the fd-tracker
is not aware of this, thus causing the report.
This is adressed in a follow-up patch.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I105fddcf3421373f9746c1d8f31016462af2448e
Jérémie Galarneau [Tue, 26 Nov 2019 23:20:35 +0000 (18:20 -0500)]
relayd: track clients of the health unix socket with the fd-tracker
accept connections to the health unix socket through a new fd-tracker
wrapper, accept_unix_socket, which allows the fd-tracker to track the
newly-created file descriptor.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d58b7fab15451cae404b13fd5d4b23a7c79988a
Jérémie Galarneau [Tue, 26 Nov 2019 22:10:02 +0000 (17:10 -0500)]
relayd: track the health quit pipe with the fd-tracker
Create the relayd health thread quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.
The close of the pipe is also performed through the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib82eabc0f152a706ac76a5042af2e3984d7e7f72
Jérémie Galarneau [Tue, 26 Nov 2019 22:07:41 +0000 (17:07 -0500)]
relayd: track the relay_conn_pipe with the fd-tracker
Create the relayd connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.
The close of the pipe is also performed through the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6ed0d64c973a454de2e50c7cae006fd546299290
Jérémie Galarneau [Tue, 26 Nov 2019 22:08:52 +0000 (17:08 -0500)]
relayd: track the quit pipe with the fd-tracker
Create the relayd quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.
The close of the pipe is also performed through the fd tracker.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2a000030765e8df990e0ea3d35a8bf157630d9f
Jérémie Galarneau [Tue, 26 Nov 2019 20:41:26 +0000 (15:41 -0500)]
relayd: Don't bypass the fd tracker when closing file descriptors
There is no reason to close all file descriptors at this point in the
relay daemon as we know for a fact that the only open fds are stdout
and stderr. If the relayd was to depend on a library that opens other
file descriptors, it would be unadvisable to perform this kind of bulk
closing of all possible file descriptors.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8ff134094b16dfb6c1aeb875431fdbd4f608eebd
Jérémie Galarneau [Tue, 26 Nov 2019 20:15:33 +0000 (15:15 -0500)]
relayd: initialize the global fd tracker from fd_cap option
Initialize the relay daemon's global fd tracker from the current
fd-cap configuration. This is in preparation for follow-up patches
which will introduce the tracking of the various file descriptor
backed resources to the relay daemon.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaabb80f1fb4d24345b750503c90388f94025159d
Jérémie Galarneau [Wed, 27 Nov 2019 18:20:32 +0000 (13:20 -0500)]
relayd: clean-up: reduce the number of exit paths in main()
The relay daemons's initialization and teardown relies on a large
number of goto/labels to clean-up on failure to launch.
All of the clean-up can be performed unconditionally by checking for
NULL or uninitialized file descriptors in relayd_cleanup(). This
reduces the number of possible tear-down paths and partly initialized
state to keep track of.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3195caf05b3dd04cc7e9c60dcb322261159fe0df
Jérémie Galarneau [Tue, 26 Nov 2019 20:08:01 +0000 (15:08 -0500)]
relayd: add fd-cap option to limit the number of opened FDs
Add an --fd-cap option to the relay daemon in order to allow the
launch of the relay daemon with a maximal number of file descriptors
to be open at any given moment.
When the value of the --fd-cap parameter is left unset, the maximal
number of file descriptors is set to the system's NOFILE soft limit
(see GETRLIMIT(3P)).
A minimal number of file descriptors of 30 is imposed, mainly to
prevent absurd configurations (someone setting 1 fd) which would not
even allow one target to connect and stream traces. This also allows
a bit of leverage to open file descriptors that could be needed by
future changes without "breaking" an existing configuration.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibaf49b25ccf3e3a8013115c9478744ca3646e306
Jonathan Rajotte [Tue, 21 Jan 2020 19:23:07 +0000 (14:23 -0500)]
Fix: use lttng_tracker_id_status enum values
This is probably a copy paste error. This should not be a problem in any
case since the final values for both enums are the same.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ia1dc173a4eae8b7d9bff35a718c93331b714f5d6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Christophe Bedard [Sat, 18 Jan 2020 19:29:49 +0000 (14:29 -0500)]
Fix: update context types for Python bindings
Fixes: #1214
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Fri, 17 Jan 2020 17:45:51 +0000 (12:45 -0500)]
Fix: lttng: placing probe on symbol starting with `_`
Issue
=====
The lttng CLI tool does not parse `--probe` symbol name properly if the
name has an underscore at the beginning.
For example, the following command fails
lttng enable-event -k --probe _do_fork my_do_fork_event
This happens because the `parse_probe_opts()` function looks if the
first character of the symbol field is an alphabetic character to
determine if a symbol was provided. The problem is that some kernel
symbols such as `_do_fork` start with an underscore.
Solution
========
check if the first character is an alphabetic character OR an
underscore.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3ee6c26641ceee508ee78e895d372c6b09fe90fb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Thu, 16 Jan 2020 19:34:47 +0000 (14:34 -0500)]
Fix: build failure with -fno-common
GCC 10 will default to building with -fno-common, this inhibits the
linker from merging multiple tentative definitions of a symbol in an
archive.
I'm not sure I understand what happen with the symbols in mi-lttng.h
but a similar issue was adressed in:
commit
4965f956f3ef47388fb4a1b2f8f504abfe31afe7
Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Date: Fri May 22 12:53:30 2015 -0400
Fix: Mark MI and Config string declarations as extern
This fixes a build issue with GCC 5.1 which would complain about
these symbols being defined multiple times.
Make sure these symbols are extern and defined only in one compile unit.
For more information, see:
https://gcc.gnu.org/gcc-10/porting_to.html
Change-Id: I139c9695371836cb1011f9ce192080b602ed2fbc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Thu, 16 Jan 2020 01:52:39 +0000 (20:52 -0500)]
Fix: Tests: missing stream redirect causes test failure
The following commit enforced the use of options (instead of arguments)
in the `gen-ust-events` test application:
commit
6c4a91d639747f260ab46decebc50998ef063712
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: Mon Aug 26 14:22:06 2019 -0400
tests: gen-ust-events: use options instead of arguments
This makes tests exit (and abort since commit
56d4838) when arguments
are passed to the test application. It currently fails with the
following error:
./gen-ust-events -i 32 -w 21 \
--sync-after-first-event /tmp/allo.hi \
--sync-before-last-event /tmp/allo.bye /dev/null
Error: takes long options only.
zsh: abort (core dumped) ./gen-ust-events -i 32 -w 21 --sync-after-first-event /tmp/allo.hi
The `/dev/null` at the end of the command line is not associated with an
option so it triggers the sanity check. The `/dev/null` most probably
meant to redirect STDOUT to `/dev/null`.
This commit adds the missing `>` so to overcome the sanity check
problem.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3e4d4066079055a542438a63ef4df5c5c4c080cf
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Mon, 13 Jan 2020 20:40:15 +0000 (15:40 -0500)]
Fix: automatic enum value overwrites existing error code value
Automatic enum value are generated using the last value and
incrementing it. Having backward compat assignation before the
LTTNG_ERR_NR would end up overwriting the error string since the
LTTNG_ERR_NR value would be LTTNG_ERR_PID_NOT_TRACKED + 1.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I4076866a28961fa49eed018e8249d2cd72979a84
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.049604 seconds and 4 git commands to generate.