Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Crash Utility (http://www.linux-archive.org/crash-utility/)
-   -   Patch to fix Seg Violation in parse_for_member (http://www.linux-archive.org/crash-utility/692425-patch-fix-seg-violation-parse_for_member.html)

Bob Montgomery 08-09-2012 10:23 PM

Patch to fix Seg Violation in parse_for_member
 
If you change the
fprintf(pc->saved_fp, buf);
lines to
print_verbatim(pc->saved_fp, buf);

Then I won't get:

crash> sk_buff.head ffff88012014dc80
Segmentation fault

When I need to get:

crash> sk_buff.head ffff88012014dc80
head = 0xffff880121267000 ""%s %s %s", got type "%s""


Patch attached (6.0.8).

I suspect performance will suffer a bit when I try to print
2 million of these...

Thanks,
Bob Montgomery


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Bob Montgomery 08-09-2012 10:31 PM

Patch to fix Seg Violation in parse_for_member
 
On Thu, 2012-08-09 at 16:23 -0600, Bob Montgomery wrote:
> If you change the
> fprintf(pc->saved_fp, buf);
> lines to
> print_verbatim(pc->saved_fp, buf);
>
> Then I won't get:
>
> crash> sk_buff.head ffff88012014dc80
> Segmentation fault
>
> When I need to get:
>
> crash> sk_buff.head ffff88012014dc80
> head = 0xffff880121267000 ""%s %s %s", got type "%s""
>
>
> Patch attached (6.0.8).
>
> I suspect performance will suffer a bit when I try to print
> 2 million of these...

Wonder if it would be quicker on average to string search for "%" and
conditionally call print_verbatim??? I had lots of successful
fprintf's and only a small number of seg viol cases.

Bob M.


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 08-10-2012 01:55 PM

Patch to fix Seg Violation in parse_for_member
 
----- Original Message -----
> On Thu, 2012-08-09 at 16:23 -0600, Bob Montgomery wrote:
> > If you change the
> > fprintf(pc->saved_fp, buf);
> > lines to
> > print_verbatim(pc->saved_fp, buf);
> >
> > Then I won't get:
> >
> > crash> sk_buff.head ffff88012014dc80
> > Segmentation fault
> >
> > When I need to get:
> >
> > crash> sk_buff.head ffff88012014dc80
> > head = 0xffff880121267000 ""%s %s %s", got type "%s""
> >
> >
> > Patch attached (6.0.8).
> >
> > I suspect performance will suffer a bit when I try to print
> > 2 million of these...
>
> Wonder if it would be quicker on average to string search for "%" and
> conditionally call print_verbatim??? I had lots of successful
> fprintf's and only a small number of seg viol cases.
>
> Bob M.

Hi Bob,

Although in practice,

(1) parse_for_member() is rarely called "in quantity", and
(2) when it is called, it would only encounter this with "char *" members, and
(3) the string would also have to have a '%' in it.

On the other hand, if you test the two print-types with a million calls,
there's a significant performance hit. But if a strstr() is done first
on the string, there's virtually no hit at all if there's no '%' in it.

So yes, I agree with you that the string-search/conditional call should be done.
I'll add that to your patch, and queue it for crash-6.0.9.

Thanks,
Dave

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Adrien Kunysz 08-10-2012 02:04 PM

Patch to fix Seg Violation in parse_for_member
 
What about replacing that fprintf() with fprintf(pc->saved_fp, "%s",
buf) or even fputs(buf, pc->saved_fp)?

On Fri, Aug 10, 2012 at 2:55 PM, Dave Anderson <anderson@redhat.com> wrote:
>
>
> ----- Original Message -----
>> On Thu, 2012-08-09 at 16:23 -0600, Bob Montgomery wrote:
>> > If you change the
>> > fprintf(pc->saved_fp, buf);
>> > lines to
>> > print_verbatim(pc->saved_fp, buf);
>> >
>> > Then I won't get:
>> >
>> > crash> sk_buff.head ffff88012014dc80
>> > Segmentation fault
>> >
>> > When I need to get:
>> >
>> > crash> sk_buff.head ffff88012014dc80
>> > head = 0xffff880121267000 ""%s %s %s", got type "%s""
>> >
>> >
>> > Patch attached (6.0.8).
>> >
>> > I suspect performance will suffer a bit when I try to print
>> > 2 million of these...
>>
>> Wonder if it would be quicker on average to string search for "%" and
>> conditionally call print_verbatim??? I had lots of successful
>> fprintf's and only a small number of seg viol cases.
>>
>> Bob M.
>
> Hi Bob,
>
> Although in practice,
>
> (1) parse_for_member() is rarely called "in quantity", and
> (2) when it is called, it would only encounter this with "char *" members, and
> (3) the string would also have to have a '%' in it.
>
> On the other hand, if you test the two print-types with a million calls,
> there's a significant performance hit. But if a strstr() is done first
> on the string, there's virtually no hit at all if there's no '%' in it.
>
> So yes, I agree with you that the string-search/conditional call should be done.
> I'll add that to your patch, and queue it for crash-6.0.9.
>
> Thanks,
> Dave
>
> --
> Crash-utility mailing list
> Crash-utility@redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 08-10-2012 02:16 PM

Patch to fix Seg Violation in parse_for_member
 
----- Original Message -----
> What about replacing that fprintf() with fprintf(pc->saved_fp, "%s",
> buf) or even fputs(buf, pc->saved_fp)?

Hmmm, that would be preferable -- let me test that...

Thanks,
Dave

> On Fri, Aug 10, 2012 at 2:55 PM, Dave Anderson <anderson@redhat.com>
> wrote:
> >
> >
> > ----- Original Message -----
> >> On Thu, 2012-08-09 at 16:23 -0600, Bob Montgomery wrote:
> >> > If you change the
> >> > fprintf(pc->saved_fp, buf);
> >> > lines to
> >> > print_verbatim(pc->saved_fp, buf);
> >> >
> >> > Then I won't get:
> >> >
> >> > crash> sk_buff.head ffff88012014dc80
> >> > Segmentation fault
> >> >
> >> > When I need to get:
> >> >
> >> > crash> sk_buff.head ffff88012014dc80
> >> > head = 0xffff880121267000 ""%s %s %s", got type "%s""
> >> >
> >> >
> >> > Patch attached (6.0.8).
> >> >
> >> > I suspect performance will suffer a bit when I try to print
> >> > 2 million of these...
> >>
> >> Wonder if it would be quicker on average to string search for "%"
> >> and
> >> conditionally call print_verbatim??? I had lots of successful
> >> fprintf's and only a small number of seg viol cases.
> >>
> >> Bob M.
> >
> > Hi Bob,
> >
> > Although in practice,
> >
> > (1) parse_for_member() is rarely called "in quantity", and
> > (2) when it is called, it would only encounter this with "char *"
> > members, and
> > (3) the string would also have to have a '%' in it.
> >
> > On the other hand, if you test the two print-types with a million
> > calls,
> > there's a significant performance hit. But if a strstr() is done
> > first
> > on the string, there's virtually no hit at all if there's no '%' in
> > it.
> >
> > So yes, I agree with you that the string-search/conditional call
> > should be done.
> > I'll add that to your patch, and queue it for crash-6.0.9.
> >
> > Thanks,
> > Dave
> >
> > --
> > Crash-utility mailing list
> > Crash-utility@redhat.com
> > https://www.redhat.com/mailman/listinfo/crash-utility
>
> --
> Crash-utility mailing list
> Crash-utility@redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Dave Anderson 08-10-2012 03:12 PM

Patch to fix Seg Violation in parse_for_member
 
----- Original Message -----
>
>
> ----- Original Message -----
> > What about replacing that fprintf() with fprintf(pc->saved_fp, "%s", buf)
> > or even fputs(buf, pc->saved_fp)?
>
> Hmmm, that would be preferable -- let me test that...

Both options work as expected -- I'll go with the former.

Thanks Adrien,
Dave

> > On Fri, Aug 10, 2012 at 2:55 PM, Dave Anderson
> > <anderson@redhat.com>
> > wrote:
> > >
> > >
> > > ----- Original Message -----
> > >> On Thu, 2012-08-09 at 16:23 -0600, Bob Montgomery wrote:
> > >> > If you change the
> > >> > fprintf(pc->saved_fp, buf);
> > >> > lines to
> > >> > print_verbatim(pc->saved_fp, buf);
> > >> >
> > >> > Then I won't get:
> > >> >
> > >> > crash> sk_buff.head ffff88012014dc80
> > >> > Segmentation fault
> > >> >
> > >> > When I need to get:
> > >> >
> > >> > crash> sk_buff.head ffff88012014dc80
> > >> > head = 0xffff880121267000 ""%s %s %s", got type "%s""
> > >> >
> > >> >
> > >> > Patch attached (6.0.8).
> > >> >
> > >> > I suspect performance will suffer a bit when I try to print
> > >> > 2 million of these...
> > >>
> > >> Wonder if it would be quicker on average to string search for
> > >> "%"
> > >> and
> > >> conditionally call print_verbatim??? I had lots of successful
> > >> fprintf's and only a small number of seg viol cases.
> > >>
> > >> Bob M.
> > >
> > > Hi Bob,
> > >
> > > Although in practice,
> > >
> > > (1) parse_for_member() is rarely called "in quantity", and
> > > (2) when it is called, it would only encounter this with "char
> > > *"
> > > members, and
> > > (3) the string would also have to have a '%' in it.
> > >
> > > On the other hand, if you test the two print-types with a million
> > > calls,
> > > there's a significant performance hit. But if a strstr() is done
> > > first
> > > on the string, there's virtually no hit at all if there's no '%'
> > > in
> > > it.
> > >
> > > So yes, I agree with you that the string-search/conditional call
> > > should be done.
> > > I'll add that to your patch, and queue it for crash-6.0.9.
> > >
> > > Thanks,
> > > Dave
> > >
> > > --
> > > Crash-utility mailing list
> > > Crash-utility@redhat.com
> > > https://www.redhat.com/mailman/listinfo/crash-utility
> >
> > --
> > Crash-utility mailing list
> > Crash-utility@redhat.com
> > https://www.redhat.com/mailman/listinfo/crash-utility
> >
>

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility


All times are GMT. The time now is 03:28 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.