diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | src/tools.c | 9 | ||||
-rw-r--r-- | tests/lanes_as_upvalue.lua | 9 |
3 files changed, 17 insertions, 4 deletions
@@ -1,5 +1,8 @@ | |||
1 | CHANGES: | 1 | CHANGES: |
2 | 2 | ||
3 | CHANGE 140: BGe 22-Nov-18 | ||
4 | * Raise an error instead of crashing when attempting to transfer a non-deep full userdata | ||
5 | |||
3 | CHANGE 139: BGe 21-Nov-18 | 6 | CHANGE 139: BGe 21-Nov-18 |
4 | * more DEBUGSPEW | 7 | * more DEBUGSPEW |
5 | 8 | ||
diff --git a/src/tools.c b/src/tools.c index d358e96..b00cef5 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1617,6 +1617,12 @@ static void inter_copy_keyvaluepair( Universe* U, lua_State* L2, uint_t L2_cache | |||
1617 | valPath = (char*) alloca( strlen( upName_) + 16 + 5); | 1617 | valPath = (char*) alloca( strlen( upName_) + 16 + 5); |
1618 | sprintf( valPath, "%s[U:%p]", upName_, key); | 1618 | sprintf( valPath, "%s[U:%p]", upName_, key); |
1619 | } | 1619 | } |
1620 | else if( lua_type( L, key_i) == LUA_TBOOLEAN) | ||
1621 | { | ||
1622 | int key = lua_toboolean( L, key_i); | ||
1623 | valPath = (char*) alloca( strlen( upName_) + 7); | ||
1624 | sprintf( valPath, "%s[%s]", upName_, key ? "true" : "false"); | ||
1625 | } | ||
1620 | } | 1626 | } |
1621 | /* | 1627 | /* |
1622 | * Contents of metatables are copied with cache checking; | 1628 | * Contents of metatables are copied with cache checking; |
@@ -1629,7 +1635,7 @@ static void inter_copy_keyvaluepair( Universe* U, lua_State* L2, uint_t L2_cache | |||
1629 | } | 1635 | } |
1630 | else | 1636 | else |
1631 | { | 1637 | { |
1632 | luaL_error( L, "Unable to copy over type '%s' (in %s)", luaL_typename( L, val_i), (vt == VT_NORMAL) ? "table" : "metatable"); | 1638 | luaL_error( L, "Unable to copy %s entry '%s' because of value is of type '%s'", (vt == VT_NORMAL) ? "table" : "metatable", valPath, luaL_typename( L, val_i)); |
1633 | } | 1639 | } |
1634 | } | 1640 | } |
1635 | } | 1641 | } |
@@ -1740,6 +1746,7 @@ static bool_t inter_copy_one_( Universe* U, lua_State* L2, uint_t L2_cache_i, lu | |||
1740 | if( lua_isnil( L, -1)) | 1746 | if( lua_isnil( L, -1)) |
1741 | { | 1747 | { |
1742 | lua_pop( L, 2); // ... | 1748 | lua_pop( L, 2); // ... |
1749 | ret = FALSE; | ||
1743 | } | 1750 | } |
1744 | else | 1751 | else |
1745 | { | 1752 | { |
diff --git a/tests/lanes_as_upvalue.lua b/tests/lanes_as_upvalue.lua index 7cc5e14..c1944b0 100644 --- a/tests/lanes_as_upvalue.lua +++ b/tests/lanes_as_upvalue.lua | |||
@@ -1,8 +1,11 @@ | |||
1 | local lanes = require "lanes".configure() -- with timers enabled | 1 | local lanes = require "lanes".configure{ verbose_errors = true} -- with timers enabled |
2 | 2 | ||
3 | local function foo() | 3 | local function foo() |
4 | local lanes = lanes -- lanes as upvalue | 4 | local lanes = lanes -- lanes as upvalue |
5 | end | 5 | end |
6 | 6 | ||
7 | local h = lanes.gen( "*", foo)() | 7 | local g = lanes.gen( "*", foo) |
8 | h:join() | 8 | |
9 | -- this should raise an error as lanes.timer_lane is a Lane (a non-deep full userdata) | ||
10 | local res, err = pcall( g) | ||
11 | print( "Generating lane yielded: ", tostring( res), tostring( err)) | ||