diff options
| -rw-r--r-- | CHANGES | 3 | ||||
| -rw-r--r-- | src/keeper.c | 2 | ||||
| -rw-r--r-- | src/lanes.c | 2 | ||||
| -rw-r--r-- | src/tools.c | 9 | ||||
| -rw-r--r-- | src/tools.h | 2 |
5 files changed, 11 insertions, 7 deletions
| @@ -1,5 +1,8 @@ | |||
| 1 | CHANGES: | 1 | CHANGES: |
| 2 | 2 | ||
| 3 | CHANGE 107: BGe 19-Mar-14 | ||
| 4 | * Make sure we don't mutex-wrap require() more than once, just in case | ||
| 5 | |||
| 3 | CHANGE 106: BGe 17-Mar-14 | 6 | CHANGE 106: BGe 17-Mar-14 |
| 4 | * Fixed crash when using protect_allocator option | 7 | * Fixed crash when using protect_allocator option |
| 5 | 8 | ||
diff --git a/src/keeper.c b/src/keeper.c index 4d2d068..63ae7ff 100644 --- a/src/keeper.c +++ b/src/keeper.c | |||
| @@ -681,7 +681,7 @@ void init_keepers( struct s_Universe* U, lua_State* L) | |||
| 681 | luaL_requiref( K, "package", luaopen_package, 1); // package | 681 | luaL_requiref( K, "package", luaopen_package, 1); // package |
| 682 | lua_pop( K, 1); // | 682 | lua_pop( K, 1); // |
| 683 | STACK_MID( K, 0); | 683 | STACK_MID( K, 0); |
| 684 | serialize_require( K); | 684 | serialize_require( U, K); |
| 685 | STACK_MID( K, 0); | 685 | STACK_MID( K, 0); |
| 686 | 686 | ||
| 687 | // copy package.path and package.cpath from the source state | 687 | // copy package.path and package.cpath from the source state |
diff --git a/src/lanes.c b/src/lanes.c index f46046e..6b3264a 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
| @@ -3108,7 +3108,7 @@ LUAG_FUNC( configure) | |||
| 3108 | STACK_MID( L, 0); | 3108 | STACK_MID( L, 0); |
| 3109 | 3109 | ||
| 3110 | // Serialize calls to 'require' from now on, also in the primary state | 3110 | // Serialize calls to 'require' from now on, also in the primary state |
| 3111 | serialize_require( L); | 3111 | serialize_require( U, L); |
| 3112 | 3112 | ||
| 3113 | // Retrieve main module interface table | 3113 | // Retrieve main module interface table |
| 3114 | lua_pushvalue( L, lua_upvalueindex( 2)); // settings M | 3114 | lua_pushvalue( L, lua_upvalueindex( 2)); // settings M |
diff --git a/src/tools.c b/src/tools.c index 65387e5..ea7662b 100644 --- a/src/tools.c +++ b/src/tools.c | |||
| @@ -735,7 +735,7 @@ lua_State* luaG_newstate( struct s_Universe* U, lua_State* from_, char const* li | |||
| 735 | } | 735 | } |
| 736 | lua_gc( L, LUA_GCRESTART, 0); | 736 | lua_gc( L, LUA_GCRESTART, 0); |
| 737 | 737 | ||
| 738 | serialize_require( L); | 738 | serialize_require( U, L); |
| 739 | 739 | ||
| 740 | // call this after the base libraries are loaded and GC is restarted | 740 | // call this after the base libraries are loaded and GC is restarted |
| 741 | // will raise an error in from_ in case of problem | 741 | // will raise an error in from_ in case of problem |
| @@ -2316,15 +2316,16 @@ int luaG_new_require( lua_State* L) | |||
| 2316 | /* | 2316 | /* |
| 2317 | * Serialize calls to 'require', if it exists | 2317 | * Serialize calls to 'require', if it exists |
| 2318 | */ | 2318 | */ |
| 2319 | void serialize_require( lua_State* L) | 2319 | void serialize_require( struct s_Universe* U, lua_State* L) |
| 2320 | { | 2320 | { |
| 2321 | STACK_GROW( L, 1); | 2321 | STACK_GROW( L, 1); |
| 2322 | STACK_CHECK( L); | 2322 | STACK_CHECK( L); |
| 2323 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "serializing require()\n" INDENT_END)); | ||
| 2323 | 2324 | ||
| 2324 | // Check 'require' is there; if not, do nothing | 2325 | // Check 'require' is there and not already wrapped; if not, do nothing |
| 2325 | // | 2326 | // |
| 2326 | lua_getglobal( L, "require"); | 2327 | lua_getglobal( L, "require"); |
| 2327 | if( lua_isfunction( L, -1)) | 2328 | if( lua_isfunction( L, -1) && lua_tocfunction( L, -1) != luaG_new_require) |
| 2328 | { | 2329 | { |
| 2329 | // [-1]: original 'require' function | 2330 | // [-1]: original 'require' function |
| 2330 | lua_pushcclosure( L, luaG_new_require, 1 /*upvalues*/); | 2331 | lua_pushcclosure( L, luaG_new_require, 1 /*upvalues*/); |
diff --git a/src/tools.h b/src/tools.h index 3152646..708421c 100644 --- a/src/tools.h +++ b/src/tools.h | |||
| @@ -187,7 +187,7 @@ int luaG_nameof( lua_State* L); | |||
| 187 | int luaG_new_require( lua_State* L); | 187 | int luaG_new_require( lua_State* L); |
| 188 | 188 | ||
| 189 | void populate_func_lookup_table( lua_State* L, int _i, char const* _name); | 189 | void populate_func_lookup_table( lua_State* L, int _i, char const* _name); |
| 190 | void serialize_require( lua_State *L); | 190 | void serialize_require( struct s_Universe* U, lua_State *L); |
| 191 | void initialize_on_state_create( struct s_Universe* U, lua_State* L); | 191 | void initialize_on_state_create( struct s_Universe* U, lua_State* L); |
| 192 | void call_on_state_create( struct s_Universe* U, lua_State* L, lua_State* from_, enum eLookupMode mode_); | 192 | void call_on_state_create( struct s_Universe* U, lua_State* L, lua_State* from_, enum eLookupMode mode_); |
| 193 | 193 | ||
