Hi Mark,

On Mon, Feb 3, 2025 at 8:36 AM Mark Wielaard <m...@klomp.org> wrote:
>
> I think this subtly changes what is being tested here.  If I remember
> correctly this tests that gelf_getshdr works correctly even when the
> underlying fd is closed and the file is either mmapped or elf_cntl
> with ELF_C_FDREAD is called.
>
> The idea being that if the file is mmapped then everything needed for
> reading the ELF file is already in memory. And when elf_cntl is called
> with ELF_C_FDREAD then libelf must make sure the same is true.
>
> You could argue that the test should explicitly call elf_cntl with
> ELF_C_FDDONE after the close (fd) though.
>
> So I don't think close should be called unconditionally.  Maybe the
> correct solution is to do if (!close_fd) close (fd); after elf_end?

Thanks for the clarification. I think you're right about simply
including `if (!close_fd) close (fd)` at the end. The test still
passes for me with that change.

I've dropped this patch and instead included the `if (!close_fd)...`
change in patch 5/5 "tests: Avoid leaking file descriptors". Are you
ok with me pushing the series with this change or would you prefer I
repost the series?

Aaron

Reply via email to