You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You must post issues only here. Questions, ideas must be posted in discussions.
GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.
Please answer the following before submitting your issue:
What version of GopherLua are you using? : ccacf662c9d24821ea6cb1abaa515cc3b6aad7c6
What version of Go are you using? : 1.22.3
What operating system and processor architecture are you using? : Mac M1 ARM 64
What did you do? : See below
What did you expect to see? : See below
What did you see instead? : See below
There is a bug in gopher lua master lastest ccacf662c9d24821ea6cb1abaa515cc3b6aad7c6.
Under certain conditions, the compiler can produce invalid code, resulting in a nil pointer deference panic.
The following code will reproduce the bug:
id="foo"functionget_def()
return {}
endfunctiontest()
localdef=id~=nilandget_def() ornilifdef~=nilthenprint("def is not nil")
endendtest()
Invoke with:
> ./glua test3.lua
runtime error: invalid memory address or nil pointer dereference
stack traceback:
test3.lua:9: in function 'test'
test3.lua:14: in main chunk
[G]: ?
The issue is caused by incorrect byte code generation, due to another issue with the LOADNIL merging optimisation (see previously resolved issue #495).
The micro code generated by the above should generate:
Note, the LOADNIL instructions on lines 9 and 10 have been merged by the optimiser, but this is incorrect. The
2nd LOADNIL instruction was a jump target for the JMP on line 8, and merging it into the prior instruction meant
the JMP missed its target, and that the the LOADNIL for reg 1 was skipped. This resulted in an uninitialised
register value being used in subsequent operations, causing the panic.
Summary
The LOADNIL merging optimisation merges multiple LOADNIL instructions of consecutive registers into a single
instruction, however it does not take into account if any of the LOADNIL instructions are jump targets, and so breaks
the logic.
The text was updated successfully, but these errors were encountered:
tul
linked a pull request
Jan 10, 2025
that will
close
this issue
You must post issues only here. Questions, ideas must be posted in discussions.
Please answer the following before submitting your issue:
ccacf662c9d24821ea6cb1abaa515cc3b6aad7c6
There is a bug in gopher lua master lastest
ccacf662c9d24821ea6cb1abaa515cc3b6aad7c6
.Under certain conditions, the compiler can produce invalid code, resulting in a nil pointer deference panic.
The following code will reproduce the bug:
Invoke with:
The issue is caused by incorrect byte code generation, due to another issue with the
LOADNIL
merging optimisation (see previously resolved issue #495).The micro code generated by the above should generate:
But instead, it generates:
Note, the
LOADNIL
instructions on lines 9 and 10 have been merged by the optimiser, but this is incorrect. The2nd
LOADNIL
instruction was a jump target for theJMP
on line 8, and merging it into the prior instruction meantthe
JMP
missed its target, and that the theLOADNIL
for reg 1 was skipped. This resulted in an uninitialisedregister value being used in subsequent operations, causing the panic.
Summary
The
LOADNIL
merging optimisation merges multipleLOADNIL
instructions of consecutive registers into a singleinstruction, however it does not take into account if any of the
LOADNIL
instructions are jump targets, and so breaksthe logic.
The text was updated successfully, but these errors were encountered: