Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to call a nil value (upvalue 'f') #67

Closed
yanhuacuo opened this issue Sep 14, 2020 · 14 comments
Closed

attempt to call a nil value (upvalue 'f') #67

yanhuacuo opened this issue Sep 14, 2020 · 14 comments

Comments

@yanhuacuo
Copy link

yanhuacuo commented Sep 14, 2020

升级到了 新的COMMIT后,原来正常的lua脚本收到一堆同一个指向的报错 aeb1e9d

求指点大概的原因在哪里,看得一头雾水。



Log file created at: 2020/09/14 11:15:58


Running on machine: DESKTOP-2E92SH5


Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg


E0914 11:15:58.694053  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.695050  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.696096  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.697018  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.697018  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.697018  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.697018  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.697018  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.805943  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.806226  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.806226  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.806226  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.996857  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.997216  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.997216  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:15:58.997216  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:16:00.265516  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:16:00.265516  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:16:00.265516  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0914 11:16:00.265516  8068 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


@yanhuacuo
Copy link
Author

上一次编译是 7月9号,配置没有动过,新的 COMMIT 后,就如上报错了。

@yanhuacuo yanhuacuo reopened this Sep 14, 2020
@hchunhui
Copy link
Owner

错误报在了内部的 helper code,所以看起来有些误导。它的意思是没有找到 lua_filter@ lua_translator@ 后面跟的那个函数。

新的 commit 只是会在 user dir 找不到 lua 脚本的情况下,去 shared dir (程序文件夹)找,这个修改看起来没问题,我自己用也是正常的。如果可以确定是这个 commit 导致的,需要检查一下是不是以前不小心在 $shared_dir/lua 放了某些文件导致冲突。

另外最近(7月2号)我把 lua 的默认版本从5.3调到了5.4,也有可能是这个原因导致的。

@yanhuacuo
Copy link
Author

初步分析,可能是 lua 版本引起的问题,

大佬有时间的话,测试一下这个函数能否正常加载,这个是之前的「单字过滤」的功能。

--- single_char
function single_char(input, env)
   b = env.engine.context:get_option("single_char")
   for cand in input:iter() do
      if (not b or utf8.len(cand.text) == 1 or cand.type == "qsj"or cand.type == "time"or cand.type == "date"or cand.type == "help") then
         yield(cand)
      end
   end
end

@yanhuacuo
Copy link
Author

yanhuacuo commented Sep 14, 2020

确信上述函数能引起报错,但是从报错内容上看,看不出原因。
查了一下 lua5.4 的文档,luaconf.h 中的不兼容列表里,也没找到该函数使用到的相关关键字。
报错内容,没有改变……
哦,怀疑人生。
因为……还有一批实现某些功能的,更复杂的函数也是一并失效的,但原因只能逐个查找。
这个最简单的要是查清,可能别的也就容易处理了。

Log file created at: 2020/09/15 00:53:25


Running on machine: DESKTOP-2E92SH5


Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg


E0915 00:53:25.037729 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:53:25.039768 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:53:25.247362 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:53:26.731674 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:53:26.931860 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:54:05.136234 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:54:05.373957 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:54:06.486285 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0915 00:54:06.673799 18352 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')

@yanhuacuo
Copy link
Author

我仔细比对了早前正常编译的版本,确实是 7月9号 拉下来的文件,那时的 lua 已然是 5.4 了,一切都是正常了。
我猜,也许最新的 commit 大概也是正常的。

这两次事件唯一的「变量」就是 Librime 的主代码。

我使用了今天这个时间节点上的 librime 主代码:

rime/librime@f3a2ad0

最新的 librime 主代码对咱们的 lua 库有了冲突?

很可能是这样……

@yanhuacuo
Copy link
Author

时间线上看,Librime 主代码在这两个月内更新二十多次,Lua的报错部分(如上所贴)又看不出端倪,大概率是兼容方面出了问题。

只能期待大佬来排雷了。

https://github.com/rime/librime/commits/master

@yanhuacuo
Copy link
Author

