summaryrefslogtreecommitdiff
path: root/doc/faq.html
diff options
context:
space:
mode:
authorMike Pall <mike>2023-08-21 02:38:56 +0200
committerMike Pall <mike>2023-08-21 02:38:56 +0200
commitf0ff869bc2fffa17bb765c4c773457578da125a9 (patch)
treea439bf4fe179352af5a6808ab5c5d4584cff197e /doc/faq.html
parentef587afb2cd7267c0defd04aa642593b76a6b23d (diff)
parentc34594681909cac98d44629863df2c7afd93eaf0 (diff)
downloadluajit-f0ff869bc2fffa17bb765c4c773457578da125a9.tar.gz
luajit-f0ff869bc2fffa17bb765c4c773457578da125a9.tar.bz2
luajit-f0ff869bc2fffa17bb765c4c773457578da125a9.zip
Merge branch 'master' into v2.1
Diffstat (limited to 'doc/faq.html')
-rw-r--r--doc/faq.html195
1 files changed, 0 insertions, 195 deletions
diff --git a/doc/faq.html b/doc/faq.html
deleted file mode 100644
index a53a7512..00000000
--- a/doc/faq.html
+++ /dev/null
@@ -1,195 +0,0 @@
1<!DOCTYPE html>
2<html>
3<head>
4<title>Frequently Asked Questions (FAQ)</title>
5<meta charset="utf-8">
6<meta name="Copyright" content="Copyright (C) 2005-2023">
7<meta name="Language" content="en">
8<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
9<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
10<style type="text/css">
11dd { margin-left: 1.5em; }
12</style>
13</head>
14<body>
15<div id="site">
16<a href="https://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
17</div>
18<div id="head">
19<h1>Frequently Asked Questions (FAQ)</h1>
20</div>
21<div id="nav">
22<ul><li>
23<a href="luajit.html">LuaJIT</a>
24<ul><li>
25<a href="https://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
26</li><li>
27<a href="install.html">Installation</a>
28</li><li>
29<a href="running.html">Running</a>
30</li></ul>
31</li><li>
32<a href="extensions.html">Extensions</a>
33<ul><li>
34<a href="ext_ffi.html">FFI Library</a>
35<ul><li>
36<a href="ext_ffi_tutorial.html">FFI Tutorial</a>
37</li><li>
38<a href="ext_ffi_api.html">ffi.* API</a>
39</li><li>
40<a href="ext_ffi_semantics.html">FFI Semantics</a>
41</li></ul>
42</li><li>
43<a href="ext_buffer.html">String Buffers</a>
44</li><li>
45<a href="ext_jit.html">jit.* Library</a>
46</li><li>
47<a href="ext_c_api.html">Lua/C API</a>
48</li><li>
49<a href="ext_profiler.html">Profiler</a>
50</li></ul>
51</li><li>
52<a href="status.html">Status</a>
53</li><li>
54<a class="current" href="faq.html">FAQ</a>
55</li><li>
56<a href="https://luajit.org/list.html">Mailing List <span class="ext">&raquo;</span></a>
57</li></ul>
58</div>
59<div id="main">
60<dl id="info">
61<dt>Q: Where can I learn more about LuaJIT and Lua?</dt>
62<dd>
63<ul style="padding: 0;">
64<li>The <a href="https://luajit.org/list.html"><span class="ext">&raquo;</span>&nbsp;LuaJIT mailing list</a> focuses on topics
65related to LuaJIT.</li>
66<li>News about Lua itself can be found at the
67<a href="https://www.lua.org/lua-l.html"><span class="ext">&raquo;</span>&nbsp;Lua mailing list</a>.
68The mailing list archives are worth checking out for older postings
69about LuaJIT.</li>
70<li>The <a href="https://lua.org"><span class="ext">&raquo;</span>&nbsp;main Lua.org site</a> has complete
71<a href="https://www.lua.org/docs.html"><span class="ext">&raquo;</span>&nbsp;documentation</a> of the language
72and links to books and papers about Lua.</li>
73<li>The community-managed <a href="http://lua-users.org/wiki/"><span class="ext">&raquo;</span>&nbsp;Lua Wiki</a>
74has information about diverse topics.</li>
75</ul></dd>
76</dl>
77
78<dl id="tech">
79<dt>Q: Where can I learn more about the compiler technology used by LuaJIT?</dt>
80<dd>
81Please use the following Google Scholar searches to find relevant papers:<br>
82Search for: <a href="https://scholar.google.com/scholar?q=Trace+Compiler"><span class="ext">&raquo;</span>&nbsp;Trace Compiler</a><br>
83Search for: <a href="https://scholar.google.com/scholar?q=JIT+Compiler"><span class="ext">&raquo;</span>&nbsp;JIT Compiler</a><br>
84Search for: <a href="https://scholar.google.com/scholar?q=Dynamic+Language+Optimizations"><span class="ext">&raquo;</span>&nbsp;Dynamic Language Optimizations</a><br>
85Search for: <a href="https://scholar.google.com/scholar?q=SSA+Form"><span class="ext">&raquo;</span>&nbsp;SSA Form</a><br>
86Search for: <a href="https://scholar.google.com/scholar?q=Linear+Scan+Register+Allocation"><span class="ext">&raquo;</span>&nbsp;Linear Scan Register Allocation</a><br>
87Here is a list of the <a href="http://lua-users.org/lists/lua-l/2009-11/msg00089.html"><span class="ext">&raquo;</span>&nbsp;innovative features in LuaJIT</a>.<br>
88And, you know, reading the source is of course the only way to enlightenment.
89</dd>
90</dl>
91
92<dl id="arg">
93<dt>Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?<br>
94Q: My vararg functions fail after switching to LuaJIT!</dt>
95<dd>LuaJIT is compatible to the Lua 5.1 language standard. It doesn't
96support the implicit <tt>arg</tt> parameter for old-style vararg
97functions from Lua 5.0.<br>Please convert your code to the
98<a href="https://www.lua.org/manual/5.1/manual.html#2.5.9"><span class="ext">&raquo;</span>&nbsp;Lua 5.1
99vararg syntax</a>.</dd>
100</dl>
101
102<dl id="x87">
103<dt>Q: Why do I get this error: "bad FPU precision"?<br>
104<dt>Q: I get weird behavior after initializing Direct3D.<br>
105<dt>Q: Some FPU operations crash after I load a Delphi DLL.<br>
106</dt>
107<dd>
108
109DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision
110mode by default. This violates the Windows ABI and interferes with the
111operation of many programs &mdash; LuaJIT is affected, too. Please make
112sure you always use the <tt>D3DCREATE_FPU_PRESERVE</tt> flag when
113initializing Direct3D.<br>
114
115Direct3D version 10 or higher do not show this behavior anymore.
116Consider testing your application with older versions, too.<br>
117
118Similarly, the Borland/Delphi runtime modifies the FPU control word and
119enables FP exceptions. Of course, this violates the Windows ABI, too.
120Please check the Delphi docs for the Set8087CW method.</dd>
121</dl>
122
123<dl id="ctrlc">
124<dt>Q: Sometimes Ctrl-C fails to stop my Lua program. Why?</dt>
125<dd>The interrupt signal handler sets a Lua debug hook. But this is
126ignored by compiled code. If your program is running in a tight loop
127and never falls back to the interpreter, the debug hook never runs and
128can't throw the "interrupted!" error.<br>
129You have to press Ctrl-C twice to stop your program. That's similar
130to when it's stuck running inside a C function under the Lua interpreter.</dd>
131</dl>
132
133<dl id="order">
134<dt>Q: Table iteration with <tt>pairs()</tt> does not result in the same order?</dt>
135<dd>The order of table iteration is explicitly <b>undefined</b> by
136the Lua language standard.<br>
137Different Lua implementations or versions may use different orders for
138otherwise identical tables. Different ways of constructing a table may
139result in different orders, too.<br>
140Due to improved VM security, LuaJIT 2.1 may even use a different order
141on separate VM invocations or when string keys are newly interned.<br><br>
142If your program relies on a deterministic order, it has a bug. Rewrite it,
143so it doesn't rely on the key order. Or sort the table keys, if you must.</dd>
144</dl>
145
146<dl id="sandbox">
147<dt>Q: Can Lua code be safely sandboxed?</dt>
148<dd>
149Maybe for an extremely restricted subset of Lua and if you relentlessly
150scrutinize every single interface function you offer to the untrusted code.<br>
151
152Although Lua provides some sandboxing functionality (<tt>setfenv()</tt>, hooks),
153it's very hard to get this right even for the Lua core libraries. Of course,
154you'll need to inspect any extension library, too. And there are libraries
155that are inherently unsafe, e.g. the <a href="ext_ffi.html">FFI library</a>.<br>
156
157More reading material at the <a href="http://lua-users.org/wiki/SandBoxes"><span class="ext">&raquo;</span>&nbsp;Lua Wiki</a> and <a href="https://en.wikipedia.org/wiki/Sandbox_(computer_security)"><span class="ext">&raquo;</span>&nbsp;Wikipedia</a>.<br><br>
158
159Relatedly, <b>loading untrusted bytecode is not safe!</b><br>
160
161It's trivial to crash the Lua or LuaJIT VM with maliciously crafted bytecode.
162This is well known and there's no bytecode verification on purpose, so please
163don't report a bug about it. Check the <tt>mode</tt> parameter for the
164<tt>load*()</tt> functions to disable loading of bytecode.<br><br>
165
166<b>In general, the only promising approach is to sandbox Lua code at the
167process level and not the VM level.</b>
168</dd>
169</dl>
170
171<dl id="arch">
172<dt>Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?</dt>
173<dd>Because it's a compiler &mdash; it needs to generate native
174machine code. This means the code generator must be ported to each
175architecture. And the fast interpreter is written in assembler and
176must be ported, too. This is quite an undertaking.<br>
177The <a href="install.html">install documentation</a> shows the supported
178architectures.<br>
179Other architectures may follow based on sufficient user demand and
180market-relevance of the architecture. Sponsoring is required to develop
181the port itself, to integrate it and to continuously maintain it in the
182actively developed branches.</dd>
183</dl>
184<br class="flush">
185</div>
186<div id="foot">
187<hr class="hide">
188Copyright &copy; 2005-2023
189<span class="noprint">
190&middot;
191<a href="contact.html">Contact</a>
192</span>
193</div>
194</body>
195</html>