* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
@ 2023-08-22 10:49 ` fweimer at redhat dot com
2023-08-22 10:49 ` fweimer at redhat dot com
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-08-22 10:49 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
Flags| |security-
See Also| |https://bugzilla.redhat.com
| |/show_bug.cgi?id=2233338
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
2023-08-22 10:49 ` [Bug dynamic-link/30785] " fweimer at redhat dot com
@ 2023-08-22 10:49 ` fweimer at redhat dot com
2023-08-22 10:59 ` fweimer at redhat dot com
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-08-22 10:49 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=28937
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
2023-08-22 10:49 ` [Bug dynamic-link/30785] " fweimer at redhat dot com
2023-08-22 10:49 ` fweimer at redhat dot com
@ 2023-08-22 10:59 ` fweimer at redhat dot com
2023-08-22 13:55 ` sam at gentoo dot org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-08-22 10:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at sourceware dot org |fweimer at redhat dot com
--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
Patch posted:
[PATCH v3 0/2] Predictable ELF destructor ordering (bug 30785)
<https://inbox.sourceware.org/libc-alpha/cover.1692701787.git.fweimer@redhat.com/>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (2 preceding siblings ...)
2023-08-22 10:59 ` fweimer at redhat dot com
@ 2023-08-22 13:55 ` sam at gentoo dot org
2023-09-11 7:27 ` fweimer at redhat dot com
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sam at gentoo dot org @ 2023-08-22 13:55 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gentoo dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (3 preceding siblings ...)
2023-08-22 13:55 ` sam at gentoo dot org
@ 2023-09-11 7:27 ` fweimer at redhat dot com
2023-09-11 20:04 ` sam at gentoo dot org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-09-11 7:27 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Florian Weimer <fweimer at redhat dot com> ---
Fixed in 2.39 via:
commit 6985865bc3ad5b23147ee73466583dd7fdf65892
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Sep 8 12:32:14 2023 +0200
elf: Always call destructors in reverse constructor order (bug 30785)
The current implementation of dlclose (and process exit) re-sorts the
link maps before calling ELF destructors. Destructor order is not the
reverse of the constructor order as a result: The second sort takes
relocation dependencies into account, and other differences can result
from ambiguous inputs, such as cycles. (The force_first handling in
_dl_sort_maps is not effective for dlclose.) After the changes in
this commit, there is still a required difference due to
dlopen/dlclose ordering by the application, but the previous
discrepancies went beyond that.
A new global (namespace-spanning) list of link maps,
_dl_init_called_list, is updated right before ELF constructors are
called from _dl_init.
In dl_close_worker, the maps variable, an on-stack variable length
array, is eliminated. (VLAs are problematic, and dlclose should not
call malloc because it cannot readily deal with malloc failure.)
Marking still-used objects uses the namespace list directly, with
next and next_idx replacing the done_index variable.
After marking, _dl_init_called_list is used to call the destructors
of now-unused maps in reverse destructor order. These destructors
can call dlopen. Previously, new objects do not have l_map_used set.
This had to change: There is no copy of the link map list anymore,
so processing would cover newly opened (and unmarked) mappings,
unloading them. Now, _dl_init (indirectly) sets l_map_used, too.
(dlclose is handled by the existing reentrancy guard.)
After _dl_init_called_list traversal, two more loops follow. The
processing order changes to the original link map order in the
namespace. Previously, dependency order was used. The difference
should not matter because relocation dependencies could already
reorder link maps in the old code.
The changes to _dl_fini remove the sorting step and replace it with
a traversal of _dl_init_called_list. The l_direct_opencount
decrement outside the loader lock is removed because it appears
incorrect: the counter manipulation could race with other dynamic
loader operations.
tst-audit23 needs adjustments to the changes in LA_ACT_DELETE
notifications. The new approach for checking la_activity should
make it clearer that la_activty calls come in pairs around namespace
updates.
The dependency sorting test cases need updates because the destructor
order is always the opposite order of constructor order, even with
relocation dependencies or cycles present.
There is a future cleanup opportunity to remove the now-constant
force_first and for_fini arguments from the _dl_sort_maps function.
Fixes commit 1df71d32fe5f5905ffd5d100e5e9ca8ad62 ("elf: Implement
force_first handling in _dl_sort_maps_dfs (bug 28937)").
Reviewed-by: DJ Delorie <dj@redhat.com>
Backports in progress.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (4 preceding siblings ...)
2023-09-11 7:27 ` fweimer at redhat dot com
@ 2023-09-11 20:04 ` sam at gentoo dot org
2023-09-11 20:04 ` sam at gentoo dot org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sam at gentoo dot org @ 2023-09-11 20:04 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=15903
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (5 preceding siblings ...)
2023-09-11 20:04 ` sam at gentoo dot org
@ 2023-09-11 20:04 ` sam at gentoo dot org
2023-09-19 7:36 ` fweimer at redhat dot com
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sam at gentoo dot org @ 2023-09-11 20:04 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Sam James <sam at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.39
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (6 preceding siblings ...)
2023-09-11 20:04 ` sam at gentoo dot org
@ 2023-09-19 7:36 ` fweimer at redhat dot com
2023-10-06 9:09 ` fweimer at redhat dot com
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-09-19 7:36 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=30869
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (7 preceding siblings ...)
2023-09-19 7:36 ` fweimer at redhat dot com
@ 2023-10-06 9:09 ` fweimer at redhat dot com
2023-10-06 9:09 ` fweimer at redhat dot com
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-10-06 9:09 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #3 from Florian Weimer <fweimer at redhat dot com> ---
I think this change needs to be reverted.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (8 preceding siblings ...)
2023-10-06 9:09 ` fweimer at redhat dot com
@ 2023-10-06 9:09 ` fweimer at redhat dot com
2023-10-18 14:29 ` fweimer at redhat dot com
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-10-06 9:09 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|2.39 |---
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (9 preceding siblings ...)
2023-10-06 9:09 ` fweimer at redhat dot com
@ 2023-10-18 14:29 ` fweimer at redhat dot com
2023-10-18 14:38 ` fweimer at redhat dot com
2023-10-18 14:38 ` fweimer at redhat dot com
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-10-18 14:29 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |WONTFIX
Status|REOPENED |RESOLVED
--- Comment #4 from Florian Weimer <fweimer at redhat dot com> ---
The change has been reverted on all branches due to unforeseen application
compatibility issues.
I will file a new bug for a concrete issue in dlclose that I identified
regarding destructor ordering. We can work on a targeted fix for that.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (10 preceding siblings ...)
2023-10-18 14:29 ` fweimer at redhat dot com
@ 2023-10-18 14:38 ` fweimer at redhat dot com
2023-10-18 14:38 ` fweimer at redhat dot com
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-10-18 14:38 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=30981
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug dynamic-link/30785] Always call destructors in reverse constructor order
2023-08-22 10:48 [Bug dynamic-link/30785] New: Always call destructors in reverse constructor order fweimer at redhat dot com
` (11 preceding siblings ...)
2023-10-18 14:38 ` fweimer at redhat dot com
@ 2023-10-18 14:38 ` fweimer at redhat dot com
12 siblings, 0 replies; 14+ messages in thread
From: fweimer at redhat dot com @ 2023-10-18 14:38 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30785
--- Comment #5 from Florian Weimer <fweimer at redhat dot com> ---
Bug 30981 is the continuation issue for dlclose.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 14+ messages in thread