lttng-tools.git
5 years agoBackport: lttng_snapshot_add_output_ok: let the caller specify the output type
Jonathan Rajotte [Fri, 22 Jun 2018 17:51:58 +0000 (13:51 -0400)] 
Backport: lttng_snapshot_add_output_ok: let the caller specify the output type

Also add support for additional options.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Relayd: introduce --group-output-by-session
Jonathan Rajotte [Tue, 19 Jun 2018 02:46:25 +0000 (22:46 -0400)] 
Backport: Relayd: introduce --group-output-by-session

LTTng-relayd now support the grouping of trace data per session name.
This mode can be used via the "--group-output-per-session"

The default, and current way, of grouping is done around the hostname of
the traced system.

When grouped by host the following folder hierarchy is mostly found on the filesystem:

    <hostname>/<session_name>[-<datetime>]/<trace>

When using "--group-output-per-session", the following hierarchy is
found on the filesystem:

    <session_name>/<hostname>[-<datetime>]/<trace>

The datetime is not always present given how it is generated in certain
situations either on the client (cli) or in lttng-sessiond and specified
output type.

This commit ensure maximum compatibility with all lttng-relayd client
(lttng-consumerd) version.

Further work can be accomplished on the
client (cli), lttng-sessiond, lttng-consumerd to pass individual path
information: session name, datetime and hostname. Note that the
automatic naming can be problematic since the datetime is used inside
the session name while when using a defined session name it is not part
of the session name. Still, this would leave older lttng-relayd client
version in the dark given that such modification would require
communication API changes. The current solution ensure that even when
dealing with older client the grouping option is respected.

The received paths are tokenized in 3 tokens.

The first one is the hostname. This is respected across all
communications. Note that, the hostname is already known since the
create session command (version >= 2.4).

The second one can either be a session name, with or without a datetime,
or extra path information. The extra path information come from the URIs
set at the client level:

    lttng create --set-url=net://localhost/extra/path/information

When the second token is extra path information the session name is
never present in the path. We reuse the name passed on the create
session command (version >= 2.4).

The datetime, if present, is extracted from the session name passed by
the client or if not present from the session name passed by the create
session command. This enable the support of automatic session name.

The third one is the rest of the path. No information extraction is done
on this token.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Doc: lttng-relayd: --working-directory option
Jonathan Rajotte [Tue, 22 May 2018 18:25:32 +0000 (14:25 -0400)] 
Backport: Doc: lttng-relayd: --working-directory option

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Introduce LTTNG_RELAYD_WORKING_DIRECTORY environment variable
Jonathan Rajotte [Tue, 22 May 2018 17:48:07 +0000 (13:48 -0400)] 
Backport: Introduce LTTNG_RELAYD_WORKING_DIRECTORY environment variable

LTTNG_RELAYD_WORKING_DIRECTORY is equivalent to the --working-directory
command line options.

Note: when using --working-directory, the command line option always
overwrite the environment configuration, LTTNG_RELAYD_WORKING_DIRECTORY
in this case.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Test: lttng-relayd working directory
Jonathan Rajotte [Fri, 18 May 2018 20:24:04 +0000 (16:24 -0400)] 
Backport: Test: lttng-relayd working directory

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Add --working-directory options to lttng-relayd
Jonathan Rajotte [Wed, 16 May 2018 22:24:01 +0000 (18:24 -0400)] 
Backport: Add --working-directory options to lttng-relayd

Base version

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Cleanup relayd socket pair on control socket transmission error
Jonathan Rajotte [Wed, 6 Jun 2018 01:00:28 +0000 (21:00 -0400)] 
Backport: Cleanup relayd socket pair on control socket transmission error

A reference to the local ctx for the socket pair is used to "force" an
evaluation of the data and metadata stream since we changed the endpoint
status. This mostly result in the closing of all the streams for which
the relayd socket pair is linked to.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoBackport: Fix: relayd streams can be leaked on connection error
Jérémie Galarneau [Wed, 21 Feb 2018 05:57:26 +0000 (00:57 -0500)] 
Backport: Fix: relayd streams can be leaked on connection error

There are cases where a connection error can cause streams to be
leaked.

For instance, the control connection could receive an index and
close. Since a packet is in-flight, the stream corresponding to
that index will not close. However, nothing guarantees that
the data connection will be able to receive the packet's data.

If the protocol is respected, this is not a problem. However,
a buggy consumerd or network errors can cause the streams to
remain in the "data in-flight" state and never close.

To mitigate a case observed in the field where a consumerd
would be forcibly closed (network interface brought down) and
cause leaks on the relay daemon, the session is aborted whenever
the control or data connection encounters an error. Aborting
a session causes the streams to be closed regardless of the
fact that data is in-flight.

Currently, only the control connection holds an ownership of
the session object. This can cause the following scenario to leak
streams:

1) Control connection receives an index
  - Stream is put in "in-flight data" mode
2) Control connection is closed/shutdown cleanly
  - try_stream_close refuses to close the stream as data is in-flight,
    but it puts the stream in "closed" mode. When the data is
    received, the stream will be closed as soon as possible.
3) Data connection closes cleanly or due to an error
  - The stream "closing" condition will never be re-evaluated.

Since the data connection has no ownership of the session, it can
never clean-up the streams that are waiting for "in-flight" data to
arrive before closing.

This patch lazily associates the data connection to its session
so that the session can be aborted whenever an error happens on
either the data or control connection.

Note that this leaves the relayd vulnerable to a case which will
still leak. If the control connection receives an index and closes
cleanly, the data connection could have never been established
with the consumer daemon and result in a leak.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoBackport: Port dynamic buffer to stable 2.9
Michael Jeanson [Fri, 27 Apr 2018 21:27:29 +0000 (17:27 -0400)] 
Backport: Port dynamic buffer to stable 2.9

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 years agoUpdate version to v2.9.10
Jérémie Galarneau [Tue, 24 Jul 2018 00:19:29 +0000 (20:19 -0400)] 
Update version to v2.9.10

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: missing context enum values in session xml schema
Francis Deslauriers [Tue, 5 Jun 2018 14:57:48 +0000 (10:57 -0400)] 
Fix: missing context enum values in session xml schema

    Handling of the following enum are added:
        LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
        LTTNG_EVENT_CONTEXT_PREEMPTIBLE
        LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
        LTTNG_EVENT_CONTEXT_MIGRATABLE

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTests: add session auto-loading test cases
Anders Wallin [Thu, 17 May 2018 20:50:41 +0000 (22:50 +0200)] 
Tests: add session auto-loading test cases

