renatosc / jnlua

Automatically exported from code.google.com/p/jnlua
0 stars 0 forks source link

Linux 32bit Lua interpreter raise a segmentaion fault error #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Using JNLua interpreter version 0.9.6 from java I got a segmentation fault. 
Only under Linux 32bit.

Code to reproduce the bug:

<code>
import com.naef.jnlua.LuaState;

public class Main {

    public static void main(String[] args){
        System.out.println("Start");

        String luaSource = "local source, line = string.rep(\"a\\n\",4500), 2 "
                + "print('string find') io.flush()"
                + "string.find(source,string.rep('[^\\n]*\\n',line))"
                + "print('string find OK')io.flush()";

System.loadLibrary("lua5.1");

        LuaState state = new LuaState();
        state.openLibs();

        state.load(luaSource, "sample");
        state.call(0, 0);
        System.out.println("END");
    }

}
</code>

The expected output is : 
Start
string find
string find OK
END

but got:
Start
string find

Because the lua line "string.find(source,string.rep('[^\\n]*\\n',line))" crash 
the JVM.
It's can be due to the size of string manipulated, because when changing the 
value of the lua variable "line" to 2 instead of 4300 doesn't crash the JVM 
anymore.

See attached dll used.

Original issue reported on code.google.com by marc.aub...@gmail.com on 13 Dec 2013 at 10:29

Attachments: