LuaLanes / lanes

Lanes is a lightweight, native, lazy evaluating multithreading library for Lua 5.1 to 5.4.
Other
465 stars 96 forks source link

hook cancel test fails with 3.15.0 #198

Closed ConiKost closed 2 years ago

ConiKost commented 3 years ago

It seems, that the hook cancel test fails for me with newest release:

####################################################################
begin hook cancel test

wait 2s
                        entering        laneBody(get,300000)
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ...                   error handler got       cancel_error
                        error handler rethrowing 'cancel_error'
                        laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin hard cancel test

wait 2s
                        entering        laneBody(receive,nil)
                        lane calling receive() ...                      error handler got       cancel_error
                        error handler rethrowing 'cancel_error'
                        laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin hard cancel test with unprotected lane body

wait 2s
                        entering        laneBody(receive,nil)
                        lane calling receive() ...                      laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin kill cancel test

wait 0.3s
                        entering        laneBody(busy,50000000)
lua5.3: tests/cancel.lua:202: force-killed lane failed to terminate within 0.0 second
stack traceback:
        [C]: in method 'cancel'
        tests/cancel.lua:202: in main chunk
        [C]: in ?
                        lane busy waiting ... make[1]: *** [Makefile:99: cancel] Fehler 1
benoit-germain commented 3 years ago

Strange, I ran all tests with no issue. Notably here is what I get (windows 10 x64, running with Lua 5.3.5 x64):

####################################################################
begin kill cancel test

wait 0.3s
                        entering        laneBody(busy,50000000)
                        lane busy waiting ... lane status:      killed
test OK

done
ConiKost commented 3 years ago

Which more information I could provice for you, so you could try to debug? I can reproduce that here.

benoit-germain commented 3 years ago

A good start would be the Lua version you are using, and a full stack trace of the crash, possibly with a non optimized build of Lua and Lanes.

ConiKost commented 3 years ago

In this case, I am using Lua 5.3, but also able to reproduce with Lua 5.2 and 5.4.

Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio
Lua 5.3.6  Copyright (C) 1994-2020 Lua.org, PUC-Rio
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio

How do I produce a full stack trace?

Here is the full log:

make -j1 LUA=lua5.3 test
make errhangtest
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird betreten
LUA_CPATH="./src/?.so" LUA_PATH="./src/?.lua;./tests/?.lua" lua5.3 tests/errhangtest.lua
true    true
false   tried to copy unsupported types
oh boy
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird verlassen
make irayo_recursive
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird betreten
LUA_CPATH="./src/?.so" LUA_PATH="./src/?.lua;./tests/?.lua" lua5.3 tests/irayo_recursive.lua
level 0
level 1
level 2
level 3
level 4
level 5
level 6
level 7
level 8
level 9
level 10
level 11
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird verlassen
make irayo_closure
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird betreten
LUA_CPATH="./src/?.so" LUA_PATH="./src/?.lua;./tests/?.lua" lua5.3 tests/irayo_closure.lua
using the closure
true
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird verlassen
make basic
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird betreten
LUA_CPATH="./src/?.so" LUA_PATH="./src/?.lua;./tests/?.lua" lua5.3 tests/basic.lua

        ---=== Tasking (basic) ===---

done    running
waiting...
5083    true
6500    true
                                ---> lane 'task(200,300,4)' collected with status closed
                                ---> lane 'task(100,200,3)' collected with status closed

        ---=== Tasking (cancelling) ===---

.. running
..... cancelled
limited[key] = table: 0x5cfd682967c0
wait_send_lane is waiting
wait_send       nil     nil
wait_send_lane is cancelled
wait_receive_lane is waiting
wait_receive    nil     nil
wait_receive_lane is cancelled
wait_receive_batched_lane is waiting
wait_receive_batched    nil     nil     nil
wait_receive_batched_lane is cancelled

        ---=== Communications ===---

1 sent
2 sent
...Lane starts!
.1 received
.2 received
...............................................................................................3 sent
3 received
1,2,3 sent
lane status: running
'a' sent
1, 2, 3 received
{'a','b','c',d=10} sent
a received
table received
4 received
{ subT1, subT2, subT1, subT2} sent
Lane ends!
table received
subT1, subT2, subT1, subT2                              ---> lane 'chunk' collected with status closed

        ---=== Stdlib naming ===---

### checking coroutine lib existence for 'coroutine'
### checking io and os libs existence for '*'
### checking io and os libs existence for 'io,os'
### checking io and os libs existence for 'io+os'
### checking io and os libs existence for 'io,os,base'
                                ---> lane 'io_os_f' collected with status closed
                                ---> lane 'io_os_f' collected with status closed
                                ---> lane 'io_os_f' collected with status closed
                                ---> lane 'io_os_f' collected with status closed
                                ---> lane 'coro_f' collected with status closed

        ---=== Comms criss cross ===---

A: Hello
B: Hello
B: I was here first!
A: I was here first!
B: So what?
A: So what?
                                ---> lane 'criss cross B -> A' collected with status closed
                                ---> lane 'criss cross A -> B' collected with status closed

        ---=== Receive & send of code ===---

namewhat
currentline     381
source  @tests/basic.lua
isvararg        false
linedefined     377
func    function: 0x5cfd682f7890
nups    3
nparams 1
what    Lua
istailcall      false
short_src       tests/basic.lua
lastlinedefined 405
ready!

        ---=== :join test ===---

joining with 'join test lane'
join test lane  14      13      12      nil
name of function print = '_G/print'
Done! :)
                                ---> lane 'join test lane' collected with status closed
                                ---> lane '<unnamed>' collected with status closed
                                ---> lane 'task(1,999999999,1)' collected with status closed
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird verlassen
make cancel
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird betreten
LUA_CPATH="./src/?.so" LUA_PATH="./src/?.lua;./tests/?.lua" lua5.3 tests/cancel.lua

####################################################################
begin genlock & genatomic cancel test

test OK

####################################################################
begin linda cancel test

wait 1s
                        entering        laneBody(receive,nil)
                        lane calling receive() ... cancel_error nil
                        lane shutting down after breaking out of loop
                        laneBody finalized
lane status:    done
test OK

####################################################################
begin soft cancel test

wait 1s
                        entering        laneBody(receive,nil)
                        lane calling receive() ... lane status: waiting
test OK
cancel_error    nil
                        lane shutting down after breaking out of loop
                        laneBody finalized
lane status:    done
test OK

####################################################################
begin hook cancel test

wait 2s
                        entering        laneBody(get,300000)
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ... again?
                        lane busy waiting ...                   error handler got       cancel_error
                        error handler rethrowing 'cancel_error'
                        laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin hard cancel test

wait 2s
                        entering        laneBody(receive,nil)
                        lane calling receive() ...                      error handler got       cancel_error
                        error handler rethrowing 'cancel_error'
                        laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin hard cancel test with unprotected lane body

wait 2s
                        entering        laneBody(receive,nil)
                        lane calling receive() ...                      laneBody after cancel
lane status:    cancelled
test OK

####################################################################
begin kill cancel test

wait 0.3s
                        entering        laneBody(busy,50000000)
lua5.3: tests/cancel.lua:202: force-killed lane failed to terminate within 0.0 second
stack traceback:
        [C]: in method 'cancel'
        tests/cancel.lua:202: in main chunk
        [C]: in ?
                        lane busy waiting ... make[1]: *** [Makefile:99: cancel] Fehler 1
make[1]: Verzeichnis „/var/tmp/portage/dev-lua/lanes-3.15.0/work/lanes-3.15.0-lua5-3“ wird verlassen
make: *** [Makefile:79: test] Fehler 2
benoit-germain commented 3 years ago

The logs in themselves won't help. You need to run lua from a debugger, which should show the state of the program at the point of the crash.

benoit-germain commented 3 years ago

I've run all the tests with Lua 5.1 to 5.4 with API checks enabled, everything works fine for me. I had a Lua 5.4-specific bug related to function transfers, but it is now fixed (v3.15.1).