P. Remek
2008-Oct-20 15:33 UTC
[dtrace-discuss] pid provider, return not fired when variable argument list
Hi, I am using pid provider and I have noticed that return probe is not fired when leaving function with variable number of arguments using va_start and va_stop. Having such code: log() { va_start(ap, fmt); log_vwrite(l, fmt, ap); va_end(ap); } I get such output from dtrace: -> log -> log_vwrite <- log Is this a dtrace problem or is there some general problem why it can''t work when using variable argument lists? Thanks, Remek
Chad Mynhier
2008-Oct-22 02:32 UTC
[dtrace-discuss] pid provider, return not fired when variable argument list
On Mon, Oct 20, 2008 at 11:33 AM, P. Remek <p.remek1 at googlemail.com> wrote:> Hi, > > I am using pid provider and I have noticed that return probe is not fired when > leaving function with variable number of arguments using va_start and va_stop. > Having such code: > > log() { > va_start(ap, fmt); > log_vwrite(l, fmt, ap); > va_end(ap); > } > > I get such output from dtrace: > > -> log > -> log_vwrite > <- log > > > Is this a dtrace problem or is there some general problem why it can''t work > when using variable argument lists?I''ve tested this, and I''m not seeing the same problem you are. For example, using this program (compiled using ''cc foo.c'' using Sun Studio 12): ------------------------------------------------------------------------ #include <stdio.h> #include <stdarg.h> void bar(int n_args, va_list ap) { int argnum = 0; int sum = 0; while (argnum < n_args) { sum += va_arg(ap, int); argnum++; } printf("Sum = %d\n", sum); } void foo(int n_args, ...) { va_list ap; va_start(ap, n_args); bar(n_args, ap); va_end(ap); } int main() { foo(5, 1, 2, 3, 4, 5); } ------------------------------------------------------------------------ I get the following result: ------------------------------------------------------------------------ # dtrace -F -c ./a.out -n ''pid$target:a.out::entry,pid$target:a.out::return'' dtrace: description ''pid$target:a.out::entry,pid$target:a.out::return'' matched 8 probes Sum = 15 CPU FUNCTION 0 -> _start 0 <- _start 0 <- _start 0 <- _start 0 <- _start 0 -> main 0 -> foo 0 -> bar 0 <- bar 0 <- foo 0 <- main 0 <- _start dtrace: pid 866 has exited # ------------------------------------------------------------------------ Do you have any more information? Are you using any interesting compiler options? What architecture are you compiling on? (I tested this on SPARC.) Chad
Adam Leventhal
2008-Oct-22 03:00 UTC
[dtrace-discuss] pid provider, return not fired when variable argument list
Hey Remek, Thanks for working me offline to gather the data I needed to understand this issue. You''re hitting a rather interesting issue in that this function (log_vwrite) contains both a jump table (something that puts the pid provider''s return site detection code into a very conservative mode) and tail-calls (relatively rare in 32-bit x86. In particular, check out this sequence: _Z10log_vwriteiPKcPc+0xb2: popl %ebx _Z10log_vwriteiPKcPc+0xb3: popl %esi _Z10log_vwriteiPKcPc+0xb4: popl %edi _Z10log_vwriteiPKcPc+0xb5: leave _Z10log_vwriteiPKcPc+0xb6: jmp -0xef06 <fatal> Normally, we''d detect this as a return site, but the presence of the jump table elswhere in the function has put us into a case where we don''t detect that specific instruction sequence. We should add that code sequence to our short list. I''ve filed the following bug for you: 6762246 when jump tables fight tail-calls no one wins Adam On Mon, Oct 20, 2008 at 05:33:03PM +0200, P. Remek wrote:> Hi, > > I am using pid provider and I have noticed that return probe is not fired when > leaving function with variable number of arguments using va_start and va_stop. > Having such code: > > log() { > va_start(ap, fmt); > log_vwrite(l, fmt, ap); > va_end(ap); > } > > I get such output from dtrace: > > -> log > -> log_vwrite > <- log > > > Is this a dtrace problem or is there some general problem why it can''t work > when using variable argument lists? > > Thanks, > Remek > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl
P. Remek
2008-Oct-22 12:26 UTC
[dtrace-discuss] pid provider, return not fired when variable argument list
Hi Adam, I''ve searched for issue number 6762246 but I can''t see it. Anyway, if you would need anything else like bugfix verification or something, let me know. Remek On Wed, Oct 22, 2008 at 5:00 AM, Adam Leventhal <ahl at eng.sun.com> wrote:> Hey Remek, > > Thanks for working me offline to gather the data I needed to understand > this issue. You''re hitting a rather interesting issue in that this function > (log_vwrite) contains both a jump table (something that puts the pid > provider''s return site detection code into a very conservative mode) and > tail-calls (relatively rare in 32-bit x86. In particular, check out this > sequence: > > _Z10log_vwriteiPKcPc+0xb2: popl %ebx > _Z10log_vwriteiPKcPc+0xb3: popl %esi > _Z10log_vwriteiPKcPc+0xb4: popl %edi > _Z10log_vwriteiPKcPc+0xb5: leave > _Z10log_vwriteiPKcPc+0xb6: jmp -0xef06 <fatal> > > Normally, we''d detect this as a return site, but the presence of the jump > table elswhere in the function has put us into a case where we don''t detect > that specific instruction sequence. We should add that code sequence to our > short list. > > I''ve filed the following bug for you: > > 6762246 when jump tables fight tail-calls no one wins > > Adam > > > On Mon, Oct 20, 2008 at 05:33:03PM +0200, P. Remek wrote: >> Hi, >> >> I am using pid provider and I have noticed that return probe is not fired when >> leaving function with variable number of arguments using va_start and va_stop. >> Having such code: >> >> log() { >> va_start(ap, fmt); >> log_vwrite(l, fmt, ap); >> va_end(ap); >> } >> >> I get such output from dtrace: >> >> -> log >> -> log_vwrite >> <- log >> >> >> Is this a dtrace problem or is there some general problem why it can''t work >> when using variable argument lists? >> >> Thanks, >> Remek >> _______________________________________________ >> dtrace-discuss mailing list >> dtrace-discuss at opensolaris.org > > -- > Adam Leventhal, Fishworks http://blogs.sun.com/ahl >
Adam Leventhal
2008-Oct-22 16:50 UTC
[dtrace-discuss] pid provider, return not fired when variable argument list
Hey Remek, It may take a little while to show up on bugs.opensolaris.org, but the bug has been filed, and I''ll try to get a fix in place in a month or two. Adam On Wed, Oct 22, 2008 at 02:26:02PM +0200, P. Remek wrote:> Hi Adam, > > I''ve searched for issue number 6762246 but I can''t see it. > Anyway, if you would need anything else like bugfix verification > or something, let me know. > > Remek > > On Wed, Oct 22, 2008 at 5:00 AM, Adam Leventhal <ahl at eng.sun.com> wrote: > > Hey Remek, > > > > Thanks for working me offline to gather the data I needed to understand > > this issue. You''re hitting a rather interesting issue in that this function > > (log_vwrite) contains both a jump table (something that puts the pid > > provider''s return site detection code into a very conservative mode) and > > tail-calls (relatively rare in 32-bit x86. In particular, check out this > > sequence: > > > > _Z10log_vwriteiPKcPc+0xb2: popl %ebx > > _Z10log_vwriteiPKcPc+0xb3: popl %esi > > _Z10log_vwriteiPKcPc+0xb4: popl %edi > > _Z10log_vwriteiPKcPc+0xb5: leave > > _Z10log_vwriteiPKcPc+0xb6: jmp -0xef06 <fatal> > > > > Normally, we''d detect this as a return site, but the presence of the jump > > table elswhere in the function has put us into a case where we don''t detect > > that specific instruction sequence. We should add that code sequence to our > > short list. > > > > I''ve filed the following bug for you: > > > > 6762246 when jump tables fight tail-calls no one wins > > > > Adam > > > > > > On Mon, Oct 20, 2008 at 05:33:03PM +0200, P. Remek wrote: > >> Hi, > >> > >> I am using pid provider and I have noticed that return probe is not fired when > >> leaving function with variable number of arguments using va_start and va_stop. > >> Having such code: > >> > >> log() { > >> va_start(ap, fmt); > >> log_vwrite(l, fmt, ap); > >> va_end(ap); > >> } > >> > >> I get such output from dtrace: > >> > >> -> log > >> -> log_vwrite > >> <- log > >> > >> > >> Is this a dtrace problem or is there some general problem why it can''t work > >> when using variable argument lists? > >> > >> Thanks, > >> Remek > >> _______________________________________________ > >> dtrace-discuss mailing list > >> dtrace-discuss at opensolaris.org > > > > -- > > Adam Leventhal, Fishworks http://blogs.sun.com/ahl > >-- Adam Leventhal, Fishworks http://blogs.sun.com/ahl