autofs5 eats the cpu if you have large groups
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
autofs5 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Lucid |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: autofs5
The issue is in lib/mounts.c, set_tsd_user_vars - editing out the boring bits, it looks like this:
grplen = sysconf(
while (1) {
char *tmp = realloc(gr_tmp, tmplen+1);
if (status != ERANGE)
}
It's trying to get the members of the users primary group, but doesn't know how big a buffer to allocate, so it keeps trying until the buffer is big enough, incrementing it each time. The increment is only 1024 bytes at a time, however, so it takes several hundred iterations to get a big enough buffer.
This shouldn't be relying on_SC_GETGR_
I've verified that bumping the increment value by 1000x fixes the issue, and stat'ing non-existent homedirs is now instantaneous.
tags: | added: glucid |
tags: |
added: verification-done removed: verification-needed |
One option would be to double tmplen each pass. That would make it take, in my case, 10 tries, rather than ~750.
so:
- tmplen += grplen;
+ tmplen *= 2;