Bug 91869 - [PATCH] ralloc: atexit(3) handlers used in dlopened libraries
Summary: [PATCH] ralloc: atexit(3) handlers used in dlopened libraries
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: 10.6
Hardware: Other FreeBSD
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-03 18:24 UTC by Jean-Sébastien Pédron
Modified: 2017-03-22 16:32 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch to use __attribute__((destructor)) in ralloc.c (2.30 KB, text/plain)
2015-09-03 18:24 UTC, Jean-Sébastien Pédron
Details
Patch to use __attribute__((destructor)) in ralloc.c (3.20 KB, patch)
2015-09-07 09:00 UTC, Jean-Sébastien Pédron
Details | Splinter Review

Description Jean-Sébastien Pédron 2015-09-03 18:24:00 UTC
Created attachment 118072 [details]
Patch to use __attribute__((destructor)) in ralloc.c

Hi!

On Linux, atexit(3) handlers are called when the program exits but also when a library is unloaded. The latter behavior is a Glibc extension.

On systems where this extension is not supported, this causes an application to crash when, for instance, a library using ralloc is dlclosed: at program exit, the registered function is no longer in memory. For example, this happens with OpenCL applications using an ICD loader on FreeBSD.

__attribute__((destructor)) fixes the problem because such handlers are called when a library is unloaded and when the program exits.
Comment 1 Jean-Sébastien Pédron 2015-09-07 09:00:14 UTC
Created attachment 118120 [details] [review]
Patch to use __attribute__((destructor)) in ralloc.c

This new patch adds a test for __attribute__((destructor)) in the configure script and hides this attribute behind a "DESTRUCTOR" macro in src/util/macros.h.

This is requested by Matt Turner on the mesa-dev@ mailing-list.
Comment 2 Vedran Miletić 2017-03-22 16:32:23 UTC
atexit() no longer exists in src/util/ralloc.{c,h}


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.