Bug 1740525 - event: rename event_XXX with gf_ prefixed to avoid crash when apps linked libevent at the same time
Summary: event: rename event_XXX with gf_ prefixed to avoid crash when apps linked lib...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: core
Version: 6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: bugs@gluster.org
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-13 08:23 UTC by Xiubo Li
Modified: 2020-02-10 17:31 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-02-10 17:31:42 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gluster.org Gerrit 23219 0 None Open event: rename event_XXX with gf_ prefixed 2019-08-28 08:35:22 UTC

Description Xiubo Li 2019-08-13 08:23:49 UTC
Description of problem:

event: rename event_XXX with gf_ prefixed

I hit one crash issue when using the libgfapi.

In the libgfapi it will call glfs_poller() --> event_dispatch()
in file api/src/glfs.c:721, and the event_dispatch() is defined
by libgluster locally, the problem is the name of event_dispatch()
is the extremly the same with the one from libevent package form
the OS.

For example, if a executable program Foo, which will also use and
link the libevent and the libgfapi at the same time, I can hit the
crash, like:

kernel: glfs_glfspoll[68486]: segfault at 1c0 ip 00007fef006fd2b8 sp
00007feeeaffce30 error 4 in libevent-2.0.so.5.1.9[7fef006ed000+46000]

The link for Foo is:
lib_foo_LADD = -levent $(GFAPI_LIBS)
It will crash.

This is because the glfs_poller() is calling the event_dispatch() from
the libevent, not the libglsuter.

The gfapi link info :
GFAPI_LIBS = -lacl -lgfapi -lglusterfs -lgfrpc -lgfxdr -luuid

If I link Foo like:
lib_foo_LADD = $(GFAPI_LIBS) -levent
It will works well without any problem.

And if Foo call one private lib, such as handler_glfs.so, and the
handler_glfs.so will link the GFAPI_LIBS directly, while the Foo won't
and it will dlopen(handler_glfs.so), then the crash will be hit everytime.

The link info will be:
foo_LADD = -levent
libhandler_glfs_LIBADD = $(GFAPI_LIBS)

I can avoid the crash temporarily by linking the GFAPI_LIBS in Foo too like:
foo_LADD = $(GFAPI_LIBS) -levent
libhandler_glfs_LIBADD = $(GFAPI_LIBS)

But this is ugly since the Foo won't use any APIs from the GFAPI_LIBS.

And in some cases when the --as-needed link option is added(on many dists
it is added as default), then the crash is back again, the above workaround
won't work.



How reproducible:

Link libveent and libgfapi at the same time, then run the app.

Comment 1 Worker Ant 2019-08-13 08:26:42 UTC
REVIEW: https://review.gluster.org/23219 (event: rename event_XXX with gf_ prefixed) posted (#1) for review on release-6 by Xiubo Li

Comment 2 hari gowtham 2019-08-28 08:34:17 UTC
The bug for mainline is: https://github.com/gluster/glusterfs/issues/699

Comment 3 Worker Ant 2019-08-28 08:35:23 UTC
REVIEW: https://review.gluster.org/23219 (event: rename event_XXX with gf_ prefixed) merged (#2) on release-6 by hari gowtham


Note You need to log in before you can comment on or make changes to this bug.