lttng-sessiond can auto load sessions at startup;
- with "--load" option to lttng-sessiond, load one file
  or all sessions files in that directory
- from session files in $LTTNG_HOME/.lttng/sessions/auto/
- from session files in $sysconfdir/lttng/sessions/auto

This test case validates the two first scenarios.

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoBash completion: ignore namespace for xmllint parsing
Jonathan Rajotte [Mon, 28 May 2018 21:31:48 +0000 (17:31 -0400)] 
Bash completion: ignore namespace for xmllint parsing

xmllint cli does not "easily" support namespace.

One can use the local_name() xpath function and other "trick".
The simplest trick for bash completion is to ignore the namespace
altogether.

Replacing "xmlns" by "ignore" does the job.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoTypo in ust consumer log message (channek -> channel)
Jérémie Galarneau [Mon, 4 Jun 2018 21:28:56 +0000 (17:28 -0400)] 
Typo in ust consumer log message (channek -> channel)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: use signed variable for refcounting of consumer_relayd_sock_pair
Jonathan Rajotte [Wed, 14 Mar 2018 18:54:21 +0000 (14:54 -0400)] 
Fix: use signed variable for refcounting of consumer_relayd_sock_pair

Otherwise refcount check after decreasing have no meaning as in
consumer_stream_relayd_close function.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: warning due to hash_key_str() being not const-correct
Jérémie Galarneau [Wed, 30 May 2018 22:09:19 +0000 (18:09 -0400)] 
Fix: warning due to hash_key_str() being not const-correct

Hash table utils do not enforce const-correct in lttng-tools prior
to 2.11. This results in a warning when pasing a const argument
to those utilities.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: calling ht_{hash, match}_enum with wrong argument
Francis Deslauriers [Fri, 9 Feb 2018 21:56:49 +0000 (16:56 -0500)] 
Fix: calling ht_{hash, match}_enum with wrong argument

ht_hash_enum and ht_match_enum are currently called with the address of the
pointer to a ust_registry_enum rather than the expected pointer to a
ust_registry_enum. This means that those function calls would end up
using garbage for hashing and comparing.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: probes should be compared strictly by events metadata
Francis Deslauriers [Fri, 9 Feb 2018 21:56:48 +0000 (16:56 -0500)] 
Fix: probes should be compared strictly by events metadata

Currently, events are compared using names and signatures. Events
with different payloads but identical name and signatures could
lead to corrupted trace because the Session Daemon would consider them
identical and give them the same event ID.

Events should be compared using the name, loglevel, fields and
model_emf_uri to ensure that their respective metadata is the same.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: test_ust-dl is generated at configure-time
Francis Deslauriers [Tue, 6 Feb 2018 17:04:27 +0000 (12:04 -0500)] 
Fix: test_ust-dl is generated at configure-time

This file should not be in EXTRA_DIST as it's generated by autoconf and
will thus be available directly in the out-of-tree build directory.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: perform the initialization memory barrier out of loop body
Jérémie Galarneau [Fri, 18 May 2018 19:08:14 +0000 (15:08 -0400)] 
Fix: perform the initialization memory barrier out of loop body

The memory barrier used by the client thread should be performed
after the lttng_sessiond_ready counter has been seen to have
reached zero.

This ensures that loads are not speculatively performed before
this point as the thread will interact with data structures
initialized by the support threads for which it was waiting for
the initialization to complete.

See the comment as to why this read barrier is promoted to a
full barrier.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoPort: fix format warnings on Cygwin
Michael Jeanson [Tue, 15 May 2018 20:19:49 +0000 (16:19 -0400)] 
Port: fix format warnings on Cygwin

On Cygwin, be64toh() returns a "long long unsigned int" while the
format specifier PRIu64 expects a "long unsigned int". Both types
are 64bits integers, just cast the result to uint64_t to silence
the warnings.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: don't wait for the load thread before serving client commands
Jérémie Galarneau [Wed, 16 May 2018 21:08:36 +0000 (17:08 -0400)] 
Fix: don't wait for the load thread before serving client commands

Since the session loading thread uses the same communication than
the external clients, it should not be included in the set of
threads that must be launched before the sessiond starts to serve
client commands.

Since the "load session" thread is guaranteed to be the last
essential thread to be initialized, it can explicitly signal
the parents that the sessiond is ready once it is done auto-loading
session configurations.

This commit also adds a lengthy comment explaining the initialization
of the session daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: sessiond fails to launch on --without-ust configuration
Jérémie Galarneau [Wed, 9 May 2018 01:26:15 +0000 (21:26 -0400)] 
Fix: sessiond fails to launch on --without-ust configuration

The sessiond will never signal that it is ready (in daemonize or
background modes) if it was built without lttng-ust. The fix in
7eac7803 made the main thread wait for the agent thread to be
ready before signalling that the session daemon is ready.

When agent tracing is not possible due to the absence of lttng-ust,
a stub function is used to launch the agent thread. This stub
must call sessiond_notify_ready() in order to unblock the main
thread.

Note that it would be _incorrect_ to not wait for the agent
thread to be launched as users expect all tracing features to
be available as soon as 'lttng-sessiond --daemonize/--background'
returns.

Not waiting for the thread to be ready caused very rare failures
of the agent tracing tests on the CI, especially on ARM and
PowerPC targets.

Reported-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: agent thread poll set creation failure results in deadlock
Jérémie Galarneau [Wed, 9 May 2018 01:23:14 +0000 (21:23 -0400)] 
Fix: agent thread poll set creation failure results in deadlock

Failing to initialize the agent thread's pollset will cause
the thread to exit before calling sessiond_notify_ready().

