readlink -f still segfaults

Rob Landley rob at landley.net
Fri May 5 21:02:35 UTC 2006


On Friday 05 May 2006 6:54 am, Natanael Copa wrote:
> It looks to me that it always needs to be free'd.
> The previous way realpath(..., NULL) gnu extension allocates for you
> when buffer is NULL.

Which is smaller.  You're saying that uClibc 0.9.28 doesn't do this, though?

Hmmm...  Sounds like we're getting into platform.c territory.  The bb_strlen() 
thing really should be in libbb/platform.c rather than xfuncs.c because 
substituting our own strlen() function to force uninlining is a workaround 
for a broken compiler that can't be told _NOT_ to inline something that's 
used over 500 times in the code.

This is another case where using the gnu extension in glibc's realpath() is 
smaller when we can do that, but we need our own bb_realpath() that calls 
xmalloc() when that's not available.

Time for new infrastructure...

> When no -f is specified xreadlink will use xrealloc to allocate memory.
>
> I cannot see why
>
> if (ENABLE_CLEANUP && (opt & READLINK_FLAG_f)) free(buf);
>
> should be there.
>
> Am I missing something?

This is unrelated.  We let exit() free our memory most of the time, because 
that makes our binary smaller by avoiding explicit calls to free.  But 
sometimes we want it to explicitly free stuff (primarily to make debuggers 
and resource profilers happy), so we have a configuration option for it.  
That produces the ENABLE macros, which are defined as either 1 or 0, meaning 
the test is resolved at compile time, the test optimizes away, and the 
corresponding code is either included or not included.

> > and make a simple
> > testsuite/readlink.tests
>
> I'm pretty new to this. Are there any docs on how to create testcases?

No, but testsuite/uniq.tests is a good example.  Basically it's a shell script 
that imports "testing.sh", which provides the "testing" function, which takes 
five arguments as described in that file.  There's also the "option" macro 
which checks the config and possibly skips the following tests, until the 
next "option" macro.  (They're not cumulative, each one resets the "skip" 
flag based on what it's checking.)

> > That'd be awesome!

Which is a synonym for "optional". :)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list