ARM C++ segfaulting - follow-up
A message that is not in the archive (sent off-list or not yet received): [email protected]
----- Original Message -----
Quoted 19 lines
Quoted 7 lines
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' inust-events.hwhich 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_headnode' offset incorrectly by four bytes. This lead to an incorrect linked list structure which caused my issue.
Quoted 6 lines
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.
I'll push the fix in master, stable-2.6, and stable-2.5.
Thanks!
Mathieu
Quoted 37 lines
Thanks,
Robert Daniels
________________________________
Ce message, ainsi que tous les fichiers joints à ce message, peuvent contenir des informations sensibles et/ ou confidentielles ne devant pas être divulguées. Si vous n'êtes pas le destinataire de ce message (ou que vous recevez ce message par erreur), nous vous remercions de le notifier immédiatement à son expéditeur, et de détruire ce message. Toute copie, divulgation, modification, utilisation ou diffusion, non autorisée, directe ou indirecte, de tout ou partie de ce message, est strictement interdite. Se désabonner: Si vous souhaitez être retiré de notre liste de diffusion, s'il vous plaît envoyer vos coordonnées à [email protected]<mailto:[email protected]> et indiquer quels sont les messages que vous ne souhaitez plus recevoir.
This e-mail, and any document attached hereby, may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized, direct or indirect, copying, disclosure, distribution or other use of the material or parts thereof is strictly forbidden.
Unsubscribe: If you would like to be removed from our mailing list, please send your contact information to [email protected]<mailto:[email protected]> and indicate what messages you no longer wish to receive._______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 8 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Great! I guess I didn't catch that part about not compiling tracepoint probes with g++.
Thanks for a great tool!
- Robert
________________________________________
From: Mathieu Desnoyers <[email protected]>
Sent: Thursday, May 7, 2015 11:31 AM
To: Robert Daniels
Cc: [email protected]
Subject: Re: [lttng-dev] ARM C++ segfaulting - follow-up
----- Original Message -----
Quoted 19 lines
Quoted 7 lines
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' inust-events.hwhich 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_headnode' offset incorrectly by four bytes. This lead to an incorrect linked list structure which caused my issue.
Quoted 6 lines
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.
I'll push the fix in master, stable-2.6, and stable-2.5.
Thanks!
Mathieu
Quoted 32 lines
Thanks,
Robert Daniels
________________________________
Ce message, ainsi que tous les fichiers joints à ce message, peuvent contenir des informations sensibles et/ ou confidentielles ne devant pas être divulguées. Si vous n'êtes pas le destinataire de ce message (ou que vous recevez ce message par erreur), nous vous remercions de le notifier immédiatement à son expéditeur, et de détruire ce message. Toute copie, divulgation, modification, utilisation ou diffusion, non autorisée, directe ou indirecte, de tout ou partie de ce message, est strictement interdite. Se désabonner: Si vous souhaitez être retiré de notre liste de diffusion, s'il vous plaît envoyer vos coordonnées à [email protected]<mailto:[email protected]> et indiquer quels sont les messages que vous ne souhaitez plus recevoir.
This e-mail, and any document attached hereby, may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized, direct or indirect, copying, disclosure, distribution or other use of the material or parts thereof is strictly forbidden.
Unsubscribe: If you would like to be removed from our mailing list, please send your contact information to [email protected]<mailto:[email protected]> and indicate what messages you no longer wish to receive.
Quoted 5 lines
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
________________________________
Ce message, ainsi que tous les fichiers joints à ce message, peuvent contenir des informations sensibles et/ ou confidentielles ne devant pas être divulguées. Si vous n'êtes pas le destinataire de ce message (ou que vous recevez ce message par erreur), nous vous remercions de le notifier immédiatement à son expéditeur, et de détruire ce message. Toute copie, divulgation, modification, utilisation ou diffusion, non autorisée, directe ou indirecte, de tout ou partie de ce message, est strictement interdite. Se désabonner: Si vous souhaitez être retiré de notre liste de diffusion, s'il vous plaît envoyer vos coordonnées à [email protected]<mailto:[email protected]> et indiquer quels sont les messages que vous ne souhaitez plus recevoir.
This e-mail, and any document attached hereby, may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized, direct or indirect, copying, disclosure, distribution or other use of the material or parts thereof is strictly forbidden.
Unsubscribe: If you would like to be removed from our mailing list, please send your contact information to [email protected]<mailto:[email protected]> and indicate what messages you no longer wish to receive.