This will cause the main thread to wait forever for all threads
to be launched when such an error occurs.

The agent thread is not needed for the sessiond to work (except
to enable the tracing of Java and Python applications). Such
a failure should leave the sessiond in a useable state.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: test uses sizeof() on the wrong operand of strncpy
Jérémie Galarneau [Wed, 9 May 2018 01:22:36 +0000 (21:22 -0400)] 
Fix: test uses sizeof() on the wrong operand of strncpy

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoUpdate version to v2.9.9
Jérémie Galarneau [Mon, 30 Apr 2018 17:50:02 +0000 (13:50 -0400)] 
Update version to v2.9.9

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoAdd DBG statement for TCP keep-alive options
Jonathan Rajotte [Mon, 9 Apr 2018 14:23:33 +0000 (10:23 -0400)] 
Add DBG statement for TCP keep-alive options

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: failure to launch agent thread is not reported
Jérémie Galarneau [Mon, 23 Apr 2018 23:03:16 +0000 (19:03 -0400)] 
Fix: failure to launch agent thread is not reported

A session daemon may fail to launch its agent thread. In such
a case, the tracing of agent domains fails silently as events
never get enabled through the agent.

The problem that was reported was caused by a second session
daemon being already bound on the agent TCP socket port, which
prevented the launch of the agent thread.

While in this situation tracing is still not possible, the user
will at least get an error indicating as such when enabling
an event in those domains.

Reported-by: Deborah Barnard <starfallprojects@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: agent may not be ready on launch
Jérémie Galarneau [Mon, 23 Apr 2018 20:36:25 +0000 (16:36 -0400)] 
Fix: agent may not be ready on launch

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: lttng logs nanoseconds
Julien Desfossez [Fri, 10 Nov 2017 21:21:46 +0000 (16:21 -0500)] 
Fix: lttng logs nanoseconds

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: stream_per_chan_id_ht should allow duplicates
Julien Desfossez [Fri, 10 Nov 2017 21:22:13 +0000 (16:22 -0500)] 
Fix: stream_per_chan_id_ht should allow duplicates

Fixes: #1134
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: relayd send_command() util not logging on failure
Jérémie Galarneau [Tue, 6 Mar 2018 16:35:23 +0000 (11:35 -0500)] 
Fix: relayd send_command() util not logging on failure

send_command() only logs if it succeeds in sending a command to
the relay daemon.

This commit makes the helper log _before_ sending the command
so that errors can be associated back to the command being sent.
Moreover, PERROR() is used to log errors returned by sendmsg().

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix: kernel snapshot handling of EAGAIN
Julien Desfossez [Mon, 11 Dec 2017 21:11:09 +0000 (16:11 -0500)] 
Fix: kernel snapshot handling of EAGAIN

kernctl_snapshot can return EAGAIN, this is not an error, it only means
there is no data to read.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 years agoFix validate_trace_empty test check
Julien Desfossez [Thu, 21 Dec 2017 20:28:56 +0000 (15:28 -0500)] 
Fix validate_trace_empty test check

Since the output of babeltrace was directly piped into wc, the return
code was never an error even if the trace was invalid. We now split the
commands in two parts: process the trace with babeltrace and check the
error code, and then count the number of lines.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: hold consumer socket lock for consumer_send_msg
Jonathan Rajotte [Tue, 10 Apr 2018 17:56:47 +0000 (13:56 -0400)] 
Fix: hold consumer socket lock for consumer_send_msg

The lock is held and released during the recv() section, but not
during the send section for a failure to lookup the PID registry.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: use off_t type for lseek function return value to avoid overflow
Gregory LEOCADIE [Thu, 29 Mar 2018 10:52:30 +0000 (12:52 +0200)] 
Fix: use off_t type for lseek function return value to avoid overflow

Context: LTTng is configured in live mode with only one channel, getting
traces for a long-running application (days of uptime)

The trace file gets bigger (many GBs), so the offset (bigger than
int.MaxValue). When getting a packet for such offset, the lseek returns
bigger than int.MaxValue. This value is stored in a variable "ret" of
type int. We have an overflow which leads to sending an error to the
viewer (babeltrace), which stops.
[error] get_data_packet: error.
[error] get_data_packet failed
[error] Unknown return code 0

Signed-off-by: Gregory LEOCADIE <g.leocadie@criteo.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoUpdate version to v2.9.8
Jérémie Galarneau [Mon, 26 Mar 2018 15:36:04 +0000 (11:36 -0400)] 
Update version to v2.9.8

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: set errno with value from SO_ERROR on error.
Jonathan Rajotte [Wed, 21 Feb 2018 03:06:31 +0000 (22:06 -0500)] 
Fix: set errno with value from SO_ERROR on error.

Debugging output at the same time in case of asynchronous handling.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: missing value handling for lttng_event_context_type
Jonathan Rajotte [Mon, 26 Feb 2018 21:03:02 +0000 (16:03 -0500)] 
Fix: missing value handling for lttng_event_context_type

Handling of the following enum are added:
    LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
    LTTNG_EVENT_CONTEXT_PREEMPTIBLE
    LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
    LTTNG_EVENT_CONTEXT_MIGRATABLE

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: Use SOL_SOCKET level for SO_KEEPALIVE on all platform
Jonathan Rajotte [Wed, 21 Feb 2018 21:59:54 +0000 (16:59 -0500)] 
Fix: Use SOL_SOCKET level for SO_KEEPALIVE on all platform

On Linux, COMPAT_SOCKET_LEVEL was set to SOL_TCP instead
of SOL_SOCKET, this resulted in execution of:
    setsockopt(..., SOL_TCP, TCP_DEFER_ACCEPT, ...)

Instead of:
    setsockopt(..., SOL_SOCKET, SO_KEEPALIVE, ...)

Hence, TCP keep alive was not enabled.

COMPAT_SOCKET_LEVEL is not needed. All platforms supported use the
SOL_SOCKET level for SO_KEEPALIVE.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: error out on leftover arguments
Julien Desfossez [Wed, 21 Feb 2018 21:57:36 +0000 (16:57 -0500)] 
Fix: error out on leftover arguments

