Fix: logging: log_add_time() save/restore errno
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 Fix: logging: log_add_time() save/restore errno
The debugging logging macros (e.g. DBG()) are used as printf in the lttng-tools source files. The printf() implementation does not alter the errno value, so the fact that log_add_time() (through clock_gettime()) can alter errno is unexpected. For instance, adding a logging statement for debugging purposes within a function for which errno is expected to stay unchanged on return will change the behavior between execution with -vvv and non-verbose.
--- src/common/error.c | 4 ++++ 1 file changed, 4 insertions(+)
src/common/error.c +4 -0
@@ -20,6 +20,7 @@#include <inttypes.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include <lttng/lttng-error.h> #include <common/common.h>
@@ -45,6 +46,7 @@ const char *log_add_time(void)struct tm tm, *res;struct timespec tp;time_t now; +int errsv = errno; ret =lttng_clock_gettime (CLOCK_REALTIME , &tp);if (ret <0 ) {
@@ -65,10 +67,12 @@ const char *log_add_time(void) goto error; } + errno = errsv;return URCU_TLS (error_log_time).str; error:/* Return an empty string on error so logging is not affected. */ + errno = errsv;return "" ; }
Signature · 1 line
2.17.1
Re: [PATCH lttng-tools 1/2] Fix relayd: initialize beacon to -1ULL
In reply to a message not in the archiveBoth patches are merged in master, stable-2.11, stable-2.10, and stable-2.9.
Thanks!
Jérémie
Quoted 39 lines · Mathieu Desnoyers
The relayd stream
beacon_ts_endfield is expected to have the value -1ULL when unset (no beacon has been received since last index).However, the initial state is wrong. It is left at the value 0, which indicates that a live beacon has indeed been received (which is untrue), which in turn causes a live beacon with
ctf_stream_idof -1ULL to be sent to babeltrace, which does not expect it, and fails.This issue can be triggered with the following scenario:
1) create live session
2) setup UST per-uid buffers tracing
3) start tracing, without any active traced application
4) hook with babeltrace live client to view the trace
5) run a traced applicationStep 5) will cause the babeltrace live client to receive a
stream_idof -1ULL, and error out.Signed-off-by Mathieu Desnoyers <[email protected]>--- src/bin/lttng-relayd/stream.c | 1 + 1 file changed, 1 insertion(+)src/bin/lttng-relayd/stream.c +1
-0@@ -98,6 +98,7 @@ struct relay_stream *stream_create(struct ctf_trace *trace, stream->tracefile_count = tracefile_count; stream->path_name = path_name; stream->channel_name = channel_name; + stream->beacon_ts_end =-1ULL ;lttng_ht_node_init_u64 (&stream->node, stream->stream_handle);pthread_mutex_init (&stream->lock,NULL );pthread_mutex_init (&stream->reflock,NULL );Signature · 1 line
2.17.1