Skip Menu |
 

Subject: large default FD_SETSIZE and stack consumption in 1.3.5 krb5 library
Download (untitled) / with headers
text/plain 1.1KiB
Hi -

Under AIX 5.2, the default size of fd_set is 8KB or about 64K
descriptors. This recently caused a thread stack overflow problem for
us when using the krb5 client library.

For the problematic threads, it turned out that the biggest contributer
to stack use was a couple of select_state structures pushed on the
stack in the kerberos client library - used for example when contacting
the kdc in the krb5_gss_init_sec_context() call chain. select_state
looks like this:

struct select_state {
int max;
int nfds;
fd_set rfds;
fd_set wfds;
fd_set xfds;
struct timeval end_time;
};

We were using 64KB thread stacks for credential management. But the
call path from krb5_gss_init_sec_context() to krb5int_cm_call_select()
consumes about 73KB of stack on AIX 5.2.

I'm not sure if there are other unix variants with a huge default
FD_SETSIZE. But, it seems like addressing this by replacing select()
with poll(), putting fd_set structures on the heap instead of the stack
or even defining -DFD_SETSIZE=<something_reasonable> for systems with an
extremely large default FD_SETSIZE (is there anywhere in the kerberos
code that needs 64K open file descriptors?) would be worth doing.

Thanks,
-Damian
From: raeburn@mit.edu
Subject: CVS Commit
* sendto_kdc.c (service_fds): Don't create a select_state on the stack; take an
additional argument pointing to it.
(krb5int_sendto): Don't create a select_state on the stack; instead, allocate
two on the heap, passing the second as the new argument to service_fds.


To generate a diff of this commit:



cvs diff -r5.422 -r5.423 krb5/src/lib/krb5/os/ChangeLog
cvs diff -r5.75 -r5.76 krb5/src/lib/krb5/os/sendto_kdc.c
Could you please try out the attached patch?
It should put the select_state structures in the library into the heap
instead of on the stack. (There's also an automatic variable in the
KDC, but since that's single-threaded at the moment I assume it's not a
problem.)

The patch is relative to the current development code, not 1.3.5, but I
don't think that code has changed so much that you won't be able to
apply it...

Ken
Download 2
application/octet-stream 4.4KiB

Message body not shown because it is not plain text.

To: dhazen@lbl.gov
Cc: rt@krbdev.mit.edu
Subject: [krbdev.mit.edu #3060] large default FD_SETSIZE and stack consumption in 1.3.5 krb5 library
From: Ken Raeburn <raeburn@MIT.EDU>
Date: Thu, 09 Jun 2005 22:12:21 -0400
RT-Send-Cc:

Oops, I don't think the patch got mailed out. Stupid web interface...
Download 2
application/octet-stream 4.4KiB

Message body not shown because it is not plain text.

From: tlyu@mit.edu
Subject: CVS Commit
pullup from trunk


To generate a diff of this commit:



cvs diff -r5.412.2.9 -r5.412.2.10 krb5/src/lib/krb5/os/ChangeLog
cvs diff -r5.74 -r5.74.4.1 krb5/src/lib/krb5/os/sendto_kdc.c