All the commands currently ignore leftover arguments, this can lead to
wrong usage of the commands and waste of time debugging. For example,
this command enables the vpid context on all channels instead of only on
the "mychan" channel:
$ lttng add-context -u mychan -t vpid

The correct usage is:
$ lttng add-context -u -c mychan -t vpid

We now output an error on leftover arguments:
$ lttng add-context -u mychan -t vpid
Error: Unknown argument: mychan
Error: Command error

Some commands accept one leftover argument (create, start, stop,
destroy), so we check if there are other leftovers:
$ lttng create mysess allo
Error: Unknown argument: allo
Error: Command error

Only the snapshot command is not handled since it has a second level of
command and does not consume the popt arguments.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: reply to version check even on protocol mismatch
Julien Desfossez [Wed, 14 Feb 2018 21:32:45 +0000 (16:32 -0500)] 
Fix: reply to version check even on protocol mismatch

In the relay, we currently put() the connection when we detect that
the major version from the session daemon is not compatible. We don't
reply to the version check message. The relay still holds a reference
on the connection so it is not closed and the session daemon is left
blocking in recvmsg.

The relay now replies to the version check so the session daemon knows
it is not compatible, and the relay completely closes the connection on
its side and removes the FD from the poll set.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: error handling on relay version check
Julien Desfossez [Wed, 14 Feb 2018 21:32:44 +0000 (16:32 -0500)] 
Fix: error handling on relay version check

If a network error occurs while performing the version check between
the session daemon and the relay, we should not report to the user that
there is a version mismatch. LTTNG_ERR_RELAYD_VERSION_FAIL is now
returned by relayd_version_check() when the daemons are not compatible
while a negative value is returned if sendmsg()/recvmsg() fail on
network errors.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoDocument add-context limitation for started session
Jonathan Rajotte [Mon, 5 Feb 2018 23:19:01 +0000 (18:19 -0500)] 
Document add-context limitation for started session

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: add-context cannot be performed after a session has been started
Jonathan Rajotte [Mon, 5 Feb 2018 23:19:00 +0000 (18:19 -0500)] 
Fix: add-context cannot be performed after a session has been started

The following scenario lead to a corrupted trace/metadata layout problem:
  - lttng create test
  - lttng enable-channel -u test
  - lttng enable-event -u -a -c test
  - lttng start
  - ./instrumented-application
  - lttng stop
  - lttng add-context -u -t procname -c test
  - lttng start
  - ./instrumented-application
  - lttng stop
  - lttng view

Babeltrace 1.5.x will fail with:

[error] Unexpected end of packet. Either the trace data stream is corrupted or metadata description does not match data layout.
[error] Reading event failed.
Error printing trace.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: duplicated kernel consumer socket locking
Francis Deslauriers [Fri, 16 Feb 2018 19:48:49 +0000 (14:48 -0500)] 
Fix: duplicated kernel consumer socket locking

Commit 9d1103e introduced a bug causing a deadlock on snapshot record.
Function consumer_snapshot_channel is called with the lock held causing
the pthread_mutex_lock call inside to hang forever.

Because consumer_snapshot_channel now acquires the lock before using the
socket. No need to acquire the lock before calling the function.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: remove unused event types in MI XML schema
Francis Deslauriers [Wed, 13 Dec 2017 17:08:34 +0000 (12:08 -0500)] 
Fix: remove unused event types in MI XML schema

KPROBE and KRETPROBE event types are never produced by the MI output,
PROBE and FUNCTION are rightfully used. Using KPROBE and KRETPROBE would
be exposing the inner workings of the kernel tracer that should be
abstracted to the user.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoTests: cleanly exit from test apps on reception of SIGTERM
Jérémie Galarneau [Thu, 15 Feb 2018 16:53:17 +0000 (11:53 -0500)] 
Tests: cleanly exit from test apps on reception of SIGTERM

There is a known lttng-ust limitation that can cause a buffer
to become unreadable if an application is killed or preempted
indefinitely between the reserve and commit operations in
while trying to record to a subbuffer.

A buffer being unreadable will cause some tests to fail since
events that are expected to be visible in a given stream
may not be shown by the trace viewers as the consumer was
unable to "get" that subbuffer.

It was fairly easy to reproduce this failure scenario using
the test_ust_fast snapshot test, in the "post_mortem" case.

This test case performs the following sequence of operations:

* setup a tracing session in snapshot mode
* launch an app
* kill(1) it after one event is known to have been produced
* record a snapshot
* try to read the resulting snapshot

Adding logging allowed the confirmation that the "get"
operation was indeed failing on the subbuffer to which the
application had run. This resulted in an empty stream
(file size == 0) being produced by the snapshot record operation.
The test was then failing because babeltrace reported that no
events were contained in the resulting trace.

Since there are no concrete solution to this limitation yet,
the test suite must ensure that the applications exit cleanly
on reception of a signal.

This patch introduces a SIGTERM signal handler in the test
applications which sets a "should_quit" flag to 1 and is
tested between every iteration of their event production loop.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoDocument consumer socket locking assumptions
Jérémie Galarneau [Wed, 14 Feb 2018 22:44:05 +0000 (17:44 -0500)] 
Document consumer socket locking assumptions

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: consumer socket lock not held during snapshot record
Jérémie Galarneau [Wed, 14 Feb 2018 21:13:51 +0000 (16:13 -0500)] 
Fix: consumer socket lock not held during snapshot record

This missing lock was identified while stress-testing the
snapshot tracing mode.

The "post_mortem" test case would sometimes hang on a
push_metadata() call waiting for a status reply from the
consumer daemon.

This test demonstrated a race that consists in killing an
application and taking a snapshot near-simultaneously.

This causes the app management thread to issue a "push metadata"
command to the consumerd while the lttng client is issuing
a snapshot record command.

Since the snapshot record does not acquire the consumer socket lock,
the "push metadata" and "snapshot" commands end-up mixed-up on
the socket which ultimately causes the "apps management" thread
to wait for a reply forever while holding the socket's lock.

