diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-10-01 11:05:31 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-10-01 11:05:31 -0300 |
commit | adaba04059ddec1c7c55dab16981f3ae2f0c3279 (patch) | |
tree | f867059a39749ff72d925af0daa447dc93025e04 /bugs | |
parent | b157f3546eddda96b8b4f5cd81f56d4ceed2c418 (diff) | |
download | lua-adaba04059ddec1c7c55dab16981f3ae2f0c3279.tar.gz lua-adaba04059ddec1c7c55dab16981f3ae2f0c3279.tar.bz2 lua-adaba04059ddec1c7c55dab16981f3ae2f0c3279.zip |
'pcall' may not restore previous error function when
inside coroutines + Check for garbage collector in function calls
does not cover all paths
Diffstat (limited to '')
-rw-r--r-- | bugs | 99 |
1 files changed, 97 insertions, 2 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.116 2012/07/13 14:53:38 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.117 2012/09/11 12:42:14 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.116 2012/07/13 14:53:38 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.117 2012/09/11 12:42:14 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -2691,6 +2691,10 @@ patch = [[ | |||
2691 | ]] | 2691 | ]] |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | |||
2695 | ----------------------------------------------------------------- | ||
2696 | -- Lua 5.2.1 | ||
2697 | |||
2694 | Bug{ | 2698 | Bug{ |
2695 | what = [[Some patterns can overflow the C stack, due to recursion]], | 2699 | what = [[Some patterns can overflow the C stack, due to recursion]], |
2696 | report = [[Tim Starling, 2012/07/08]], | 2700 | report = [[Tim Starling, 2012/07/08]], |
@@ -2702,6 +2706,97 @@ patch = [[ | |||
2702 | ]=] | 2706 | ]=] |
2703 | 2707 | ||
2704 | 2708 | ||
2709 | Bug{ | ||
2710 | what = [['pcall' may not restore previous error function when | ||
2711 | inside coroutines]], | ||
2712 | report = [[Alexander Gavrilov, 2012/06/12]], | ||
2713 | since = [[5.2]], | ||
2714 | fix = nil, | ||
2715 | example = [[ | ||
2716 | function errfunc(x) | ||
2717 | return 'errfunc' | ||
2718 | end | ||
2719 | |||
2720 | function test(do_yield) | ||
2721 | print(do_yield and "yielding" or "not yielding") | ||
2722 | pcall(function() -- this pcall sets errfunc back to none | ||
2723 | if do_yield then | ||
2724 | coroutine.yield() -- stops errfunc from being restored | ||
2725 | end | ||
2726 | end) | ||
2727 | error('fail!') | ||
2728 | end | ||
2729 | |||
2730 | coro = coroutine.wrap(function() | ||
2731 | print(xpcall(test, errfunc, false)) | ||
2732 | print(xpcall(test, errfunc, true)) | ||
2733 | print(xpcall(test, errfunc, false)) | ||
2734 | end) | ||
2735 | |||
2736 | coro() | ||
2737 | --> not yielding | ||
2738 | --> false errfunc | ||
2739 | --> yielding | ||
2740 | coro() | ||
2741 | --> false temp:12: fail! <<<< should be 'errfunc' too | ||
2742 | --> not yielding | ||
2743 | --> false errfunc | ||
2744 | ]], | ||
2745 | patch = [[ | ||
2746 | --- ldo.c 2012/08/28 18:30:45 2.107 | ||
2747 | +++ ldo.c 2012/09/23 15:49:55 | ||
2748 | @@ -403,7 +403,11 @@ | ||
2749 | int n; | ||
2750 | lua_assert(ci->u.c.k != NULL); /* must have a continuation */ | ||
2751 | lua_assert(L->nny == 0); | ||
2752 | - /* finish 'lua_callk' */ | ||
2753 | + if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ | ||
2754 | + ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */ | ||
2755 | + L->errfunc = ci->u.c.old_errfunc; | ||
2756 | + } | ||
2757 | + /* finish 'lua_callk'/'lua_pcall' */ | ||
2758 | adjustresults(L, ci->nresults); | ||
2759 | /* call continuation function */ | ||
2760 | if (!(ci->callstatus & CIST_STAT)) /* no call status? */ | ||
2761 | ]] | ||
2762 | } | ||
2763 | |||
2764 | Bug{ | ||
2765 | what = [[Check for garbage collector in function calls does not cover | ||
2766 | all paths]], | ||
2767 | report = [[Roberto, 2012/08/15]], | ||
2768 | since = [[5.2.1]], | ||
2769 | fix = nil, | ||
2770 | example = [[ | ||
2771 | See <a href="http://lua-users.org/lists/lua-l/2012-08/msg00149.html"> | ||
2772 | http://lua-users.org/lists/lua-l/2012-08/msg00149.html</a> | ||
2773 | ]], | ||
2774 | patch = [[ | ||
2775 | @@ -311,6 +311,7 @@ | ||
2776 | ci->top = L->top + LUA_MINSTACK; | ||
2777 | lua_assert(ci->top <= L->stack_last); | ||
2778 | ci->callstatus = 0; | ||
2779 | + luaC_checkGC(L); /* stack grow uses memory */ | ||
2780 | if (L->hookmask & LUA_MASKCALL) | ||
2781 | luaD_hook(L, LUA_HOOKCALL, -1); | ||
2782 | lua_unlock(L); | ||
2783 | @@ -338,6 +339,7 @@ | ||
2784 | ci->u.l.savedpc = p->code; /* starting point */ | ||
2785 | ci->callstatus = CIST_LUA; | ||
2786 | L->top = ci->top; | ||
2787 | + luaC_checkGC(L); /* stack grow uses memory */ | ||
2788 | if (L->hookmask & LUA_MASKCALL) | ||
2789 | callhook(L, ci); | ||
2790 | return 0; | ||
2791 | @@ -393,7 +395,6 @@ | ||
2792 | luaV_execute(L); /* call it */ | ||
2793 | if (!allowyield) L->nny--; | ||
2794 | L->nCcalls--; | ||
2795 | - luaC_checkGC(L); | ||
2796 | } | ||
2797 | ]] | ||
2798 | } | ||
2799 | |||
2705 | --[=[ | 2800 | --[=[ |
2706 | Bug{ | 2801 | Bug{ |
2707 | what = [[ ]], | 2802 | what = [[ ]], |