Skip to content

Commit 63ae847

Browse files
PSRCodejgalar
authored andcommitted
Fix: notification: assert on len > 0 for dropped notification message
Observed issue ============== Using the notification client from doc/examples/trigger-condition-event-matches/notification-client.cpp, an assert is hit when the notification subsystem is under load. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007f69eab58859 in __GI_abort () at abort.c:79 #2 0x00007f69eab58729 in __assert_fail_base (fmt=0x7f69eacee588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7f69eae1d5dd "len > 0", file=0x7f69eae1d5cb "unix.cpp", line=179, function=<optimized out>) at assert.c:92 #3 0x00007f69eab6a006 in __GI___assert_fail (assertion=0x7f69eae1d5dd "len > 0", file=0x7f69eae1d5cb "unix.cpp", line=179, function=0x7f69eae1d598 "ssize_t lttcomm_recv_unix_sock(int, void*, size_t)") at assert.c:101 #4 0x00007f69eadd5fe6 in lttcomm_recv_unix_sock (sock=3, buf=0x55da9ecd5f89, len=0) at unix.cpp:179 #5 0x00007f69ead7df3f in receive_message (channel=0x55da9ecd6ee0) at channel.cpp:64 #6 0x00007f69ead7e478 in lttng_notification_channel_get_next_notification (channel=0x55da9ecd6ee0, _notification=0x7ffdefed2570) at channel.cpp:279 #7 0x000055da9e0e742f in main (argc=2, argv=0x7ffdefed2698) at notification-client.cpp:506 (gdb) frame #5 0x00007f69ead7df3f in receive_message (channel=0x55da9ecd6ee0) at channel.cpp:64 64 ret = lttcomm_recv_unix_sock(channel->socket, (gdb) print msg $2 = {type = 5 '\005', size = 0, fds = 0, payload = 0x7ffdefed24a8 ""} The msg type 5 is `LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED` Cause ===== The msg portion of a `LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION_DROPPED` is indeed zero. There is no extra payload. Solution ======== When the msg size is zero, skip the 'payload' reception phase. Known drawbacks ========= None. Signed-off-by: Jonathan Rajotte <[email protected]> Signed-off-by: Jérémie Galarneau <[email protected]> Change-Id: Ibabb922d0e410c9902414a5eabbe04738861d772
1 parent bdfd0a8 commit 63ae847

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/lib/lttng-ctl/channel.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ int receive_message(struct lttng_notification_channel *channel)
5353
goto error;
5454
}
5555

56+
if (msg.size == 0) {
57+
goto skip_payload;
58+
}
59+
5660
/* Reserve space for the payload. */
5761
ret = lttng_dynamic_buffer_set_size(&channel->reception_payload.buffer,
5862
channel->reception_payload.buffer.size + msg.size);
@@ -68,6 +72,7 @@ int receive_message(struct lttng_notification_channel *channel)
6872
goto error;
6973
}
7074

75+
skip_payload:
7176
/* Receive message fds. */
7277
if (msg.fds != 0) {
7378
ret = lttcomm_recv_payload_fds_unix_sock(channel->socket,

0 commit comments

Comments
 (0)