Page MenuHome GnuPG

GPGME: gpgme_io_spawn issues
Testing, NormalPublic

Description

When closefrom is not available, it uses get_max_fds.

get_max_fds implementation has following issues:

  • return type mismatch: int is good
  • TRACE may calls non-async-signal-safe function, may result hang (in multithread application)
  • sysconf is not async-signal-safe function, may result hang (in multithread application)
  • syscall return type is long. For 64-bit arch, it has unseen type conversion from long to int, which is difficult to read. Use of long for r and pos is good.
  • On a machine which doesn't allow unaligned access, dir_buf should be aligned properly (__attribute__ ((aligned (8))). getdents64 itself would be OK for the kernel (glibc documentation seems to say so) with unaligned buf, but dir_entry->d_reclen is not.

Event Timeline

gniibe triaged this task as Normal priority.Jun 20 2025, 2:07 AM
gniibe created this task.
gniibe removed a project: golang.

iirc we introduced sysconf (_SC_OPEN_MAX) for non-linux platforms and that fixed real world problems. What about getting this value at module initialization time and keep on using it as a fallback?

OK. I'll add a code for setting the fallback value in _gpgme_io_subsystem_init and use it from get_max_fds.