diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | src/lanes.c | 5 | ||||
-rw-r--r-- | src/universe.c | 9 |
3 files changed, 15 insertions, 2 deletions
@@ -1,5 +1,8 @@ | |||
1 | CHANGES: | 1 | CHANGES: |
2 | 2 | ||
3 | CHANGE 131: BGe 7-Nov-18 | ||
4 | * Fix potential crash at application shutdown when deep userdata were created before Lanes is required | ||
5 | |||
3 | CHANGE 130: BGe 2-Nov-18 | 6 | CHANGE 130: BGe 2-Nov-18 |
4 | * always duplicate the config structure in new lanes even when no libraries are initialized by the generator | 7 | * always duplicate the config structure in new lanes even when no libraries are initialized by the generator |
5 | (fixes an internal error trying to call on_state_create in a lane without any libs loaded) | 8 | (fixes an internal error trying to call on_state_create in a lane without any libs loaded) |
diff --git a/src/lanes.c b/src/lanes.c index 7b1a707..d4b4c73 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -1756,7 +1756,10 @@ static int selfdestruct_gc( lua_State* L) | |||
1756 | // Locks for 'tools.c' inc/dec counters | 1756 | // Locks for 'tools.c' inc/dec counters |
1757 | MUTEX_FREE( &U->deep_lock); | 1757 | MUTEX_FREE( &U->deep_lock); |
1758 | MUTEX_FREE( &U->mtid_lock); | 1758 | MUTEX_FREE( &U->mtid_lock); |
1759 | 1759 | // universe is no longer available (nor necessary) | |
1760 | // we need to do this in case some deep userdata objects were created before Lanes was initialized, | ||
1761 | // as potentially they will be garbage collected after Lanes at application shutdown | ||
1762 | universe_store( L, NULL); | ||
1760 | return 0; | 1763 | return 0; |
1761 | } | 1764 | } |
1762 | 1765 | ||
diff --git a/src/universe.c b/src/universe.c index 00de1f3..4689a09 100644 --- a/src/universe.c +++ b/src/universe.c | |||
@@ -56,7 +56,14 @@ void universe_store( lua_State* L, Universe* U) | |||
56 | { | 56 | { |
57 | STACK_CHECK( L); | 57 | STACK_CHECK( L); |
58 | push_unique_key( L, UNIVERSE_REGKEY); | 58 | push_unique_key( L, UNIVERSE_REGKEY); |
59 | lua_pushlightuserdata( L, U); | 59 | if( NULL != U) |
60 | { | ||
61 | lua_pushlightuserdata( L, U); | ||
62 | } | ||
63 | else | ||
64 | { | ||
65 | lua_pushnil( L); | ||
66 | } | ||
60 | lua_rawset( L, LUA_REGISTRYINDEX); | 67 | lua_rawset( L, LUA_REGISTRYINDEX); |
61 | STACK_END( L, 0); | 68 | STACK_END( L, 0); |
62 | } | 69 | } |