Skip to content

[linux] fix segfault when eventpoll fdinfo is unavailable - #368

Merged
jiegec merged 1 commit into
lsof-org:masterfrom
daeho-ro:fix-eventpoll-tfd-count-sentinel
Aug 12, 2026
Merged

[linux] fix segfault when eventpoll fdinfo is unavailable#368
jiegec merged 1 commit into
lsof-org:masterfrom
daeho-ro:fix-eventpoll-tfd-count-sentinel

Conversation

@daeho-ro

Copy link
Copy Markdown
Contributor

tfd_count is declared size_t (dproc.c:97), but process_id() uses -1 as its "no fdinfo" sentinel (dproc.c:1222). It becomes SIZE_MAX, so the fi.tfd_count > 0 guard passes where the != -1 siblings skip, and snp_eventpoll() qsorts SIZE_MAX entries of a 32-entry array:

#4  __GI___qsort_r (total_elems=18446744073709551615, size=4, cmp=fd_compare)
#5  process_id ()

This hits any run with OffType != OFFSET_FDINFO that reports a process holding an epoll descriptor. Declaring it int matches tfds[] and the eventfd_id/pid sentinels.

Comment thread lib/dialects/linux/dproc.c Outdated
process_id() pre-fills -1 sentinels for the oty == 0 case, but tfd_count is size_t, so -1 becomes SIZE_MAX and the `fi.tfd_count > 0` guard passes where the `!= -1` siblings skip. snp_eventpoll() then qsorts SIZE_MAX entries of a 32-entry array. Declare it ssize_t so the sentinel compares as negative while the struct layout stays the same.
@daeho-ro
daeho-ro force-pushed the fix-eventpoll-tfd-count-sentinel branch from fdebebf to e1f8076 Compare August 12, 2026 14:08
@jiegec
jiegec merged commit 2f75875 into lsof-org:master Aug 12, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants