Bug 31212 - seekdir() unexpected directory stream positioning on 32bit arm
Summary: seekdir() unexpected directory stream positioning on 32bit arm
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.37
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-04 21:53 UTC by Petre Rodan
Modified: 2024-01-21 19:11 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
seekdir test for armv7 (317 bytes, text/x-csrc)
2024-01-04 21:53 UTC, Petre Rodan
Details
output of emerge --info (2.06 KB, text/plain)
2024-01-05 08:49 UTC, Petre Rodan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petre Rodan 2024-01-04 21:53:08 UTC
Created attachment 15284 [details]
seekdir test for armv7

hi there!

my stable branch Gentoo Linux comes with a 32-bit specific patch to glibc 2.37, found here [1] - I guess the offending patch is the one that modifies sysdeps/unix/sysv/linux/seekdir.c to add the _DIRENT_OFFSET_TRANSLATION ifdef block.

I have attached a sample test which I run on my armv7. the output reads:

 ./main
 pre:           . .. clockevents platform w1 serio iio gpio event_source mdio_bus soc cpu mmc scsi mmc_rpmb spi clocksource hid dp-aux usb serial serial-base
cec sdio genpd nvmem gadget workqueue virtio container i2c mipi-dsi
 s0 location:  4294967295
 s0 entries:
 rew location: 1
 rew entries:   . .. clockevents platform w1 serio iio gpio event_source mdio_bus soc cpu mmc scsi mmc_rpmb spi clocksource hid dp-aux usb serial serial-base
cec sdio genpd nvmem gadget workqueue virtio container i2c mipi-dsi

as you can see, seekdir(dp, 0) leaves the location at an invalid -1 value
while rewinddir(dp) works correctly.
I guess that patch is already part of the glibc repo, so can you reproduce the problem on an armv7?

running the test program on an amd64 Gentoo that contains the same patches returns a perfect output.

thanks,
peter

[1] https://gitweb.gentoo.org/proj/toolchain/glibc-patches.git/tree/9999/0005-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
Comment 1 Petre Rodan 2024-01-05 08:49:52 UTC
Created attachment 15286 [details]
output of emerge --info

for a bit of context, the bug started here

https://lkml.org/lkml/2024/1/4/281

and for the Gentoo toolchain devs I will attach the emerge --info and the glibc USE flags

[ebuild   R    ] sys-libs/glibc-2.37-r7:2.2::gentoo  USE="caps gd multiarch ssp static-libs -audit -cet -compile-locales -crypt -custom-cflags -doc -hash-sysv-compat -headers-only -multilib -multilib-bootstrap -nscd -perl -profile (-selinux) -stack-realign -suid -systemd -systemtap -test -vanilla" 18308 KiB
Comment 2 Andreas K. Huettel 2024-01-06 09:32:08 UTC
These are non-standard patches that we carry in Gentoo, so it's not really glibc's fault.

That said, it probably makes sense to track it here since the patches are a workaround to a longstanding glibc problem.