| Summary: | [patch] accept(2) can return EINVAL for undocumented reason | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Documentation | Reporter: | Arne H Juul <arnej> | ||||
| Component: | Books & Articles | Assignee: | Remko Lodder <remko> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Latest | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
Arne H Juul
2005-05-03 19:40:01 UTC
On 2005-05-03 20:35, Arne H Juul <arnej@europe.yahoo-inc.com> wrote: > We had a problem where a daemon wouldn't read commands on its socket; > after some debugging we found that accept() on the socket didn't work > (with errno EINVAL). According to man 2 accept this can only be > caused by "listen(2) has not been called" but after more intensive > debugging we couldn't figure out how that was possible in our program. > > Inspection of the actual kernel source for accept(2) however shows > that it also returns EINVAL when the namelen argument is negative; it > turns out the program had a stupid bug where the namelen was > uninitialized causing accept() to fail unpredicably depending on stack > contents. The following documentation fix would (hopefully) have > saved us some time chasing down codepaths through listen(). True! The relevant bits in CURRENT are in uipc_syscalls.c (which you already know, but I'm posting here for the audit trail): 281 static int 282 accept1(td, uap, compat) ... 290 { ... 307 if (namelen < 0) 308 return (EINVAL); > .It Bq Er EINVAL > .Xr listen 2 > has not been called on the socket descriptor. > +.It Bq Er EINVAL > +The > +.Fa addrlen > +argument is negative. I think that documenting both cases in a single paragraph of accept(2) is ok too: .It Bq Er EINVAL .Xr listen 2 -has not been called on the socket descriptor. +has not been called on the socket descriptor or the +.Fa addrlen +argument is negative. If this change to the diff is ok with you too, I'll see that it gets committed. - Giorgos Responsible Changed From-To: freebsd-bugs->freebsd-doc Patch provided is against the documentation, not the kernel. On Wed, 4 May 2005, Giorgos Keramidas wrote: > I think that documenting both cases in a single paragraph of accept(2) > is ok too: > > .It Bq Er EINVAL > .Xr listen 2 > -has not been called on the socket descriptor. > +has not been called on the socket descriptor or the > +.Fa addrlen > +argument is negative. This is just a style thing, and personally I don't really mind either way; other system call man pages have separate paragraphs for same errno with different reasons, so I think it's best to follow that style. -- Arne H Juul Mail: arnej@europe.yahoo-inc.com Release engineer Web: http://www.yahoo.com/ Yahoo Norway Phone: +47 7320 1219 Prinsensgate 49, 7013 Trondheim Fax: +47 7320 1201 State Changed From-To: open->closed The original diff has been committed to CURRENT. In a few days I'll merge this to -STABLE versions. Thanks :) Responsible Changed From-To: freebsd-doc->keramida State Changed From-To: closed->patched Keep this open (as 'patched') until I merge it to STABLE. State Changed From-To: patched->closed I merged it to RELENG_5 per request of rionda. Also make sure that I get a pointyhat if something goes wrong instead of keramida. Responsible Changed From-To: keramida->remko I merged it to RELENG_5 per request of rionda. Also make sure that I get a pointyhat if something goes wrong instead of keramida. |