[ntp:hackers] Segfaults in ntp-dev

Paul Vixie paul at vix.com
Mon Jun 4 00:16:45 PDT 2007


dave wrote:

> This is bogus.

yes.  but it's the standard, and it works everywhere, and it works well.

> The original architecture of Algol 60 and eventually Algol 68 was principle
> driven and well conceived. Nonsense creation of structures by implication is
> evil.

yes.  i thought so when this happened and i think so now, too.  but i use 'em,
since it makes code clearer.

> What happens if I record the pointers and later attempt to free them?

that's nonsequitur for two reasons.  first, these are intermediate results,
you can no more take the address of a returned aggregate than you could take
the address of the expression (1+3).  second, not all pointers are into the
heap, and if you attempt to free something that's not in the heap, you'll
either corrupt the heap or segfault.

> It might even work, but that is not an appropriate architectural model.

again, i agree that it's not really C.  but it is ANSI C and it's the brave
new world we live in, and a lot of published API's depend on aggregates being
passed into functions and returned from functions.  and they don't have to be
small enough to fit into machine words.  i don't know where they put them and
i don't care because i don't have to know.  it makes code cleaner.  i'm
assuming that the usual convention is "allocate space on the caller's stack
and pass the address of this as an implicit argument".  but it could be
written in Cheez Whiz on the back of a flea on some machine/compiler combos,
and i wouldn't care, because as i've said, it makes code cleaner.


More information about the hackers mailing list