| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Frequently Asked Questions (FAQ)</title>
- <meta charset="utf-8">
- <meta name="Copyright" content="Copyright (C) 2005-2022">
- <meta name="Language" content="en">
- <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
- <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
- <style type="text/css">
- dd { margin-left: 1.5em; }
- </style>
- </head>
- <body>
- <div id="site">
- <a href="https://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
- </div>
- <div id="head">
- <h1>Frequently Asked Questions (FAQ)</h1>
- </div>
- <div id="nav">
- <ul><li>
- <a href="luajit.html">LuaJIT</a>
- <ul><li>
- <a href="https://luajit.org/download.html">Download <span class="ext">»</span></a>
- </li><li>
- <a href="install.html">Installation</a>
- </li><li>
- <a href="running.html">Running</a>
- </li></ul>
- </li><li>
- <a href="extensions.html">Extensions</a>
- <ul><li>
- <a href="ext_ffi.html">FFI Library</a>
- <ul><li>
- <a href="ext_ffi_tutorial.html">FFI Tutorial</a>
- </li><li>
- <a href="ext_ffi_api.html">ffi.* API</a>
- </li><li>
- <a href="ext_ffi_semantics.html">FFI Semantics</a>
- </li></ul>
- </li><li>
- <a href="ext_buffer.html">String Buffers</a>
- </li><li>
- <a href="ext_jit.html">jit.* Library</a>
- </li><li>
- <a href="ext_c_api.html">Lua/C API</a>
- </li><li>
- <a href="ext_profiler.html">Profiler</a>
- </li></ul>
- </li><li>
- <a href="status.html">Status</a>
- </li><li>
- <a class="current" href="faq.html">FAQ</a>
- </li><li>
- <a href="http://wiki.luajit.org/">Wiki <span class="ext">»</span></a>
- </li><li>
- <a href="https://luajit.org/list.html">Mailing List <span class="ext">»</span></a>
- </li></ul>
- </div>
- <div id="main">
- <dl id="info">
- <dt>Q: Where can I learn more about LuaJIT and Lua?</dt>
- <dd>
- <ul style="padding: 0;">
- <li>The <a href="https://luajit.org/list.html"><span class="ext">»</span> LuaJIT mailing list</a> focuses on topics
- related to LuaJIT.</li>
- <li>The <a href="http://wiki.luajit.org/"><span class="ext">»</span> LuaJIT wiki</a> gathers community
- resources about LuaJIT.</li>
- <li>News about Lua itself can be found at the
- <a href="https://www.lua.org/lua-l.html"><span class="ext">»</span> Lua mailing list</a>.
- The mailing list archives are worth checking out for older postings
- about LuaJIT.</li>
- <li>The <a href="https://lua.org"><span class="ext">»</span> main Lua.org site</a> has complete
- <a href="https://www.lua.org/docs.html"><span class="ext">»</span> documentation</a> of the language
- and links to books and papers about Lua.</li>
- <li>The community-managed <a href="http://lua-users.org/wiki/"><span class="ext">»</span> Lua Wiki</a>
- has information about diverse topics.</li>
- </ul></dd>
- </dl>
- <dl id="tech">
- <dt>Q: Where can I learn more about the compiler technology used by LuaJIT?</dt>
- <dd>
- Please use the following Google Scholar searches to find relevant papers:<br>
- Search for: <a href="https://scholar.google.com/scholar?q=Trace+Compiler"><span class="ext">»</span> Trace Compiler</a><br>
- Search for: <a href="https://scholar.google.com/scholar?q=JIT+Compiler"><span class="ext">»</span> JIT Compiler</a><br>
- Search for: <a href="https://scholar.google.com/scholar?q=Dynamic+Language+Optimizations"><span class="ext">»</span> Dynamic Language Optimizations</a><br>
- Search for: <a href="https://scholar.google.com/scholar?q=SSA+Form"><span class="ext">»</span> SSA Form</a><br>
- Search for: <a href="https://scholar.google.com/scholar?q=Linear+Scan+Register+Allocation"><span class="ext">»</span> Linear Scan Register Allocation</a><br>
- Here is a list of the <a href="http://lua-users.org/lists/lua-l/2009-11/msg00089.html"><span class="ext">»</span> innovative features in LuaJIT</a>.<br>
- And, you know, reading the source is of course the only way to enlightenment.
- </dd>
- </dl>
- <dl id="arg">
- <dt>Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?<br>
- Q: My vararg functions fail after switching to LuaJIT!</dt>
- <dd>LuaJIT is compatible to the Lua 5.1 language standard. It doesn't
- support the implicit <tt>arg</tt> parameter for old-style vararg
- functions from Lua 5.0.<br>Please convert your code to the
- <a href="https://www.lua.org/manual/5.1/manual.html#2.5.9"><span class="ext">»</span> Lua 5.1
- vararg syntax</a>.</dd>
- </dl>
- <dl id="x87">
- <dt>Q: Why do I get this error: "bad FPU precision"?<br>
- <dt>Q: I get weird behavior after initializing Direct3D.<br>
- <dt>Q: Some FPU operations crash after I load a Delphi DLL.<br>
- </dt>
- <dd>
- DirectX/Direct3D (up to version 9) sets the x87 FPU to single-precision
- mode by default. This violates the Windows ABI and interferes with the
- operation of many programs — LuaJIT is affected, too. Please make
- sure you always use the <tt>D3DCREATE_FPU_PRESERVE</tt> flag when
- initializing Direct3D.<br>
- Direct3D version 10 or higher do not show this behavior anymore.
- Consider testing your application with older versions, too.<br>
- Similarly, the Borland/Delphi runtime modifies the FPU control word and
- enables FP exceptions. Of course, this violates the Windows ABI, too.
- Please check the Delphi docs for the Set8087CW method.</dd>
- </dl>
- <dl id="ctrlc">
- <dt>Q: Sometimes Ctrl-C fails to stop my Lua program. Why?</dt>
- <dd>The interrupt signal handler sets a Lua debug hook. But this is
- ignored by compiled code. If your program is running in a tight loop
- and never falls back to the interpreter, the debug hook never runs and
- can't throw the "interrupted!" error.<br>
- You have to press Ctrl-C twice to stop your program. That's similar
- to when it's stuck running inside a C function under the Lua interpreter.</dd>
- </dl>
- <dl id="order">
- <dt>Q: Table iteration with <tt>pairs()</tt> does not result in the same order?</dt>
- <dd>The order of table iteration is explicitly <b>undefined</b> by
- the Lua language standard.<br>
- Different Lua implementations or versions may use different orders for
- otherwise identical tables. Different ways of constructing a table may
- result in different orders, too.<br>
- Due to improved VM security, LuaJIT 2.1 may even use a different order
- on separate VM invocations or when string keys are newly interned.<br><br>
- If your program relies on a deterministic order, it has a bug. Rewrite it,
- so it doesn't rely on the key order. Or sort the table keys, if you must.</dd>
- </dl>
- <dl id="sandbox">
- <dt>Q: Can Lua code be safely sandboxed?</dt>
- <dd>
- Maybe for an extremely restricted subset of Lua and if you relentlessly
- scrutinize every single interface function you offer to the untrusted code.<br>
- Although Lua provides some sandboxing functionality (<tt>setfenv()</tt>, hooks),
- it's very hard to get this right even for the Lua core libraries. Of course,
- you'll need to inspect any extension library, too. And there are libraries
- that are inherently unsafe, e.g. the <a href="ext_ffi.html">FFI library</a>.<br>
- More reading material at the <a href="http://lua-users.org/wiki/SandBoxes"><span class="ext">»</span> Lua Wiki</a> and <a href="https://en.wikipedia.org/wiki/Sandbox_(computer_security)"><span class="ext">»</span> Wikipedia</a>.<br><br>
- Relatedly, <b>loading untrusted bytecode is not safe!</b><br>
- It's trivial to crash the Lua or LuaJIT VM with maliciously crafted bytecode.
- This is well known and there's no bytecode verification on purpose, so please
- don't report a bug about it. Check the <tt>mode</tt> parameter for the
- <tt>load*()</tt> functions to disable loading of bytecode.<br><br>
- <b>In general, the only promising approach is to sandbox Lua code at the
- process level and not the VM level.</b>
- </dd>
- </dl>
- <dl id="arch">
- <dt>Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?</dt>
- <dd>Because it's a compiler — it needs to generate native
- machine code. This means the code generator must be ported to each
- architecture. And the fast interpreter is written in assembler and
- must be ported, too. This is quite an undertaking.<br>
- The <a href="install.html">install documentation</a> shows the supported
- architectures.<br>
- Other architectures may follow based on sufficient user demand and
- market-relevance of the architecture. Sponsoring is required to develop
- the port itself, to integrate it and to continuously maintain it in the
- actively developed branches.</dd>
- </dl>
- <br class="flush">
- </div>
- <div id="foot">
- <hr class="hide">
- Copyright © 2005-2022
- <span class="noprint">
- ·
- <a href="contact.html">Contact</a>
- </span>
- </div>
- </body>
- </html>
|