Description
- Platform: Linux dennis-thinkpad 4.15.0-39-generic Fix compile on DragonFly and FreeBSD #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Info: When try to create more connections to a mysql server, panic at
FD_SET
. - Error:
panicked 'index out of bounds: the len is 16 but the index is 53' at
"/root/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/libc-0.2.58/src/unix/notbsd/mod.rs:1177"
Activity
killme2008 commentedon Jun 14, 2019
We don't use libc derectly, but use nix-0.11.0 such as
Panic at
fd_set.insert(socket_fd)
.gnzlbg commentedon Jun 14, 2019
@killme2008 could you compile with
--features=extra_traits
, and dumpfd_set
andsocket_fd
before the insert call?
cc @asomers
asomers commentedon Jun 14, 2019
This is probably a bug in your application.
select
can only be used with file descriptors up toFD_SETSIZE
.gnzlbg commentedon Jun 14, 2019
@asomers does nix expose a "safe" wrapper over these APIs ?
asomers commentedon Jun 14, 2019
No need. libc's exported
FD_SET
is already safe. That's why the application panic()ed rather than segfaulted.gnzlbg commentedon Jun 14, 2019
Ok, then I'm going to leave this open here. While I agree with you that the bug is in user code, I think we should be providing a better error message in this situation, e.g., by asserting at the beginning of the function that the indices must be in bounds, and explaining what those bounds are, at least in debug mode via a
debug_assert!
.tgross35 commentedon Aug 29, 2024
For anyone looking to help, these functions
libc/src/unix/linux_like/mod.rs
Lines 1541 to 1586 in 5431bdb
.get(...).unwrap_or_else(|| panic!(...))
rather than[...]
indexing.highjeans commentedon Mar 18, 2025
Just for clarification, the functions prefixed with
FD_
are for file descriptors? What aboutCMSG_
?asomers commentedon Mar 18, 2025
The
CMSG_
functions are not related. They are intended for use with sendmsg(2) and recvmsg(2), whereas theFD_
functions are for use with select(2).