[lttng-dev] [PATCH lttng-tools 1/1] Fix: consumer snapshot: handle unsigned long overflow

2019-02-19 Thread Mathieu Desnoyers
Comparing the consumed iterator and the produced position without
using a difference generates an empty snapshot when the iterator is
before unsigned long overflow and the produced position is after
unsigned long overflow.

This applies to both UST and kernel consumers.

Signed-off-by: Mathieu Desnoyers 
---
 src/common/kernel-consumer/kernel-consumer.c | 2 +-
 src/common/ust-consumer/ust-consumer.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common/kernel-consumer/kernel-consumer.c 
b/src/common/kernel-consumer/kernel-consumer.c
index 9bed7b55..1533e9ef 100644
--- a/src/common/kernel-consumer/kernel-consumer.c
+++ b/src/common/kernel-consumer/kernel-consumer.c
@@ -234,7 +234,7 @@ int lttng_kconsumer_snapshot_channel(struct 
lttng_consumer_channel *channel,
produced_pos, nb_packets_per_stream,
stream->max_sb_size);
 
-   while (consumed_pos < produced_pos) {
+   while ((long) (consumed_pos - produced_pos) < 0) {
ssize_t read_len;
unsigned long len, padded_len;
 
diff --git a/src/common/ust-consumer/ust-consumer.c 
b/src/common/ust-consumer/ust-consumer.c
index 46f33005..94b761cb 100644
--- a/src/common/ust-consumer/ust-consumer.c
+++ b/src/common/ust-consumer/ust-consumer.c
@@ -1168,7 +1168,7 @@ static int snapshot_channel(struct lttng_consumer_channel 
*channel,
produced_pos, nb_packets_per_stream,
stream->max_sb_size);
 
-   while (consumed_pos < produced_pos) {
+   while ((long) (consumed_pos - produced_pos) < 0) {
ssize_t read_len;
unsigned long len, padded_len;
 
-- 
2.11.0

___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


Re: [lttng-dev] Tracepoints firing without being enabled in LTTng

2019-02-19 Thread Francis Deslauriers
Hi Mosleh,
Just to be clear:
When you run your app as a service (background), lttng list -u doesn't
display any events AND you see events in the live session without
having run enable-event and start commands.
When you run your app normally, lttng list -u displays events AND you
only see events after running enable-event and start commands.
Is that correct?

Please provide the output of the lttng-sessiond in verbose mode using
the following command:
> lttng-sessiond -vvv
please provide the output of your application as a service with this
environment variable:  LTTNG_UST_DEBUG=1
and please provide us with the service file describing how your
service is started.
Put all of this on a pastebin.com

Is your application mass-closing file descriptors when it's
daemonizing? how about using fork() syscall without an exec() after
it? If so, have a look at this part of the UST man page:
https://lttng.org/man/3/lttng-ust/v2.10/#doc-_using_lttng_ust_with_daemons

Thank you,
Francis


Le mar. 19 févr. 2019, à 16 h 37, Mosleh Uddin  a écrit :
>
> Hello,
>
> Sorry for the late reply. I was able to figure out the weird behavior from 
> the application. Turns out if I run my application as a service,  lttng no 
> longer can see any of the UST tracepoints and causes the behavior I was 
> explaining.
> When I execute the application normally (./app_name), the functionality is as 
> expected. Is this the expected behavior? Is there some way I can trace the 
> userspace application while running it as a service simultaneously?
>
> Thanks for any info,
> Mosleh
>
> On Fri, Feb 15, 2019 at 2:48 PM Francis Deslauriers 
>  wrote:
>>
>> Can you start the lttng-sessiond in verbose mode using the following command:
>> > lttng-sessiond -vvv
>> and then do the lttng create, start of application and lttng view on another 
>> console.
>>
>> Then copy the output of the sessiond on https://pastebin.com/ and send us 
>> the link.
>>
>> Thank you,
>> Francis
>>
>> Le ven. 15 févr. 2019, à 14 h 36, Mosleh Uddin  a 
>> écrit :
>>>
>>> That's correct, I don't enable any events or do: lttng start.
>>> Here is some snapshots of starting everything up, followed by starting my 
>>> application.
>>>
>>>
>>> Here are the outputs for the commands:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Note that even though the session is inactive, when a trace event occurs in 
>>> my application it is being recorded in the appropriate directory:
>>>
>>>
>>>
>>> Also maybe important, the system has root only user. Would having the 
>>> application belonging to a different user and trying to run as root cause 
>>> these kinds of complications? I did notice when testing on a raspberry pi 
>>> that running an application as a root user would mean running sessions as 
>>> root user as well.
>>>
>>> Thanks,
>>> Mosleh
>>>
>>> On Fri, Feb 15, 2019 at 11:55 AM Francis Deslauriers 
>>>  wrote:

 Adding back lttng-dev mailing list.

 So you don't even run a lttng-enable-event command?
 That's odd.

 Can you send us the output of the following commands:
 Is it possible that there are other lttng-sessiond daemons running on
 the machine?
 > ps aux | grep "lttng-sessiond"
 Verify if there are other active tracing sessions:
 > lttng list
 Check the details of the current session:
 > lttng status

 Thank you,
 Francis

 Le ven. 15 févr. 2019, à 11 h 29, Mosleh Uddin  a 
 écrit :
 >
 > Hi Francis,
 >
 > Thank you for the quick response.
 > Just to clear things up, my application is running when I run that 
 > command.
 >
 > The commands I am running are:
 > > lttng-sessiond -d
 > > lttng create my-sess --live
 > After this command I start my application. If I then do the command:
 > > lttng view
 > I will see the tracepoints in the application in the terminal even 
 > though I have not done: lttng start.
 >
 > I thought it was strange that I cannot find my application in the: lttng 
 > list command under any domain.
 > Also the reason I start my application after creating a session is 
 > because the system automatically starts the application using systemd,
 > in order to get tracing data at all I have to manually stop the 
 > application and start it again after creating a session.
 >
 > Thanks again for any help,
 > Mosleh
 >
 > On Fri, Feb 15, 2019 at 10:32 AM Francis Deslauriers 
 >  wrote:
 >>
 >> Hi Mosleh,
 >> It's expected to not see any event when running lttng list -u if no
 >> lttng-ust instrumented applications are running.
 >>
 >> What are the exact lttng commands you are running to see those
 >> unexpected events?
 >>
 >> Thank you,
 >> Francis
 >>
 >>
 >> Le ven. 15 févr. 2019, à 10 h 08, Mosleh Uddin  a 
 >> écrit :
 >> >
 >> > Hello,
 >> >
 >> > I am having a strange issue with my current application. For some 
 

Re: [lttng-dev] Tracepoints firing without being enabled in LTTng

2019-02-19 Thread Mosleh Uddin
Hello,

Sorry for the late reply. I was able to figure out the weird behavior from
the application. Turns out if I run my application as a service,  lttng no
longer can see any of the UST tracepoints and causes the behavior I was
explaining.
When I execute the application normally (./app_name), the functionality is
as expected. Is this the expected behavior? Is there some way I can trace
the userspace application while running it as a service simultaneously?

Thanks for any info,
Mosleh

On Fri, Feb 15, 2019 at 2:48 PM Francis Deslauriers <
francis.deslauri...@efficios.com> wrote:

> Can you start the lttng-sessiond in verbose mode using the following
> command:
> > lttng-sessiond -vvv
> and then do the lttng create, start of application and lttng view on
> another console.
>
> Then copy the output of the sessiond on https://pastebin.com/ and send us
> the link.
>
> Thank you,
> Francis
>
> Le ven. 15 févr. 2019, à 14 h 36, Mosleh Uddin  a
> écrit :
>
>> That's correct, I don't enable any events or do: lttng start.
>> Here is some snapshots of starting everything up, followed by starting my
>> application.
>> [image: image.png]
>>
>> Here are the outputs for the commands:
>>
>> [image: image.png]
>>
>> [image: image.png]
>>
>> [image: image.png]
>>
>> Note that even though the session is inactive, when a trace event occurs
>> in my application it is being recorded in the appropriate directory:
>>
>> [image: image.png]
>>
>> Also maybe important, the system has root only user. Would having the
>> application belonging to a different user and trying to run as root cause
>> these kinds of complications? I did notice when testing on a raspberry pi
>> that running an application as a root user would mean running sessions as
>> root user as well.
>>
>> Thanks,
>> Mosleh
>>
>> On Fri, Feb 15, 2019 at 11:55 AM Francis Deslauriers <
>> francis.deslauri...@efficios.com> wrote:
>>
>>> Adding back lttng-dev mailing list.
>>>
>>> So you don't even run a lttng-enable-event command?
>>> That's odd.
>>>
>>> Can you send us the output of the following commands:
>>> Is it possible that there are other lttng-sessiond daemons running on
>>> the machine?
>>> > ps aux | grep "lttng-sessiond"
>>> Verify if there are other active tracing sessions:
>>> > lttng list
>>> Check the details of the current session:
>>> > lttng status
>>>
>>> Thank you,
>>> Francis
>>>
>>> Le ven. 15 févr. 2019, à 11 h 29, Mosleh Uddin  a
>>> écrit :
>>> >
>>> > Hi Francis,
>>> >
>>> > Thank you for the quick response.
>>> > Just to clear things up, my application is running when I run that
>>> command.
>>> >
>>> > The commands I am running are:
>>> > > lttng-sessiond -d
>>> > > lttng create my-sess --live
>>> > After this command I start my application. If I then do the command:
>>> > > lttng view
>>> > I will see the tracepoints in the application in the terminal even
>>> though I have not done: lttng start.
>>> >
>>> > I thought it was strange that I cannot find my application in the:
>>> lttng list command under any domain.
>>> > Also the reason I start my application after creating a session is
>>> because the system automatically starts the application using systemd,
>>> > in order to get tracing data at all I have to manually stop the
>>> application and start it again after creating a session.
>>> >
>>> > Thanks again for any help,
>>> > Mosleh
>>> >
>>> > On Fri, Feb 15, 2019 at 10:32 AM Francis Deslauriers <
>>> francis.deslauri...@efficios.com> wrote:
>>> >>
>>> >> Hi Mosleh,
>>> >> It's expected to not see any event when running lttng list -u if no
>>> >> lttng-ust instrumented applications are running.
>>> >>
>>> >> What are the exact lttng commands you are running to see those
>>> >> unexpected events?
>>> >>
>>> >> Thank you,
>>> >> Francis
>>> >>
>>> >>
>>> >> Le ven. 15 févr. 2019, à 10 h 08, Mosleh Uddin 
>>> a écrit :
>>> >> >
>>> >> > Hello,
>>> >> >
>>> >> > I am having a strange issue with my current application. For some
>>> context, I have integrated LTTng into a Yocto build and put custom trace
>>> points in my embedded system application. Once I load the built image onto
>>> my system and start a session daemon, I try to list all available userspace
>>> events (using lttng list -u), but no events show up.
>>> >> >
>>> >> > The strange occurrence is when I create a session (lltng create
>>> my-sess) and not start tracing the trace events will display on the screen
>>> regardless (when starting session in live mode with lttng view). I was
>>> wondering if anyone has any insight on this issue I am having.
>>> >> >
>>> >> > Thanks for any assistance,
>>> >> > Mosleh
>>> >> > ___
>>> >> > lttng-dev mailing list
>>> >> > lttng-dev@lists.lttng.org
>>> >> > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>>> >>
>>> >> --
>>> >> Francis Deslauriers
>>> >> Computer Engineer
>>> >> EfficiOS inc.
>>>
>>>
>>>
>>> --
>>> Francis Deslauriers
>>> Computer Engineer
>>> EfficiOS inc.
>>>
>>