This prevents the client, invoked by the test script, from
completing the "stop" operation on the session.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: set_relayd_for_snapshot does not acquire the consumer socket lock
Jérémie Galarneau [Wed, 14 Feb 2018 21:05:18 +0000 (16:05 -0500)] 
Fix: set_relayd_for_snapshot does not acquire the consumer socket lock

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoDocument the locking assumptions of consumerd-relayd socket passing
Jérémie Galarneau [Wed, 14 Feb 2018 21:04:33 +0000 (16:04 -0500)] 
Document the locking assumptions of consumerd-relayd socket passing

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoAssert that the consumer lock is held while sending FDs to consumerd
Jérémie Galarneau [Wed, 14 Feb 2018 21:14:21 +0000 (16:14 -0500)] 
Assert that the consumer lock is held while sending FDs to consumerd

The consumer_data lock must be held during the communications
between the consumerd and sessiond.

The consumer_data lock is refered-to by each consumer_socket
instance; they point to their consumer's global data lock.

The lock can't be taken in consumer_send_msg() or consumer_send_fds()
since we want to protect a complete "transaction". Some commands
require both functions to be called and we want to hold the lock
over the duration of both calls to protect against other
threads initiating a communication between the two calls.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoAssert that the consumer socket lock is taken during communication
Jérémie Galarneau [Wed, 14 Feb 2018 19:59:35 +0000 (14:59 -0500)] 
Assert that the consumer socket lock is taken during communication

The consumer_data lock must be acquired during any communication
between the session and consumer daemons.

Stress tests have shown a number of deadlocks that have been
traced down to this type of errors.

Individual fixes follow this commit.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoTests: refuse to run test suite if lttng processes are present
Jérémie Galarneau [Fri, 9 Feb 2018 21:40:39 +0000 (16:40 -0500)] 
Tests: refuse to run test suite if lttng processes are present

The test suite often fails because of unclean environments where
stale LTTng processes are left running. Since the test suite
assumes that no LTTng process (daemons and test applications) are
running, it makes sense to force the user to kill all those
processes before running the test suite.

The warn_processes.sh script now prints an error and returns 1
to indicate an early failure to the test harness.

It is possible to circumvent this check by invoking the tests
manually or by removing the "exit 1" from the warn_processes.sh
script if there is a need to have persistent processes across
the execution of the test suite.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: metadata channel leak when using the snapshot tracing mode
Jérémie Galarneau [Thu, 8 Feb 2018 23:25:55 +0000 (18:25 -0500)] 
Fix: metadata channel leak when using the snapshot tracing mode

While running stress tests involving the snapshot mode, it
becomes apparent that the lttng-consumerd leaks a number of file
descriptors.

To isolate the problem, the test was narrowed down to

* Create a session in snapshot mode
* Enable a userspace channel
* Enable all userspace events
* Start tracing
* Run a traced application
* Stop tracing
* Destroy session

This has shown that 5 file descriptors were leaked on each
iteration of the above.

As the comments in this change indicate, the ownership and
lifetime of metadata channels varies depending on the tracing
mode being used.

In non-snapshot tracing modes, metadata channels are owned by
their respective streams. On destruction of a metadata stream,
consumer_del_channel() is invoked since the stream releases its
ownership of the metadata channel.

However, this relationship between metadata streams and channels
does not exist in snapshot mode; streams are created and
destroyed on every snapshot record. Hence, the
LTTNG_CONSUMER_CLOSE_METADATA command must immediately clean the
metadata channel.

The channel's "monitor" flag is used to determine whether or not
the metadata channel is in "snapshot" mode or not.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoUpdate version to v2.9.7
Jérémie Galarneau [Mon, 5 Feb 2018 20:41:50 +0000 (15:41 -0500)] 
Update version to v2.9.7

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: do not flag consumer as disabled on relayd comm failure
Jonathan Rajotte [Thu, 25 Jan 2018 23:57:27 +0000 (18:57 -0500)] 
Fix: do not flag consumer as disabled on relayd comm failure

A relay daemon may be temporarily unavailable (e.g. not launched yet,
or simply a network error). In such a case, it is not necessary to
mark the consumer as bad since the error is not related to the
consumer daemon itself.

This change lets the user try to create a channel later without
having to restart the session and consumer daemons.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: cleanup inactive FDs in the consumer polling thread
Julien Desfossez [Thu, 1 Feb 2018 19:27:05 +0000 (14:27 -0500)] 
Fix: cleanup inactive FDs in the consumer polling thread

Users have reported assert() hitting on consumerd shutdown on a
non-empty data stream hash table.

Relevant stack trace:
[...] in lttng_ht_destroy (ht=0x6) at hashtable.c:162
[...] in lttng_consumer_cleanup () at consumer.c:1207
[...] in main ([...]) at lttng-consumerd.c:625

This is reproducible when a consumerd is shutting down at the same
time as one of its relay daemon peers.

On failure to reach a relay daemon, all of that relay daemons'
associated streams are marked as having an inactive endpoint (see
cleanup_relayd(), consumer.c:467). The data polling thread is notified
of the change through an empty message on the "data" pipe.

Before blocking on the next poll(), the data polling thread checks if
it needs to update its poll set using the "need_update" flag. This
flag is set anytime a stream is added or deleted.

While building a new poll set, streams that are now marked as inactive
or as having an inactive endpoint are not included in the new poll
set. Those inactive streams are in a transitional state, awaiting
a clean-up.

After updating the poll set, the data polling thread checks if it
should quit (via the consumer_quit flag). Assuming this flag is set,
the thread cannot simply exit; it must clean-up any remaining data
stream.

The thread currently performs this check at consumer.c:2532. This
check is erroneous as it assumes that the number of FDs in the poll set is
indicative of the number of FDs the thread has ownership of.

If all streams are inactive, the poll set will contain no FDs to
monitor and the thread will assume that it can exit. This will leave
streams in "data_ht", causing an assertion to hit in the main thread
during the clean-up.

This patch adds an inactive FD count which must also reach zero before
the data polling thread can exit.

The clean-up of the inactive streams occurs as the data polling thread
wakes-up on its "data" pipe. Upon being woken-up on the "data" pipe,
the data polling thread will validate the endpoint status of every
data stream and close those that have been marked as inactive
(see consumer_del_stream(), consumer.c:525).

