mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
🛠 Retrieve main thread to prevent collapses on Luas
— Lua 5.1, 5.2, and 5.3 seemed to have a deficiency in which the stack thread space variable (given as a lua_State*) would die before everything referencing it would be properly dead. This made holding a reference for keep-alive purposes impossible to maintain. Therefore, we retrieve the main thread to keep it alive.
This commit is contained in:
parent
268b58964c
commit
612b469ad9
|
@ -42,7 +42,7 @@ include(FetchContent)
|
|||
|
||||
# # # Configuration
|
||||
# # Cached defines, strings, paths and options
|
||||
set(SOL2_LUA_VERSION "5.3.5" CACHE STRING "The version of Lua needed. Can be 5.1, 5.2, 5.3, 5.4, LuaJIT, or a more specific 3-part version number for a specifc Lua (e.g., 5.3.5 or luajit-2.0.5)")
|
||||
set(SOL2_LUA_VERSION "5.4.4" CACHE STRING "The version of Lua needed. Can be 5.1, 5.2, 5.3, 5.4, LuaJIT, or a more specific 3-part version number for a specifc Lua (e.g., 5.4.4 or luajit-2.0.5)")
|
||||
set(SOL2_BUILD_LUA TRUE CACHE BOOL "Always build Lua, do not search for it in the system")
|
||||
set(SOL2_PLATFORM "x64" CACHE STRING "Target platform to compile for when building binaries (x86, x64)")
|
||||
option(SOL2_CI "Whether or not we are in continguous integration mode" OFF)
|
||||
|
|
|
@ -50,7 +50,7 @@ VOLUME /root/sol2
|
|||
# Command line arguments, with default values
|
||||
ARG SOL2_PLATFORM=x64
|
||||
ARG SOL2_LUA_VERSION=x64
|
||||
ARG SOL2_LUA_VERSION=5.3.5
|
||||
ARG SOL2_LUA_VERSION=5.4.4
|
||||
ARG SOL2_TEST_SINGLE=false
|
||||
ARG SOL2_TEST_INTEROP=false
|
||||
ARG SOL2_CI=true
|
||||
|
|
|
@ -107,7 +107,7 @@ if (LuaBuild_FIND_VERSION)
|
|||
endif()
|
||||
endif()
|
||||
if (NOT LUA_VERSION)
|
||||
set(LUA_VERSION 5.3.5)
|
||||
set(LUA_VERSION 5.4.4)
|
||||
endif()
|
||||
find_lua_build(${LUA_VERSION})
|
||||
unset(find_lua_build)
|
||||
|
|
|
@ -34,83 +34,8 @@ include(Common/Core)
|
|||
# Latest versions for specific sub-versions of Lua
|
||||
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
|
||||
set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4)
|
||||
set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.5)
|
||||
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.1)
|
||||
|
||||
# exact version, coming from CI: pull directly from Lua and use external project to build
|
||||
# list of known md5 / sha1: must update when there are changes
|
||||
set(LUA_VANILLA_MD5_5.4.1 1d575faef1c907292edd79e7a2784d30)
|
||||
set(LUA_VANILLA_SHA1_5.4.1 88961e7d4fda58ca2c6163938fd48db8880e803d)
|
||||
set(LUA_VANILLA_MD5_5.4.0 dbf155764e5d433fc55ae80ea7060b60)
|
||||
set(LUA_VANILLA_SHA1_5.4.0 8cdbffa8a214a23d190d7c45f38c19518ae62e89)
|
||||
set(LUA_VANILLA_MD5_5.3.5 4f4b4f323fd3514a68e0ab3da8ce3455)
|
||||
set(LUA_VANILLA_SHA1_5.3.5 112eb10ff04d1b4c9898e121d6bdf54a81482447)
|
||||
set(LUA_VANILLA_MD5_5.3.4 53a9c68bcc0eda58bdc2095ad5cdfc63)
|
||||
set(LUA_VANILLA_SHA1_5.3.4 79790cfd40e09ba796b01a571d4d63b52b1cd950)
|
||||
set(LUA_VANILLA_MD5_5.3.3 703f75caa4fdf4a911c1a72e67a27498)
|
||||
set(LUA_VANILLA_SHA1_5.3.3 a0341bc3d1415b814cc738b2ec01ae56045d64ef)
|
||||
set(LUA_VANILLA_MD5_5.3.2 33278c2ab5ee3c1a875be8d55c1ca2a1)
|
||||
set(LUA_VANILLA_SHA1_5.3.2 7a47adef554fdca7d0c5536148de34579134a973)
|
||||
set(LUA_VANILLA_MD5_5.3.1 797adacada8d85761c079390ff1d9961)
|
||||
set(LUA_VANILLA_SHA1_5.3.1 1676c6a041d90b6982db8cef1e5fb26000ab6dee)
|
||||
set(LUA_VANILLA_MD5_5.3.0 a1b0a7e92d0c85bbff7a8d27bf29f8af)
|
||||
set(LUA_VANILLA_SHA1_5.3.0 1c46d1c78c44039939e820126b86a6ae12dadfba)
|
||||
set(LUA_VANILLA_MD5_5.2.4 913fdb32207046b273fdb17aad70be13)
|
||||
set(LUA_VANILLA_SHA1_5.2.4 ef15259421197e3d85b7d6e4871b8c26fd82c1cf)
|
||||
set(LUA_VANILLA_MD5_5.2.3 dc7f94ec6ff15c985d2d6ad0f1b35654)
|
||||
set(LUA_VANILLA_SHA1_5.2.3 926b7907bc8d274e063d42804666b40a3f3c124c)
|
||||
set(LUA_VANILLA_MD5_5.2.2 efbb645e897eae37cad4344ce8b0a614)
|
||||
set(LUA_VANILLA_SHA1_5.2.2 0857e41e5579726a4cb96732e80d7aa47165eaf5)
|
||||
set(LUA_VANILLA_MD5_5.2.1 ae08f641b45d737d12d30291a5e5f6e3)
|
||||
set(LUA_VANILLA_SHA1_5.2.1 6bb1b0a39b6a5484b71a83323c690154f86b2021)
|
||||
set(LUA_VANILLA_MD5_5.2.0 f1ea831f397214bae8a265995ab1a93e)
|
||||
set(LUA_VANILLA_SHA1_5.2.0 08f84c355cdd646f617f09cebea48bd832415829)
|
||||
set(LUA_VANILLA_MD5_5.1.5 2e115fe26e435e33b0d5c022e4490567)
|
||||
set(LUA_VANILLA_SHA1_5.1.5 b3882111ad02ecc6b972f8c1241647905cb2e3fc)
|
||||
set(LUA_VANILLA_MD5_5.1.4 d0870f2de55d59c1c8419f36e8fac150)
|
||||
set(LUA_VANILLA_SHA1_5.1.4 2b11c8e60306efb7f0734b747588f57995493db7)
|
||||
set(LUA_VANILLA_MD5_5.1.3 a70a8dfaa150e047866dc01a46272599)
|
||||
set(LUA_VANILLA_SHA1_5.1.3 89bc9f5a351402565b8077e8123327e7cd15f004)
|
||||
set(LUA_VANILLA_MD5_5.1.2 687ce4c2a1ddff18f1008490fdc4e5e0)
|
||||
set(LUA_VANILLA_SHA1_5.1.2 8a460d2d7e70e93cb72bf3d584405464763cb5f0)
|
||||
set(LUA_VANILLA_MD5_5.1.1 22f4f912f20802c11006fe9b84d5c461)
|
||||
set(LUA_VANILLA_SHA1_5.1.1 be13878ceef8e1ee7a4201261f0adf09f89f1005)
|
||||
set(LUA_VANILLA_MD5_5.1 3e8dfe8be00a744cec2f9e766b2f2aee)
|
||||
set(LUA_VANILLA_SHA1_5.1 1ae9ec317511d525c7999c842ca0b1ddde84e374)
|
||||
set(LUA_VANILLA_MD5_5.0.3 feee27132056de2949ce499b0ef4c480)
|
||||
set(LUA_VANILLA_SHA1_5.0.3 e7e91f78b8a8deb09b13436829bed557a46af8ae)
|
||||
set(LUA_VANILLA_MD5_5.0.2 dea74646b7e5c621fef7174df83c34b1)
|
||||
set(LUA_VANILLA_SHA1_5.0.2 a200cfd20a9a4c7da1206ae45dddf26186a9e0e7)
|
||||
set(LUA_VANILLA_MD5_5.0.1 e0a450d84971a3f4563b98172d1e382c)
|
||||
set(LUA_VANILLA_SHA1_5.0.1 03b47b4785178aca583333f01d8726a8ab9f7ae7)
|
||||
set(LUA_VANILLA_MD5_5.0 6f14803fad389fb1cb15d17edfeddd91)
|
||||
set(LUA_VANILLA_SHA1_5.0 88b1bc057857c0db5ace491c4af2c917a2b803bf)
|
||||
set(LUA_VANILLA_MD5_4.0.1 a31d963dbdf727f9b34eee1e0d29132c)
|
||||
set(LUA_VANILLA_SHA1_4.0.1 12f1864a7ecd4b8011862a07fa3f177b2e80e7d3)
|
||||
set(LUA_VANILLA_MD5_4.0 be11522d46d33a931868c03694aaeeef)
|
||||
set(LUA_VANILLA_SHA1_4.0 8d432c73ef6e98b81d252114be1a83182cc9607a)
|
||||
set(LUA_VANILLA_MD5_3.2.2 374ba5c4839709922de40b8d10382705)
|
||||
set(LUA_VANILLA_SHA1_3.2.2 fa50ff14c00d8523c8a3d1d3f4887ecc4400d0c3)
|
||||
set(LUA_VANILLA_MD5_3.2.1 47264a1978df49fc1dea6ffcddb05b21)
|
||||
set(LUA_VANILLA_SHA1_3.2.1 d43af5a1c7a65c0ddb4b0ac06c29ecf4cdd22367)
|
||||
set(LUA_VANILLA_MD5_3.2 a6552da3d40ae9b04489a788262279e8)
|
||||
set(LUA_VANILLA_SHA1_3.2 84cf9f0e7d00eed3ea8b4ac2b84254b714510b34)
|
||||
set(LUA_VANILLA_MD5_3.1 d677f3827167eefdefc7b211397cfdfb)
|
||||
set(LUA_VANILLA_SHA1_3.1 509485e3baafd946f4ffe2a984f8a63746adc32a)
|
||||
set(LUA_VANILLA_MD5_3.0 997558ae76c2f1cd1e10fd3835c45c6a)
|
||||
set(LUA_VANILLA_SHA1_3.0 5c8c910353f717ba29b4fe7d538994454229b335)
|
||||
set(LUA_VANILLA_MD5_2.5 da915d58904e75b9b0fc18147e19b0bb)
|
||||
set(LUA_VANILLA_SHA1_2.5 7920e12c40242932c22fa261ff114cc485a39d99)
|
||||
set(LUA_VANILLA_MD5_2.4 5d035cc244285c1dbbcaaa0908b58965)
|
||||
set(LUA_VANILLA_SHA1_2.4 74036935b36e6ae4ed17bd7a9408154f9a4a6b17)
|
||||
set(LUA_VANILLA_MD5_2.2 a298b58e197ff8168ec907d6145252ef)
|
||||
set(LUA_VANILLA_SHA1_2.2 2d8b1df94b2fb76f0f16ca1ddc54d5186b10df4b)
|
||||
set(LUA_VANILLA_MD5_2.1 053a9f6728cc56f6a23716a6a1ede595)
|
||||
set(LUA_VANILLA_SHA1_2.1 b9a797547f480bcb58b5d3da846c8ac8d2201df0)
|
||||
set(LUA_VANILLA_MD5_1.1 9f83141cc8ea362497e272071eda5cf6)
|
||||
set(LUA_VANILLA_SHA1_1.1 67209701eec5cc633e829d023fbff62d5d6c8e5e)
|
||||
set(LUA_VANILLA_MD5_1.0 96e8399fc508d128badd8ac3aa8f2119)
|
||||
set(LUA_VANILLA_SHA1_1.0 6a82d2ae7ce9ad98c7b4824a325b91522c0d6ebb)
|
||||
set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.6)
|
||||
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.4)
|
||||
|
||||
# Clean up some variables
|
||||
if (LUA_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
|
||||
|
@ -154,21 +79,6 @@ FIND_PACKAGE_MESSAGE(LUABUILD
|
|||
"Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library with ${LUA_VANILLA_LANGUAGE} linkage..."
|
||||
"[${LUA_VANILLA_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}][${LUA_VANILLA_LANGUAGE}]")
|
||||
|
||||
# Get Hashes to use for download
|
||||
set(LUA_VANILLA_SHA1 ${LUA_VANILLA_SHA1_${LUA_VANILLA_VERSION}})
|
||||
set(LUA_VANILLA_MD5 ${LUA_VANILLA_MD5_${LUA_VANILLA_VERSION}})
|
||||
|
||||
if (LUA_VANILLA_MD5)
|
||||
set(LUA_VANILLA_DOWNLOAD_MD5_COMMAND URL_MD5 ${LUA_VANILLA_MD5})
|
||||
else ()
|
||||
set(LUA_VANILLA_DOWNLOAD_MD5_COMMAND "")
|
||||
endif()
|
||||
if (LUA_VANILLA_SHA1)
|
||||
set(LUA_VANILLA_DOWNLOAD_SHA1_COMMAND URL_HASH SHA1=${LUA_VANILLA_SHA1})
|
||||
else ()
|
||||
set(LUA_VANILLA_DOWNLOAD_SHA1_COMMAND "")
|
||||
endif()
|
||||
|
||||
# # # Makefile and self-build configurations
|
||||
|
||||
# # Potential compiler variables
|
||||
|
@ -273,8 +183,6 @@ else()
|
|||
STAMP_DIR "${LUA_BUILD_TOPLEVEL}-stamp"
|
||||
INSTALL_DIR "${LUA_BUILD_INSTALL_DIR}"
|
||||
URL ${LUA_VANILLA_DOWNLOAD_URL}
|
||||
URL_MD5 ${LUA_VANILLA_MD5}
|
||||
URL_HASH SHA1=${LUA_VANILLA_SHA1}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
|
|
|
@ -70,9 +70,8 @@ namespace sol { namespace stack {
|
|||
actual* mem = static_cast<actual*>(memory);
|
||||
return static_cast<actual>(*mem);
|
||||
}
|
||||
actual r {};
|
||||
if constexpr (!derive<element>::value) {
|
||||
return {};
|
||||
return OptionalType();
|
||||
}
|
||||
else {
|
||||
memory = detail::align_usertype_unique_tag<true, false>(memory);
|
||||
|
@ -80,6 +79,7 @@ namespace sol { namespace stack {
|
|||
memory = detail::align_usertype_unique<actual, true, false>(memory);
|
||||
string_view ti = usertype_traits<element>::qualified_name();
|
||||
int cast_operation;
|
||||
actual r {};
|
||||
if constexpr (is_actual_type_rebindable_for_v<Tu>) {
|
||||
using rebound_actual_type = unique_usertype_rebind_actual_t<Tu, void>;
|
||||
string_view rebind_ti = usertype_traits<rebound_actual_type>::qualified_name();
|
||||
|
@ -103,13 +103,13 @@ namespace sol { namespace stack {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
return OptionalType();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!check<T>(L, index, std::forward<Handler>(handler))) {
|
||||
tracking.use(static_cast<int>(!lua_isnone(L, index)));
|
||||
return {};
|
||||
return OptionalType();
|
||||
}
|
||||
return OptionalType(stack_detail::unchecked_get<T>(L, index, tracking));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
namespace sol {
|
||||
namespace detail {
|
||||
inline void stack_fail(int, int) {
|
||||
#if SOL_IS_ON(SOL_EXCEPTIONS_I_)
|
||||
#if SOL_IS_ON(SOL_EXCEPTIONS)
|
||||
throw error(detail::direct_error, "imbalanced stack after operation finish");
|
||||
#else
|
||||
// Lol, what do you want, an error printout? :3c
|
||||
|
|
|
@ -517,7 +517,7 @@ namespace sol {
|
|||
iterator it;
|
||||
std::size_t index;
|
||||
|
||||
iter(lua_State* L_, int stack_index, T& source_, iterator it_) : keep_alive(L_, stack_index), source(source_), it(std::move(it_)), index(0) {
|
||||
iter(lua_State* L_, int stack_index, T& source_, iterator it_) : keep_alive(sol::main_thread(L_, L_), stack_index), source(source_), it(std::move(it_)), index(0) {
|
||||
}
|
||||
|
||||
~iter() {
|
||||
|
@ -1394,10 +1394,11 @@ namespace sol {
|
|||
T& source;
|
||||
iterator it;
|
||||
|
||||
iter(lua_State* L_, int stack_index, T& source, iterator it) noexcept : keep_alive(L_, stack_index), source(source), it(std::move(it)) {
|
||||
iter(lua_State* L_, int stack_index, T& source, iterator it) noexcept
|
||||
: keep_alive(sol::main_thread(L_, L_), stack_index), source(source), it(std::move(it)) {
|
||||
}
|
||||
|
||||
~iter () {
|
||||
~iter() {
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ echo -e "travis_fold:start:build_preparation\r"
|
|||
|
||||
if [ -z "${SOL2_LUA_VERSION}" ]
|
||||
then
|
||||
export SOL2_LUA_VERSION=5.3.5
|
||||
export SOL2_LUA_VERSION=5.4.4
|
||||
fi
|
||||
|
||||
if [ -z "${SOL2_PLATFORM}" ]
|
||||
|
|
Loading…
Reference in New Issue
Block a user