godot/core
Hein-Pieter van Braam-Stewart ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
..
bind [46188] fix: get unix from datetime when empty dict 2021-03-12 10:17:41 +01:00
crypto Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
io Add a "keep" import mode to keep files as-is and export them. 2021-03-23 15:44:24 +01:00
math Geometry2D::make_atlas Fail is passed invalid rect size 2021-02-25 15:14:32 +01:00
os Fix thread_local, tls, ASLR, and DEP with MingW 2021-03-25 23:20:12 +01:00
array.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
array.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
class_db.cpp Modernize RWLock 2021-02-18 11:41:07 +01:00
class_db.h Modernize RWLock 2021-02-18 11:41:07 +01:00
color_names.inc doc: Document named color constants 2020-01-26 12:08:16 +01:00
color.cpp Make Color::from_hsv use Color::set_hsv 2021-03-04 11:39:02 +01:00
color.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
command_queue_mt.cpp Modernize Semaphore 2021-02-18 11:58:08 +01:00
command_queue_mt.h Modernize Semaphore 2021-02-18 11:58:08 +01:00
compressed_translation.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
compressed_translation.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
core_builders.py Update AUTHORS and DONORS list 2020-08-14 00:32:05 +02:00
core_string_names.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
core_string_names.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
cowdata.h Improve robustness of atomics 2021-02-19 11:48:30 +01:00
dictionary.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
dictionary.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
engine.cpp Revert backport of 2D transform and camera snapping options 2021-03-05 14:20:31 +00:00
engine.h Revert backport of 2D transform and camera snapping options 2021-03-05 14:20:31 +00:00
error_list.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
error_macros.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
error_macros.h Modernize atomics 2021-02-18 12:23:25 +01:00
func_ref.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
func_ref.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
global_constants.cpp doc: Sync classref with current source 2021-02-16 14:47:29 +01:00
global_constants.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
hash_map.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
hashfuncs.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
image.cpp Fix invalid memory usage when modifying locked image 2021-03-16 13:45:45 +08:00
image.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
input_map.cpp Print suggestions when requesting a nonexistent InputMap action 2021-02-11 18:00:26 +01:00
input_map.h Print suggestions when requesting a nonexistent InputMap action 2021-02-11 18:00:26 +01:00
int_types.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
list.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
local_vector.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
make_binders.py SCons: Format buildsystem files with psf/black 2020-06-10 15:30:52 +02:00
map.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
message_queue.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
message_queue.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
method_bind.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
method_bind.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
method_ptrcall.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
node_path.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
node_path.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
oa_hash_map.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
object_id.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
object_rc.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
object.cpp Modernize atomics 2021-02-18 12:23:25 +01:00
object.h Modernize atomics 2021-02-18 12:23:25 +01:00
ordered_hash_map.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
packed_data_container.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
packed_data_container.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
pair.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
path_remap.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
path_remap.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
pool_allocator.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
pool_allocator.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
pool_vector.cpp Modernize Mutex 2021-02-18 11:58:08 +01:00
pool_vector.h Modernize atomics 2021-02-18 12:23:25 +01:00
pooled_list.h doc: Sync classref with current source 2021-01-13 16:55:27 +01:00
print_string.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
print_string.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
project_settings.cpp Fix bug causing project.godot to be ignored when project.binary is missing 2021-03-17 15:17:02 +01:00
project_settings.h Add GLOBAL_DEF_ALIAS and alias for rename of pixel_snap 2021-03-09 15:16:24 +00:00
ref_ptr.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
ref_ptr.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
reference.cpp Modernize atomics 2021-02-18 12:23:25 +01:00
reference.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
register_core_types.cpp Modernize Mutex 2021-02-18 11:58:08 +01:00
register_core_types.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
resource.cpp Modernize RWLock 2021-02-18 11:41:07 +01:00
resource.h Modernize RWLock 2021-02-18 11:41:07 +01:00
rid.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
rid.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
ring_buffer.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
safe_refcount.cpp Improve robustness of atomics 2021-02-19 11:48:30 +01:00
safe_refcount.h Fix SafeNumeric::conditional_increment() for NO_THREADS 2021-02-25 22:34:15 +01:00
script_debugger_local.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
script_debugger_local.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
script_language.cpp Don't save project settings when not necessary 2021-02-16 14:27:38 +01:00
script_language.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
SCsub Don't handle BaseException in build scripts 2020-12-12 10:10:23 +00:00
self_list.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
set.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
simple_type.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
sort_array.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
string_buffer.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
string_builder.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
string_builder.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
string_name.cpp Modernize Mutex 2021-02-18 11:58:08 +01:00
string_name.h Modernize Mutex 2021-02-18 11:58:08 +01:00
translation.cpp Fixes some inconsistent ISO-639 language codes 2021-02-25 15:14:32 +01:00
translation.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
type_info.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
typedefs.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
ucaps.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
undo_redo.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
undo_redo.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
ustring.cpp Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
ustring.h Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
variant_call.cpp Relaxes Node naming constraints in glTF documents to match the Editor. 2021-03-12 08:35:50 -08:00
variant_op.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
variant_parser.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
variant_parser.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
variant.cpp Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
variant.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
vector.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
version.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
vmap.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00
vset.h Update copyright statements to 2021 2021-01-13 16:17:06 +01:00