[Gluster-devel] readdir() harmful in threaded code
Emmanuel Dreyfus
manu at netbsd.org
Wed Feb 10 13:48:52 UTC 2016
Hi
After obtaining a core in a regression, I noticed there are a few readdir()
use in threaded code. This is begging for a crash, as readdir() maintains
an internal state that will be trashed on concurent use. readdir_r()
should be used instead.
A quick search shows readdir(à usage here:
contrib/fuse-util/mount_util.c:30
extras/test/ld-preload-test/ld-preload-test.c:310
extras/test/test-ffop.c:550
libglusterfs/src/compat.c:256
libglusterfs/src/compat.c:315
libglusterfs/src/syscall.c:97
tests/basic/fops-sanity.c:662
tests/utils/arequal-checksum.c:331
Occurences in contrib, extra and tests are probably harmless are there
are usage in standalone programs that are not threaded. We are left with
three groups of problems:
1) libglusterfs/src/compat.c:256 and libglusterfs/src/compat.c:315
This is Solaris compatibility code. Is it used at all?
2) libglusterfs/src/syscall.c:97 This is the sys_readdir() wrapper,
which is in turn used in:
libglusterfs/src/run.c:284
xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c:582
xlators/features/changelog/lib/src/gf-history-changelog.c:854
xlators/features/index/src/index.c:471
xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
xlators/storage/posix/src/posix.c:3700
xlators/storage/posix/src/posix.c:5896
3) We also find sys_readdir() in libglusterfs/src/common-utils.h for
GF_FOR_EACH_ENTRY_IN_DIR() which in turn appears in:
libglusterfs/src/common-utils.c:3979
libglusterfs/src/common-utils.c:4002
xlators/mgmt/glusterd/src/glusterd-hooks.c:365
xlators/mgmt/glusterd/src/glusterd-hooks.c:379
xlators/mgmt/glusterd/src/glusterd-store.c:651
xlators/mgmt/glusterd/src/glusterd-store.c:661
xlators/mgmt/glusterd/src/glusterd-store.c:1781
xlators/mgmt/glusterd/src/glusterd-store.c:1806
xlators/mgmt/glusterd/src/glusterd-store.c:3044
xlators/mgmt/glusterd/src/glusterd-store.c:3072
xlators/mgmt/glusterd/src/glusterd-store.c:3593
xlators/mgmt/glusterd/src/glusterd-store.c:3606
xlators/mgmt/glusterd/src/glusterd-store.c:4032
xlators/mgmt/glusterd/src/glusterd-store.c:4111
There a hive of sprious bugs to squash here.
--
Emmanuel Dreyfus
manu at netbsd.org
More information about the Gluster-devel
mailing list