lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Alfredo Palhares wrote:
> Hello Lua-l wizards,
> 
> I was trying to add a dynamic tag library to my Awesome WM, while
> trying it, i got the following error.
> 
> ...orp/Documents/projects/public/awesome-tyranical/init.lua:49: too many C levels (limit is 200) in function at line 39 near 'v'
> 
> I have to idea what this error means, I know its a "require time"
> error, thus making it harder to debug, because as soon as I do
> local tyranical = require("tyranical").
> 
> I failed to google about this error, and how to confront it.
> 
> I have the library in a git repo[1] (example branch), if you want to
> test, you just need to install awesomewm and xephyr and do "sh utils/xephyr.sh start"
> 
> Please enlighten me.
> 
> [1] https://github.com/masterkorp/awesome-tyranical/tree/example

I 'grep'ped through the Lua 5.2.1 source code and found this error
message in two places of lparser.c: One is in the function "enterlevel"
(line 333), the other in "assignment" (line 1151).

I would have believed that this error only happens when you have an
extremely nested code, which does not appear to be the case in your file
and I could not reproduce the error by just calling loadfile on your
script (and I did not download and install the entire environment).

I suspect that the parser uses the same C stack counter as the
interpreter and there might be circular references in your modules.
Module "a" requires module "b", which requires "c", which in turn
requires "a" again. As long as all modules are only registered when they
return, you run into an endless recursion.

The Lua 5.2 solution would be:

> local M = {}
> package.loaded[...] = M  -- '...' evaluates to the name by which your module was required
> -- now you can require modules that again require yours
> -- ...and finally:
> return M

I haven't installed your environment yet, so this is only guesswork, but
I hope it helps nonetheless.

Regards,

David Kolf