[gambit-list] Gambit crash with over 1024 file descriptors

Dimitris Vyzovitis vyzo at hackzen.org
Mon Mar 25 02:03:34 EDT 2013


I guess this shouldn't be too big a surprise given this definition:
/usr/include/bits/typesizes.h:#define	__FD_SETSIZE		1024

/usr/include/sys/select.h:
 typedef struct
  {
#ifdef __USE_XOPEN
    __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->fds_bits)
#else
    __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
# define __FDS_BITS(set) ((set)->__fds_bits)
#endif
  } fd_set;

#define __NFDBITS	(8 * (int) sizeof (__fd_mask))

So great. Gambit can't do more than 1024 file descriptors, unless the
scheduler is fixed to use poll instead of select.

-- vyzo

On Sun, Mar 24, 2013 at 10:45 PM, Dimitris Vyzovitis <vyzo at hackzen.org> wrote:
> I have a program uses large numbers of file descriptors (over 1024),
> and it crashes miserably in __fortify_fail. Turning off
> FORTIFY_SOURCE/stack-protector results in a plain old segfault.
>
> Reproducing with the attached program (crash-it.scm):
> Platform is GNU/Linux x86-64, gcc is 4.6.3.
> You need to set your ulimit over 1024 to trigger the crash (otherwise
> you'll just get "Too many open files" and rain of "integer expected"
> from the looping threads)
>
> $ ulimit -n
> 4096
> $ gsi crash-it.scm -e "(go 1500)"
> *** buffer overflow detected ***: gsi terminated
> ======= Backtrace: =========
> /lib64/libc.so.6(__fortify_fail+0x37)[0x7fb775187dd7]
> /lib64/libc.so.6(+0xfdbe0)[0x7fb775185be0]
> /lib64/libc.so.6(+0xffd8e)[0x7fb775187d8e]
> /usr/local/gambit/current/lib/libgambc.so(___device_select_add_fd+0x55)[0x7fb775d625c5]
> /usr/local/gambit/current/lib/libgambc.so(+0x227a91)[0x7fb775d62a91]
> /usr/local/gambit/current/lib/libgambc.so(___device_select+0x104)[0x7fb775d62324]
> /usr/local/gambit/current/lib/libgambc.so(___os_condvar_select+0x141)[0x7fb775d64d61]
> /usr/local/gambit/current/lib/libgambc.so(+0x2310a1)[0x7fb775d6c0a1]
> /usr/local/gambit/current/lib/libgambc.so(___call+0xfa)[0x7fb775d4d2ba]
> /usr/local/gambit/current/lib/libgambc.so(___setup+0xfc0)[0x7fb775d4f760]
> /usr/local/gambit/current/lib/libgambc.so(___main+0x2a7)[0x7fb775d4bf57]
> /usr/local/gambit/current/lib/libgambc.so(___main_char+0xb0)[0x7fb775d59200]
> /lib64/libc.so.6(__libc_start_main+0xed)[0x7fb7750ac60d]
> gsi[0x403199]
>
> Build config:
> ./configure
>  --prefix=/usr/local/gambit
>  --enable-single-host
>  --enable-c-opt
>  --enable-gcc-opts
>  --enable-multiple-versions
>  --enable-shared
>
> To build without fortifications:
>  ./configure CFLAGS="-U_FORTIFY_SOURCE -fno-stack-protector" ...
> And you'll get a segfault.
>
> -- vyzo



More information about the Gambit-list mailing list