History log of /haiku/src/system/runtime_loader/elf_tls.cpp
Revision Date Author Comments
# aabcd6b3 30-Aug-2022 Augustin Cavalier <waddlesplash@gmail.com>

runtime_loader: Correct destruction of old TLS DSO blocks.

Instead of checking against the current block's DSO generation,
the DSO that the operator[] was invoked on was being checked instead.
This could lead to spurious deletions of TLS data in the case where
the generation count changed between accesses of the TLS variable
(currently that only happens when modules are unloaded.)

May fix #17896, but I did not have a reliable way to reproduce that.

Change-Id: Ie1ee51c1fbbe638918fd5a010047a2b56d481f2b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5604
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# dbcbe07a 05-Apr-2022 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: review after ebeab0cf7032dd3f09d4588aa05e0618482999b8

* memset should happen after the NULL check
* useless casts

Change-Id: Id96e7861154b554dd927bf5dde2329c8acd2fdca
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5181
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# ebeab0cf 05-Sep-2021 X512 <danger_mail@list.ru>

rumtime_loader: fix TLS for riscv64

Change-Id: I55593dea936af31135b8e9159f8b6a64270369c0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5157
Reviewed-by: X512 <danger_mail@list.ru>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# e7d37c7e 17-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

Revert "runtime_loader: Add missing locking around resizing the TLS DTV."

This reverts commit d0111efeada9f21db085e0cc27abd94d408ddaa9.

Initially, I, too thought this was the correct solution. In
investigating the related #14342, I found that adding a lock of
the mutex in the function that crashed most often in (DestroyAll())
increased the time it took to cause a crash from 1-2 seconds
to 10-15 seconds, but it still inevitably crashed.

Further, crash addresses were often very low (e.g. 0x1, 0x18); on
inspection I determined these were coming from the fPointer fields
of TLSBlocks. But accesses to TLSBlocks were now well protected
by the TLS mutex, and they were memset'd after allocation, so that
didn't make any sense.

At that point, I went back and read over the code until I understood
it, and it became clear this solution was incorrect: TLSBlocks and
their underlying data are always associated with a specific thread,
meaning _Resize() and DestroyAll() would never be called on the same
data from different threads, despite appearances to the contrary.

Thus despite a dearth of comments in this file, it seems pdziepak
knew what he was doing when he wrote this; no locking is needed.
That left only one place to cause this kind of memory corruption...


# d0111efe 17-Dec-2018 Jérôme Duval <jerome.duval@gmail.com>

runtime_loader: Add missing locking around resizing the TLS DTV.

* Fixes crashes when the DTV is concurrently resized by multiple threads.
* Fixes JVM crash or endless loop when building OpenJDK.
* Should help with #13154, #14129, #14304, #14342.

Change-Id: I132600315d76a1a86236c6c70db09a3cdf0a8743
Reviewed-on: https://review.haiku-os.org/771
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 368dd377 18-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

runtime_loader: Fix missing include of util/kernel_cpp.h.

Due to the missing include, the builtin new and delete operators were
used in those two files instead of the ones from the include used
everywhere else in the runtime_loader.


# 680ca3b1 08-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: fix CID 1211995, improve generation counting

There is no need to increase generation counter each time new DSO is
registered.


# 44c0c4d3 03-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: add support for ELF based TLS

This patch introduces support of ELF based TLS handling with lazy allocation
and initalization of TLS block for each DSO and thread. The implementation
generally follows the official ABI except that generation counter in dtv
is in fact a pointer to Generation object that contains both generation
counter and size of the dtv. That simplified the implementation a bit, but
could be changed later. The ABI requirements regariding in memory position
of TLS block is not honoured what results in static TLS model being
unsupported. However, that should not be a problem as long as
"executables" in Haiku are in fact shared objects and optimizations which
require specific TLS block in memory layout are not possible anyway.


# 368dd377989a07862be20f87c23329734b2277d8 18-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

runtime_loader: Fix missing include of util/kernel_cpp.h.

Due to the missing include, the builtin new and delete operators were
used in those two files instead of the ones from the include used
everywhere else in the runtime_loader.


# 680ca3b13d52422ea165f09173c82c8ba26e73c5 08-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: fix CID 1211995, improve generation counting

There is no need to increase generation counter each time new DSO is
registered.


# 44c0c4d3d0d68c3c3db23858b1089d3cf51bdf16 03-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: add support for ELF based TLS

This patch introduces support of ELF based TLS handling with lazy allocation
and initalization of TLS block for each DSO and thread. The implementation
generally follows the official ABI except that generation counter in dtv
is in fact a pointer to Generation object that contains both generation
counter and size of the dtv. That simplified the implementation a bit, but
could be changed later. The ABI requirements regariding in memory position
of TLS block is not honoured what results in static TLS model being
unsupported. However, that should not be a problem as long as
"executables" in Haiku are in fact shared objects and optimizations which
require specific TLS block in memory layout are not possible anyway.