"make distcheck" marks each source file on the srcdir in the extracted
dist tarball read-only. The examples copy from the srcdir into the
builddir before running the "make" examples, but this keeps the
read-only flag on the builddir directories, which fails the build
because the resulting objects cannot be created.
Fix this by ensuring the copied target directory for each example is
user-writeable.
We need to byteswap integers passed to the filter when they are tagged
as being in an endianness which differs from the architecture
endianness, so the integer comparisons make sense in terms of value
rather than raw bytes for those fields.
This has been detected in the lttng-modules port of the filter
interpreter by Coverity. The intent of the code in UST is similar, and
we can find the same dead code, although Coverity may not see it as dead
code because it cannot prove that the string is not modified between the
two uses. Since we know it is not modified, remove the dead code.
Assertions in the lttng-ust-comm init function are slightly too harsh
for their own good. In situations involving incoherent seccomp profiles
(e.g. accepting futex, poll, nanosleep, clock_nanosleep, but not
restart_syscall), unexpected errno values can be returned by
sem_timedwait.
Print an error in those situations, but let the application proceed.
Fix: Ensure the Java JUL messages are correctly formatted
It is possible for log records to contain messages that need some
formatting, for example if the string contains localized elements
or if the log(Level, String, Object[]) method is used.
In these cases, we need to make sure to format the string and not
pass the "raw" string to the tracepoint.
This only applies to the JUL API. log4j 1.2.x did not handle such
formatting, although log4j 2.x does.
This is a backport of commit 4721f9c to the stable-2.7 branch.
When adding large context (e.g. callstack), headers larger than 256
bytes cause discrepancy between calculated size and size written into
the trace buffers. This generates a corrupted trace and triggers a
warning in ring buffer backend, which triggers a safety net disabling
tracing for the current channel.
Mikael Beckius [Tue, 12 May 2015 09:04:34 +0000 (11:04 +0200)]
Fix: live timer calculation error
There is an calculation error for live timer. Variable
chan->switch_timer_interval is based on microsecond, and it is not right
to assign chan->switch_timer_interval mod 1000000 to var tv_nsec which
is based on nanosecond.
Signed-off-by: Mikael Beckius <mikael.beckius@windriver.com> Signed-off-by: Jianchuan Wang <jianchuan.wang@windriver.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Stelios Bounanos [Wed, 14 Oct 2015 16:31:36 +0000 (17:31 +0100)]
Fix: Don't (re)define STAP_PROBEV
Define a new LTTNG_STAP_PROBEV macro to avoid clobbering STAP_PROBEV or
emitting unwanted sdt probes when lttng-ust has been built without sdt
support.
Fix: Argument with 'nonnull' attribute passed null
Reported by scan-build
API Argument with 'nonnull' attribute passed null libringbuffer
/ring_buffer_backend.c 380
API Argument with 'nonnull' attribute passed null libringbuffer
/ring_buffer_backend.c 420
CID 1021259 (#1 of 1): Improper use of negative value
(NEGATIVE_RETURNS)5. negative_returns: sysconf(_SC_PAGESIZE) is passed
to a parameter that cannot be negative.
Philippe Proulx [Sat, 5 Sep 2015 17:38:01 +0000 (13:38 -0400)]
Fix: Python agent: do not register twice to same port
It is possible that one of the session daemons left its agent.port
file on the file system, for example when killed with SIGKILL. It
is also common that both those session daemons use the same port for
listening to agent connections. In this case, if one session daemon
is running, but two agent.port files exist, the Python agent would
connect its two threads to the same session daemon, leading to
everything done twice: list shows events twice, tracing records
events twice, etc.
This patch ensures that if two agent.port files are found and have
the same content, only one thread is used.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: close socket on protocol error, sendmsg MSG_NOSIGNAL
Don't try to keep interacting with sessiond when a protocol error is
detected at the UST application side: this means we cannot trust the
protocol anymore, so there is no reason for keeping the socket open.
For instance, if the application is exiting and we receive a new stream,
we're effectively not reading the stream data, and we return an error.
Unfortunately, the session daemon may try to send us another command,
but we will try interpreting the stream data as a command, which is
invalid.
Also, use MSG_NOSIGNAL flag in the fds recvmsg, so the session daemon
don't get killed with SIGPIPE when it cannot send to the socket due to
connection closed.
Listener threads can be cancelled with ust lock held, which can hang the
following ust cleanup routine, because tracepoint probe unregister needs
to take the ust lock.
Fix this by disabling pthread cancellation for the entire duration of
the ust lock.
Jonathan Rajotte [Mon, 10 Aug 2015 18:45:34 +0000 (14:45 -0400)]
Build: python agent: use setup.py over autoconf
This change provides a valid way of installing the agent. The autoconf
python macro provides the wrong installation path for
python 3 under Debian and Ubuntu due to distro-specific packaging for
python 2.7 and 3.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Cleanup local_apps sock_info in lttng_ust_cleanup
LTTng-UST will deadlock after a fork while waiting on the
"constructor_wait" semaphore if local apps, handled the session daemon
running under the current UID, are disabled or "not_allowed".
This deadlock can be triggered by setting an infinite registration
timeout, clearing the HOME environment variable and launching an app
which calls FORK(3). This will cause setup_local_apps() to fail to
determine the local_apps sock_path, thus leaving
local_apps.allowed == 0.
This, in turn, would cause lttng_ust_cleanup to skip the cleanup
of the local_apps sock_info after a fork,
leaving local_apps.constructor_sem_posted == 1. This would cause
handle_register_done() in the child to skip over the decrementation
of sem_count and post of the constructor_wait semaphore.
Handling sys_futex EINTR allows us to retry waiting on the futex
immediately if we are interrupted by a signal without having to try
connecting to the session daemon.
This should not impact correctness though, as the wait scheme would
simply try to connect, fail, and try waiting again.
Michael Jeanson [Tue, 30 Jun 2015 20:59:54 +0000 (16:59 -0400)]
Fix: java class check when uudecode is not present
On systems where 'uudecode' is present, the java class check will
run a precompiled class file in the local directory. If the CLASSPATH
variable doesn't contain "." the test will fail regardless of the
presence of the tested for class on the classpath.
This fix makes the behavior of the test consistant whether 'uudecode'
is present or not.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- Use camelCase for regular members and FULL_CAPS for static final
ones (except for API classes).
- All members of an interface are public static final by default,
no need to repeat the modifiers.
- Marked final some fields that could be.
Java has a @Deprecated annotation to indicate deprecated classes
(or methods, members, etc.). This will keep the code available for
backwards compatibility, but will emit a warning to any user calling
it.
- Remove unused imports.
- Access static fields statically.
- Mark static methods that can be.
- Remove exception declarations that are not actually thrown
(on non-API methods only).
Trace viewers use the tracer minor version to know which event name to
expect for the statedump. Since we changed the namespacing of those
events for 2.7, switch the tracer minor version to "7" before rc1, hence
the use of "pre" at this stage of the release process.
Because tracepoint state is updated by lttng-ust threads, and read by
application threads, we need to perform a volatile load of that state.
Not having the volatile load can cause the compiler to optimize away the
reload of that state, keeping a local copy instead. For instance, a main
program consisting of a loop could keep the tracepoint state on its
stack or in registers without ever reloading it from memory.
Perform a volatile load (CMM_LOAD_SHARED()) of the tracepoint state.
Add the matching volatile store (CMM_STORE_SHARED()) in tracepoint.c for
the state update.
Antoine Busque [Mon, 25 May 2015 23:17:09 +0000 (19:17 -0400)]
Rename helper providers and events for consistency
This patch renders uniform the provider names of UST helpers by making
them all start with the "lttng_ust_" prefix. Also, the helper formerly
known as "ust_baddr" is now "lttng_ust_dl", and its "push" and "pop"
events are now "dlopen" and "dlclose", respectively. This is in line
with the other helpers, for which the name of the provider reflects
the name of the library, and the names of events correspond to those
of the traced functions.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Antoine Busque [Mon, 25 May 2015 23:12:30 +0000 (19:12 -0400)]
Refactor state dump system
This patch refactors the state dump system. The state dump provider is
now "lttng_ust_statedump". Each process' state dump is now delimited
by a pair of "start" and "end" events. These events mark the beginning
and end of the state dump, which happens once per traced application
per session. Note that for a given (process, session) pair, begin/end
events are serialized and will match. However, in a session, state
dumps from different processes may be interleaved. The vpid context
should be used to identify which events belong to which process.
Signed-off-by: Antoine Busque <abusque@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Philippe Proulx [Wed, 1 Apr 2015 00:09:54 +0000 (20:09 -0400)]
Refactor Python agent
This patch refactors the whole LTTng-UST Python agent.
Notorious changes are:
* Python module "lttng_agent" moved to Python package
"lttngust". This removes "agent" from the name, which
really is an implementation detail. "lttngust" is used
because "lttng" would clash with LTTng-tools Python
bindings.
* Python package instead of simple module. Splitting the
code in various modules will make future development
easier.
* Use daemon threads to make sure logging with tracing
support is available as long as the regular threads live,
while making sure that the application exits instantly when
its regular threads die.
* Create client threads and register to session daemons
at import time. This allows the package to be usable just
by importing it (no need to instanciate any specific class
or call any specific function).
* Do not use a semaphore + sleep to synchronize client threads
with the importing thread: use a blocking synchronized
queue with appropriate timeouts.
* Add debug statements at strategic locations, enabled by
setting the $LTTNG_UST_PYTHON_DEBUG environment variable
to 1 before importing the package.
* Override the default session daemon registration timeout
with $LTTNG_UST_PYTHON_REGISTER_TIMEOUT (ms).
* Override the default session daemon registration retry
delay with $LTTNG_UST_PYTHON_REGISTER_RETRY_DELAY (ms).
* Honor $LTTNG_HOME (to retrieve session daemon TCP ports).
* Do not use an absolute path when loading the tracepoint
provider shared object. Users should use the
$LD_LIBRARY_PATH environment variable to override the
default library path when running Python instead.
* Do not keep an event dictionary since this brings issues
when enabling/disabling events with the same name in
different sessions.
* Make sure the reference count does not go below 0,
which could happen when destroying a session which contains
events that are disabled already.
* Minor improvements to make the code more Pythonic.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Robert Daniels wrote:
> > I'm attempting to use lttng userspace tracing with a C++ application
> > on an ARM platform. I'm using GCC 4.8.4 on Linux 3.14 with the 2.6
> > release of lttng. I've compiled lttng-modules, lttng-ust, and
> > lttng-tools and have been able to get a simple test working with C
> > code. When I attempt to run the hello.cxx test on my target it will
> > segfault.
>
>
> I spent a little time digging into this issue and finally discovered the
> cause of my segfault with ARM C++ tracepoints.
>
> There is a struct called 'lttng_event' in ust-events.h which contains an
> empty union 'u'. This was the cause of my issue. Under C, this empty union
> compiles to a zero byte member while under C++ it compiles to a one byte
> member, and in my case was four-byte aligned which caused my C++ code to
> have the 'cds_list_head node' offset incorrectly by four bytes. This lead
> to an incorrect linked list structure which caused my issue.
>
> Since this union is empty, I simply removed it from the struct and everything
> worked correctly.
>
> I don't know the history or purpose behind this empty union so I'd like to
> know if this is a safe fix. If it is I can submit a patch with the union
> removed.
That's a very nice catch!
We do not support building tracepoint probe provider with
g++ yet, as stated in lttng-ust(3):
"- Note for C++ support: although an application instrumented with
tracepoints can be compiled with g++, tracepoint probes should be
compiled with gcc (only tested with gcc so far)."
However, if it works fine with this fix, then I'm tempted to take it,
especially because removing the empty union does not appear to affect
the layout of struct lttng_event as seen from liblttng-ust, which must
be compiled with a C compiler, and from probe providers compiled with
a C compiler. So all we are changing is the layout of a probe provider
compiled with a C++ compiler, which is anyway buggy at the moment,
because it is not compatible with the layout expected by liblttng-ust
compiled with a C compiler.
Reported-by: Robert Daniels <robert.daniels@vantagecontrols.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: use lttng_secure_getenv to handle env. vars. involving paths
This is a security fix for applications linked against liblttng-ust
which are exposed as setuid binaries.
A malicious user which can run those applications could target those
environment variable paths to locations that would allow it to create
files in various areas of the filesystem.