From: Shawn Ostermann (firstname.lastname@example.org)
Message-Id: <F2C278DE-D2E3-43C4-9B2B-E1CB6D2E5ED0@eecs.ohiou.edu> From: Shawn Ostermann <email@example.com> Subject: Re: tcptrace-bugs Static variable returns of HostName() are not consider by callers Date: Wed, 4 Jan 2006 14:44:07 -0500
We should talk about this first. The extra overhead of the strdup()
plus the free() after the printf() will be expensive. And, of
course, somebody will forget to use free, or will have a custom bit
of code that doesn't use it, which will lead to a terrible memory
leak that will be very difficult to find.
I guess my suggestion is to:
1) Change the name of HostName() to something like TempHostName() and
then use that everywhere instead in OUR code
2) Create a new HostName() that calls TempHostName() and then strdup().
I can't remember for sure, how soon do you lose the HostName()
buffer? Is it nondeterministic?
On Jan 4, 2006, at 12:57 PM, Manikantan Ramadas wrote:
>>> Every where else where HostName() gets called, it is merely
>>> for debug-help printf messages;
>> I agree, the hazard is there but it is ignored only in few debug
>> (AFAIK). It really *did* manifest as wrong behavior that made
>> debugging of
>> another bug in 6.6.1 (when dst_port==src_port, seems to be fixed
>> now in
>> 6.6.7) a lot harder until I fixed the printf()s... It's not nice
>> suggesting that debugging printf()s are allowed to mislead, which was
>> the case in this instance...
> I was under the impression that no one ran into a manifestation
> of this wrong behavior (by which I mean incorrect debug printfs),
> and therefore took the stance of why fix things if they aren't broken.
> But I take your word on this one. The easiset fix would be to wrap
> up those HostName() calls in strdup() in those debug printfs.
> Should be easy to do. I shall do that for the long over-due next
> bugfix release of tcptrace.
> "The quieter you become, the more you can hear." - Baba Ram Dass.
> * Manikantan Ramadas * IRG, OU * http://irg.cs.ohiou.edu/~mramadas *
This archive was generated by hypermail 2.1.7 : 01/05/06 EST