lua插件放到 7月9号的 librime 代码节点里,编译出的 librime 一切正常,确认是 librime 最新的主代码节点,对咱们的 Lua插件不兼容了。

@CharlesMengCA
Copy link

Jul 27, 2020的librime也没有问题。

@yanhuacuo
Copy link
Author

Jul 27, 2020的librime也没有问题。

试试最新的:rime/librime@f3a2ad0

@yanhuacuo
Copy link
Author

yanhuacuo commented Sep 16, 2020

Jul 27, 2020的librime也没有问题。

现在已经确认 lua 插件没问题,而是 librime 主代码的问题。

最新时间节点的 librime 主代码与插件联合编译正常,但是功能并不正常:

https://github.com/rime/librime/commits/master

@hchunhui
Copy link
Owner

谢谢大家的反馈。我使用了最新的 ibus-rime, librime, librime-lua 代码编译(见 https://github.com/hchunhui/ibus-rime.AppImage/releases ),但没有复现上述故障。后面有空再研究一下最近的代码变化。

@yanhuacuo
Copy link
Author

yanhuacuo commented Sep 18, 2020

谢谢大家的反馈。我使用了最新的 ibus-rime, librime, librime-lua 代码编译(见 https://github.com/hchunhui/ibus-rime.AppImage/releases ),但没有复现上述故障。后面有空再研究一下最近的代码变化。

linux 下确实可用,但 windows 下编译出的 rime.dll 又的确不可用。同一套 librime 的源码。

E0919 03:17:02.371892 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.557619 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.557619 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.557619 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.557619 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.754709 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.754709 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.755736 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:02.755736 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.386540 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.386540 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.386540 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.386540 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.597705 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.597705 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.597705 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')


E0919 03:17:03.597705 10424 lua_gears.cc:15] LuaTranslation::Next error(2): [string "table.unpack = table.unpack or unpack..."]:4: attempt to call a nil value (upvalue 'f')



@hchunhui
Copy link
Owner

我好像找到原因了,是 librime 返回了无效的 user dir 和 shared dir,导致 rime 脚本无法被正确读取并加载。

目前只有在 windows 下能观察到这个现象。我在debug 分支加了调试日志,对应的字符串打印出来是乱码:

I0920 11:25:30.476583  9576 modules.cc:40] debug: user_dir: P鸐�struct LuaType<struct rime::Segment const >
I0920 11:25:30.476583  9576 modules.cc:41] debug: shared_dir: 鐱N���
I0920 11:25:30.476583  9576 modules.cc:42] debug: user_file: P鸐�struct LuaType<struct rime::Segment const >\rime.lua
I0920 11:25:30.476583  9576 modules.cc:43] debug: shared_file: P鸐�struct LuaType<struct rime::Segment const >\rime.lua
I0920 11:25:30.476583  9576 modules.cc:59] rime.lua info: rime.lua should be either in the rime user data directory or in the rime shared data directory

@yanhuacuo
Copy link
Author

yanhuacuo commented Sep 21, 2020

我好像找到原因了,是 librime 返回了无效的 user dir 和 shared dir,导致 rime 脚本无法被正确读取并加载。

目前只有在 windows 下能观察到这个现象。我在debug 分支加了调试日志,对应的字符串打印出来是乱码:

I0920 11:25:30.476583  9576 modules.cc:40] debug: user_dir: P鸐�struct LuaType<struct rime::Segment const >
I0920 11:25:30.476583  9576 modules.cc:41] debug: shared_dir: 鐱N���
I0920 11:25:30.476583  9576 modules.cc:42] debug: user_file: P鸐�struct LuaType<struct rime::Segment const >\rime.lua
I0920 11:25:30.476583  9576 modules.cc:43] debug: shared_file: P鸐�struct LuaType<struct rime::Segment const >\rime.lua
I0920 11:25:30.476583  9576 modules.cc:59] rime.lua info: rime.lua should be either in the rime user data directory or in the rime shared data directory

今日修改【 rime/librime@78abaa8 】已修复该问题。
感谢两位大佬。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants