luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau-lang.org
MIT License
3.79k stars 349 forks source link

failed assert in script file crashes repl #1273

Closed dubiousjim closed 1 month ago

dubiousjim commented 1 month ago

I've confirmed this issue against c8fe77c, though I think it's been around for longer.

I have to make some small changes to the source to be able to build on my system, but I don't think these are responsible. The changes are:

diff --git c/CMakeLists.txt w/CMakeLists.txt
index 5b7e551..281f4dc 100644
--- c/CMakeLists.txt
+++ w/CMakeLists.txt
@@ -6,6 +6,9 @@ endif()

 cmake_minimum_required(VERSION 3.0)

+set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
+set(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
+
 option(LUAU_BUILD_CLI "Build CLI" ON)
 option(LUAU_BUILD_TESTS "Build tests" ON)
 option(LUAU_BUILD_WEB "Build Web module" OFF)
diff --git c/CLI/FileUtils.cpp w/CLI/FileUtils.cpp
index 2e17bcb..c3b1eac 100644
--- c/CLI/FileUtils.cpp
+++ w/CLI/FileUtils.cpp
@@ -20,6 +20,7 @@
 #endif

 #include <string.h>
+#include <sys/errno.h>

 #ifdef _WIN32
 static std::wstring fromUtf8(const std::string& path)

My system is a Mac OS 10.15.7 with MacPorts.

The issue only arises with a debug build of Luau. Here is my build command:

cd cmake
cmake .. -DCMAKE_BUILD_TYPE=Debug;
cmake --build . --target Luau.{Repl,Analyze,Compile}.CLI --config Debug;

To produce the problem, create a script file testx.lua containing the text assert(false). (I cannot generate the problem by typing this into the interpreter/repl, it has to be in a script file.)

Then invoke the debug build of the interpreter like this:

$ ./luau -i testx.lua

One gets an error message and prompt in the interpreter, as expected. Press any key. Now the interpreter crashes. Here's a sample session:

$ ./luau -i ../testx.lua
../testx.lua:1: assertion failed!
stacktrace:
[C] function assert
../testx.lua:1
>  /Users/jim/repo/luau/VM/src/lapi.cpp(281): ASSERTION FAILED: L->top < L->ci->top
Illegal instruction: 4
vegorov-rbx commented 1 month ago

Thank you for the report, we'll fix this issue soon.