lipp / lua-websockets

Websockets for Lua.
http://lipp.github.com/lua-websockets/
MIT License
396 stars 113 forks source link

attempt to yield across C-call boundary #74

Open duzc2 opened 9 years ago

duzc2 commented 9 years ago

local copas = require'copas' local ws_client = require('websocket.client').copas() ws_client:connect('ws://127.0.0.1:8180/')

error:copas.lua:298: attempt to yield across C-call boundary

env: luajit 2.0.2 the last version of copas and coxpcall windows 7

lipp commented 9 years ago

can you provide more info? within my test environment, this works: https://github.com/lipp/lua-websockets/blob/master/spec/server_copas_spec.lua#L109

greatwolf commented 7 years ago

I can confirm I'm getting the same problem as the OP. Here's the stacktrace I get:

G:\OSS\cryptofu>luajit
LuaJIT 2.1.0-alpha -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 fold cse dce fwd dse narrow loop abc sink fuse
> copas = require 'copas'
> ws_client = require 'websocket.client'.copas()
> =ws_client
table: 0x00328998
> =ws_client:connect "ws://echo.websocket.org"
G:/LuaRocks/systree/share/lua/5.1/copas.lua:350: attempt to yield across C-call
boundary
stack traceback:
        [C]: in function 'yield'
        G:/LuaRocks/systree/share/lua/5.1/copas.lua:350: in function 'connect'
        ...uaRocks/systree/share/lua/5.1/websocket\client_copas.lua:16: in function 'sock_connect'
        G:/LuaRocks/systree/share/lua/5.1/websocket\sync.lua:128: in function <G:/LuaRocks/systree/share/lua/5.1/websocket\sync.lua:120>
        [C]: at 0x004021a0
>

env: luajit 2.1.0 copas 2.0.0-1 luasec 0.6-1 luasocket 3.0rc1 Windows 7 64-bit

Let me know if there's any other piece of info you need to help track down this bug.

greatwolf commented 7 years ago

Just tested this on lua 5.1.5 and getting similar stacktrace:

G:\OSS\cryptofu>G:\Lua-5.1.5\lua.exe
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> copas = require 'copas'
> ws = require'websocket.client'.copas()
> =ws
table: 00475FC0
> =ws.connect
function: 00475D90
> =ws:connect "ws://echo.websocket.org"
attempt to yield across metamethod/C-call boundary
stack traceback:
        [C]: in function 'yield'
        G:/LuaRocks/systree/share/lua/5.1/copas.lua:350: in function 'connect'
        ...cks/systree/share/lua/5.1/websocket\client_copas.lua:16: in function
'sock_connect'
        G:/LuaRocks/systree/share/lua/5.1/websocket\sync.lua:128: in function <G
:/LuaRocks/systree/share/lua/5.1/websocket\sync.lua:120>
        (tail call): ?
        [C]: ?
>

environment and settings the same as above except PUC-Lua 5.1.5 is used instead of luajit.

dirkvanderwalt commented 7 years ago

Hi,

I also get this error on LEDE: lua -v Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32)

First prise will be if there are a fix for the COPAS, else I'll try and get someone to build me the lua-ev package to try that since I'll need a mainloop in my application.

If you need more info feel free to ask and I'll gladly provide it

jsopenrb commented 6 years ago

It should be mentioned in the documentation that copas-mode code must run inside copas.addthread