This occurs as often as necessary to allow the thread to clean-up all
of its inactive streams and exit cleanly.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoman: document dead-peer detection for lttng-relayd
Jonathan Rajotte [Mon, 22 Jan 2018 20:43:35 +0000 (15:43 -0500)] 
man: document dead-peer detection for lttng-relayd

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agolttng-relayd: use TCP keep-alive mechanism to detect dead-peer
Jonathan Rajotte [Mon, 22 Jan 2018 20:43:34 +0000 (15:43 -0500)] 
lttng-relayd: use TCP keep-alive mechanism to detect dead-peer

Allow relayd to clean-up objects related to a dead connection
for which the FIN packet was no emitted (Unexpected shutdown,
ethernet:blocking). Note that an idle peer is not considered dead given
that it respond to the keep-alive query after the idle time is elapsed.

By RFC 1122-4.2.3.6 implementation must default to no less than two
hours for the idle period. On linux the default value is indeed 2 hours.
This could be problematic if relayd should be aggressive regarding
dead-peers. Hence it is important to provide tuning knob regarding the
tcp keep-alive mechanism.

The following environments variable can be used to enable and fine-tune
it:
    LTTNG_RELAYD_TCP_KEEP_ALIVE_ENABLE
        Set to 1 to enable the use of tcp keep-alive allowing the detection
        of dead peers.

    LTTNG_RELAYD_TCP_KEEP_ALIVE_TIME
        See tcp(7) tcp_keepalive_time or tcp_keepalive_interval on
        Solaris 11.
        A value of -1 lets the operating system manage this parameter
        (default).

    LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBES
        See tcp(7) tcp_keepalive_probes.
        A value of -1 lets the operating system manage this
        parameter (default).
        No effect on Solaris.

    LTTNG_RELAYD_TCP_KEEP_ALIVE_INTVL`::
        See tcp(7) tcp_keepalive_intvl.
        A value of -1 lets the operating system manage
        his parameter (default).

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: unknown consumer type considered a libc error
Jérémie Galarneau [Thu, 30 Nov 2017 22:45:30 +0000 (23:45 +0100)] 
Fix: unknown consumer type considered a libc error

The PERROR() macro uses the errno variable to print an error
message. However, the consumer type being invalid is an internal
error. The value of errno, at that point, is unrelated to the
error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix warning: src/bin/lttng/utils.c: cast incompatible pointer
Jérémie Galarneau [Mon, 13 Nov 2017 15:31:29 +0000 (10:31 -0500)] 
Fix warning: src/bin/lttng/utils.c: cast incompatible pointer

Reported-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: src/common/pipe.h: include <sys/types.h> for ssize_t and mode_t
Philippe Proulx [Wed, 8 Nov 2017 20:19:24 +0000 (15:19 -0500)] 
Fix: src/common/pipe.h: include <sys/types.h> for ssize_t and mode_t

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: detect dlmopen() and disable corresponding tests if not available
Philippe Proulx [Mon, 6 Nov 2017 23:46:41 +0000 (18:46 -0500)] 
Fix: detect dlmopen() and disable corresponding tests if not available

musl and uClibc-ng are known not to support dlmopen(). LTTng-UST has
this dlmopen() detection.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: resolve full path of LTTNG_UST_CLOCK_PLUGIN
Jérémie Galarneau [Sun, 12 Nov 2017 19:44:31 +0000 (14:44 -0500)] 
Fix: resolve full path of LTTNG_UST_CLOCK_PLUGIN

This fix is specific to the stable-2.9 branch (and applies to prior
versions) since this was adressed as part of a refactor of the
session daemon's handling of configuration option (e6142f2e).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agolttng-enable-event(1): filtering: specify that `$ctx.cpu_id` is available
Philippe Proulx [Fri, 8 Sep 2017 02:52:48 +0000 (22:52 -0400)] 
lttng-enable-event(1): filtering: specify that `$ctx.cpu_id` is available

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: Make version.h generation work with dash
Olivier Blin [Fri, 27 Oct 2017 09:46:19 +0000 (11:46 +0200)] 
Fix: Make version.h generation work with dash

version.h generation failed when using dash as shell:
Generating version.h... /bin/sh: 24: Syntax error: Missing '))'

dash does not handle the following construct:
git_describe="$((cd /path/to/lttng-tools/.; git describe) 2>/dev/null)"

Use backquotes instead.

The fix has been tested with dash and bash.

Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: buffer overflow warning in python bindings
Jérémie Galarneau [Sun, 12 Nov 2017 16:41:47 +0000 (11:41 -0500)] 
Fix: buffer overflow warning in python bindings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoTests fix: BT2 does not output the metadata of a trace collection
Jérémie Galarneau [Wed, 8 Nov 2017 19:02:07 +0000 (14:02 -0500)] 
Tests fix: BT2 does not output the metadata of a trace collection

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoUpdate version to v2.9.6
Jérémie Galarneau [Thu, 3 Aug 2017 19:16:40 +0000 (15:16 -0400)] 
Update version to v2.9.6

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: uninitialized return value on error path
Mathieu Desnoyers [Wed, 2 Aug 2017 15:34:43 +0000 (11:34 -0400)] 
Fix: uninitialized return value on error path

Found by Coverity:

*** CID 1378810:  Uninitialized variables  (UNINIT)
/src/bin/lttng-sessiond/context.c: 73 in add_kctx_all_channels()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: ensure kernel context is in a list before trying to delete it
Jérémie Galarneau [Wed, 2 Aug 2017 20:49:44 +0000 (16:49 -0400)] 
Fix: ensure kernel context is in a list before trying to delete it

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: ambiguous ownership of kernel context by multiple channels
Jérémie Galarneau [Mon, 31 Jul 2017 21:51:35 +0000 (17:51 -0400)] 
Fix: ambiguous ownership of kernel context by multiple channels

A kernel context, when added to multiple channels, must be copied
before being added to individual channels. The current code
adds the same ltt_kernel_context structure to multiple kernel
channels which introduces a conceptual ambiguity in the ownership
of the context object.

Concretely, creating multiple kernel channels and adding a context
to all of them (by not specifying a channel name) causes the context
to be added to each channels' list of contexts, overwritting the
context's list node, and causing the channel context lists to become
corrupted. This results in crashes being observed during the
destruction of the session.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: ret is never used on error_open code path
Jonathan Rajotte [Wed, 26 Jul 2017 14:52:15 +0000 (10:52 -0400)] 
Fix: ret is never used on error_open code path

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: use error code path instead of break when errors happen before execl
Jonathan Rajotte [Wed, 26 Jul 2017 14:29:17 +0000 (10:29 -0400)] 
Fix: use error code path instead of break when errors happen before execl

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: wrong variable assignment on error
Jonathan Rajotte [Tue, 25 Jul 2017 21:46:47 +0000 (17:46 -0400)] 
Fix: wrong variable assignment on error

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: missing error handling in use of print_tabs()
Jonathan Rajotte [Tue, 25 Jul 2017 21:20:45 +0000 (17:20 -0400)] 
Fix: missing error handling in use of print_tabs()

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: ret is used instead or err to set an error code
Jonathan Rajotte [Tue, 25 Jul 2017 15:31:02 +0000 (11:31 -0400)] 
Fix: ret is used instead or err to set an error code

Use err instead of ret. ret is never used for error reporting under
error label.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: report error using fd instead of ret
Jonathan Rajotte [Tue, 25 Jul 2017 14:45:32 +0000 (10:45 -0400)] 
Fix: report error using fd instead of ret

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: NULL passed to memcpy in error path
Jérémie Galarneau [Fri, 28 Jul 2017 14:59:30 +0000 (10:59 -0400)] 
Fix: NULL passed to memcpy in error path

CID 1378708:  Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "data" to "memcpy", which dereferences it.

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: lost packet accounting always lost on snapshot
Julien Desfossez [Tue, 25 Jul 2017 19:23:49 +0000 (15:23 -0400)] 
Fix: lost packet accounting always lost on snapshot

Because of the continue when we fail to get a subbuff, the lost_packet
count is always reset to 0 before we can account it in the channel. Now
we account it directly before the continue.

Reported-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: report error on session listing
Jonathan Rajotte [Fri, 21 Jul 2017 15:09:14 +0000 (11:09 -0400)] 
Fix: report error on session listing

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix live-comm: merge TCP socket write-write sequence in a single write
Jonathan Rajotte [Mon, 24 Jul 2017 20:07:00 +0000 (16:07 -0400)] 
Fix live-comm: merge TCP socket write-write sequence in a single write

The live protocol implementation is often sending content
on TCP sockets in two separate writes. One to send a command header,
and the second one sending the command's payload. This was presumably
done under the assumption that it would not result in two separate
TCP packets being sent on the network (or that it would not matter).

Delayed ACK-induced delays were observed [1] on the second write of the
"write header, write payload" sequence and result in problematic
latency build-ups for live clients connected to moderately/highly
active sessions.

Fundamentaly, this problem arises due to the combination of Nagle's
algorithm and the delayed ACK mechanism which make write-write-read
sequences on TCP sockets problematic as near-constant latency is
expected when clients can keep-up with the event production rate.

In such a write-write-read sequence, the second write is held up until
the first write is acknowledged (TCP ACK). The solution implemented
by this patch bundles the writes into a single one [2].

[1] https://github.com/tbricks/wireshark-lttng-plugin
    Basic Wireshark dissector for lttng-live by Anto Smyk from Itiviti
[2] https://lists.freebsd.org/pipermail/freebsd-net/2006-January/009527.html

Reported-by: Anton Smyk <anton.smyk@itiviti.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: join consumer timer thread
Mathieu Desnoyers [Fri, 16 Jun 2017 21:23:13 +0000 (17:23 -0400)] 
Fix: join consumer timer thread

Detaching the timer thread has the unfortunate side-effect of letting
the health management data structures be freed by main() while the timer
thread may still be using them (if, e.g., main() exits quickly).

Overcome this situation by tearing down and joining the timer thread.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoUpdate version to v2.9.5
Jérémie Galarneau [Wed, 14 Jun 2017 18:25:46 +0000 (14:25 -0400)] 
Update version to v2.9.5

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: test_utils_expand_path passes NULL to sprintf
Jérémie Galarneau [Tue, 13 Jun 2017 18:50:05 +0000 (14:50 -0400)] 
Fix: test_utils_expand_path passes NULL to sprintf

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: lttng list of channels should return errors
Mathieu Desnoyers [Fri, 26 May 2017 16:14:19 +0000 (18:14 +0200)] 
Fix: lttng list of channels should return errors

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: discard event/lost packet counters
Mathieu Desnoyers [Fri, 26 May 2017 16:14:18 +0000 (18:14 +0200)] 
Fix: discard event/lost packet counters

For per-pid buffers, we need to sum the counters for each application.

For per-uid buffers, if no application has launched yet, it should not
be considered as an error (which stops iteration on all other channels),
but rather as values of 0.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: missing errno.h include in time.h compat header
Jérémie Galarneau [Fri, 2 Jun 2017 18:49:20 +0000 (14:49 -0400)] 
Fix: missing errno.h include in time.h compat header

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: registry can be null on lookup
Jonathan Rajotte [Mon, 6 Feb 2017 20:28:52 +0000 (15:28 -0500)] 
Fix: registry can be null on lookup

A session teardown can be initiated by a dying application. Hence, a
session object can exist without a valid registry. As a result,
get_session_registry can return null. To prevent this, the UST
application session lock should be held, when possible, when looking up
the registry to ensure synchronization. Otherwise the presence of a
registry is not guaranteed. In such case, handling a null return value
from look-up registry function is necessary.

Core dumps, triggered by the "assert(registry)" statement found in
reply_ust_register_channel, were observed when killing instrumented
applications. In this occurrence, obtaining the UST application lock
result in a deadlock since the lock is already held during
ust_app_global_create. Handling the null value is simpler and
corresponds with the handling of previous look-up done during the
function.

Handling of null value is also applied to:
add_event_ust_registry
add_enum_ust_registry
ust_app_snapshot_record

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoTest: Replace test relying on pselect6(2) man page ambiguity
Francis Deslauriers [Wed, 31 May 2017 21:08:23 +0000 (17:08 -0400)] 
Test: Replace test relying on pselect6(2) man page ambiguity

The `pselect_fd_too_big` test is checking for the case where the `nfds`
is larger than the number of open files allowed for this process
(RLIMIT_NOFILE).

According to the ERRORS section of the pselect6(2) kernel man page[1], if
`nfds` > RLIMIT_NOFILE is evaluate to true the pselect6 syscall should
return EINVAL but the BUGS section mentions that the current
implementation ignores any FD larger than the highest numbered FD of the
current process.

This is in fact what happens. The Linux implementation of the pselect6
syscall[2] does not compare the `nfds` and RLIMIT_NOFILE, but rather caps
`nfds` to the highest numbered FD of the current process as the BUGS
kernel man page mentionned.

It was observed elsewhere that there is a discrepancy between the manual
page and the implementation[3].

As a solution, replace the current testcase with one that checks the
behaviour of the syscall when an invalid FD is passed.

[1]:http://man7.org/linux/man-pages/man2/pselect6.2.html
[2]:https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/select.c#n619
[3]:https://patchwork.kernel.org/patch/9345805/

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: use "flush empty" ioctl for snapshots
Mathieu Desnoyers [Thu, 11 May 2017 21:53:58 +0000 (17:53 -0400)] 
Fix: use "flush empty" ioctl for snapshots

When the flush empty ioctl is available, use it to produce an empty
packet at the end of the snapshot, which ensures the stream intersection
feature works.

If this specific ioctl is not available, fallback on the "flush" ioctl,
which does not produce empty packets.

In that situation, there were two prior behaviors possible for
lttng-modules: earlier versions implement a "snapshot" command which
does not perform an implicit "flush_empty". In that case, the stream
intersection feature may not be reliable. In more recent lttng-modules
versions (included stable branch) which did not implement the
flush_empty ioctl, the snapshot ioctl implicitly performed a
flush_empty, which makes the stream intersection feature work, but has
side-effects on the snapshot ioctl performed by the live timer (produces
a stream of empty packets in live mode).

[ Please apply to master, 2.10, 2.9, 2.8 branches. ]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: lttng-consumerd: cpu hotplug: send "streams_sent" command
Mathieu Desnoyers [Thu, 11 May 2017 20:00:56 +0000 (16:00 -0400)] 
Fix: lttng-consumerd: cpu hotplug: send "streams_sent" command

When creating a new channel, the streams being sent to the relayd are
kept invisible to the live client until the "streams_sent" command is
received. This ensures the client does not see a partial stream set.

This "streams_sent" command needs to be sent on CPU hotplug too,
otherwise the live client handling within relayd is not aware of those
streams (they are never published).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: lttng-sessiond: cpu hotplug: send channel to consumer only once
Mathieu Desnoyers [Thu, 11 May 2017 20:00:55 +0000 (16:00 -0400)] 
Fix: lttng-sessiond: cpu hotplug: send channel to consumer only once

On CPU hotplug, we currently send a duplicate of the channel key, which
allocates its own object (duplicated) within the consumerd. We want the
newly added stream to map to the pre-existing channel key, so don't send
the channel duplicate.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: lttng-sessiond: cpu hotplug stream number mismatch
Mathieu Desnoyers [Thu, 11 May 2017 20:00:54 +0000 (16:00 -0400)] 
Fix: lttng-sessiond: cpu hotplug stream number mismatch

The counter should be always increasing (kept in the channel), rather
than local to the function. This causes cpu hotplug handling to
disregard further streams that should be added to the consumer output
on CPU hotplug.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: consumer_timer_signal_thread_qs waits on LTTNG_CONSUMER_SIG_SWITCH
Jérémie Galarneau [Thu, 18 May 2017 20:15:20 +0000 (16:15 -0400)] 
Fix: consumer_timer_signal_thread_qs waits on LTTNG_CONSUMER_SIG_SWITCH

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: thread exit vs futex wait/wakeup race
Mathieu Desnoyers [Wed, 17 May 2017 22:36:54 +0000 (18:36 -0400)] 
Fix: thread exit vs futex wait/wakeup race

relayd_live_stop performs, in this order:

        CMM_STORE_SHARED(live_dispatch_thread_exit, 1);   [A]
        futex_nto1_wake(&viewer_conn_queue.futex);        [B]

whereas thread_dispatcher does:

   while (!CMM_LOAD_SHARED(live_dispatch_thread_exit)) {  [1]

     [...]
     futex_nto1_prepare(&viewer_conn_queue.futex);        [2]
     [...]
     futex_nto1_wait(&viewer_conn_queue.futex);           [3]

Unfortunately, on the following sequence:

[1] [A] [B] [2] [3]

thread_dispatcher will end up hanging.

We need to move the live_dispatch_thread_exit load between "prepare" and
"wait" to fix this.

There are similar scenarios with relay_thread_dispatcher, and the
session daemon thread_dispatch_ust_registration, which are also fixed
here.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: status_loc argument of waitpid() is used on error
Jérémie Galarneau [Mon, 15 May 2017 14:37:18 +0000 (10:37 -0400)] 
Fix: status_loc argument of waitpid() is used on error

waitpid() may leave stat_loc uninitialized on error (depending
on errno's value, see WAIT(3)).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 years agoFix: COMPAT_EPOLL_PROC_PATH is available from Linux 2.6.28
Jonathan Rajotte [Tue, 9 May 2017 19:46:35 +0000 (15:46 -0400)] 
Fix: COMPAT_EPOLL_PROC_PATH is available from Linux 2.6.28

v2: Typo in commit message "per see" -> "per se"

Failing on opening [1] is not an error per se. [1] was
introduced in Linux 2.6.28 but epoll is available since
2.5.44. Hence, goto end and set a default value without
setting error return value.

[1] /proc/sys/fs/epoll/max_user_watches

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.050197 seconds and 5 git commands to generate.