Roberto Ierusalimschy
b5c65705ca
New year (2023)
...
Also, small tweak in makefile. (-Wsign-compare is already enabled by
-Wextra.)
2023-03-31 11:47:31 -03:00
Roberto Ierusalimschy
7ca8105a2e
More orderliness in casts of enumerations
2023-03-27 16:29:39 -03:00
Roberto Ierusalimschy
94689ac3ad
More regularity in uses of enums in 'lcode.c'
2023-03-24 15:52:03 -03:00
Roberto Ierusalimschy
ab859fe59b
Bug: Loading a corrupted binary file can segfault
...
The size of the list of upvalue names are stored separated from the
size of the list of upvalues, but they share the same array.
2023-03-17 15:52:09 -03:00
Roberto Ierusalimschy
c4b71b7ba0
Details
...
Comments in 'onelua.c'
2023-03-09 11:12:11 -03:00
Roberto Ierusalimschy
1de2f31694
Corrected support for 16-bit systems
...
We still need access to a 16-bit system to correctly test
these changes.
2023-03-09 11:10:04 -03:00
Roberto Ierusalimschy
02bab9fc25
Bug: Wrong line in error message for arith. errors
...
It also causes 'L->top' to be wrong when the error happens,
triggering an 'assert'.
2023-02-08 14:15:41 -03:00
Roberto Ierusalimschy
5e08b41567
Simpler definition for LUA_STRFTIMEOPTIONS
...
There is no need for those intermediate definitions.
2023-02-07 10:48:39 -03:00
Roberto Ierusalimschy
cf08915d62
New macro LUA_USE_IOS
...
Do not try to detect automatically whether system is iOS; it is
simpler and more reliable to let the programmer inform that.
2023-02-02 13:43:41 -03:00
Roberto Ierusalimschy
c888ae0aea
Small changes in hash of pointers
...
When converting from pointer to integer, use 'uintptr_t' if available;
otherwise try 'uintmax_t', and use 'size_t' as last resource.
2023-02-02 13:37:11 -03:00
Roberto Ierusalimschy
d69789da1c
Fix absence of 'system' in iOS
...
Despite claiming to be ISO, the C library in some Apple platforms
does not implement 'system'.
2023-01-24 15:04:17 -03:00
Roberto Ierusalimschy
314745ed84
Avoid excessive name pollution in test files
...
Test files are more polite regarding the use of globals when locals
would do, and when globals are necessary deleting them after use.
2022-12-28 18:34:11 -03:00
Roberto Ierusalimschy
0825cf237d
Detail in make file for testes/libs
...
Everything depends on the Lua version (as given by 'lua.h')
2022-12-23 11:28:11 -03:00
Roberto Ierusalimschy
f874d37fa2
Small change in barrier macros
...
Reuse macros for objects when defining the macros for values.
2022-12-15 14:18:03 -03:00
Roberto Ierusalimschy
35e01ed21d
Small improvements in 'lmem.c'
...
Added some auxiliary macros + fixed a bug in compilation option
EMERGENCYGCTESTS. (It should not try to force an emergency collection
when it cannot run one.)
2022-12-15 10:44:55 -03:00
Roberto Ierusalimschy
6aabf4b15e
Details in some header files
...
Identifier LUA_NUMTAGS was deprecated (changed to LUA_NUMTYPES) +
better handling of some inclusion loops.
2022-12-14 16:20:39 -03:00
Roberto Ierusalimschy
fa2f294dd1
Reduce calls to 'luaC_step' when GC is stopped
2022-12-09 16:35:19 -03:00
Roberto Ierusalimschy
82fae58e25
Details
...
Parentheses and comments.
2022-12-02 11:33:09 -03:00
Roberto Ierusalimschy
9a77f57edc
Stop GC while building initial state
2022-11-23 14:17:28 -03:00
Roberto Ierusalimschy
be908a7d4d
Removed unused field 'UpVal.tbc'
2022-11-08 10:15:10 -03:00
Roberto Ierusalimschy
9ede317c70
Threads are created like other objects
...
Using a version of 'luaC_newobj' that allows offsets (extra space
before the object itself).
2022-11-01 17:14:01 -03:00
Roberto Ierusalimschy
ee645472eb
Stack reallocation done with a single realloc
...
To avoid the need of both the old and the new stack addresses valid
at the same time, to correct the pointers to the stack, these pointers
are changed to offsets before the reallocation and then changed back
to pointers after the reallocation.
2022-10-31 15:06:20 -03:00
Roberto Ierusalimschy
413a393e62
Stack indices changed to union's
...
That will allow to change pointers to offsets while reallocating
the stack.
2022-10-29 12:06:37 -03:00
Roberto Ierusalimschy
ba089bcb08
Details
...
Added comments in the makefile about other useful '-fsanitize' options.
2022-10-26 10:15:09 -03:00
Roberto Ierusalimschy
1e64c1391f
Bug: stack overflow with nesting of coroutine.close
2022-10-25 16:44:06 -03:00
Roberto Ierusalimschy
b85816b9a8
Removed test function 'luaH_isdummy'
...
It was not being used anywhere.
2022-10-21 09:18:13 -03:00
Roberto Ierusalimschy
c954db3924
Option '-l g=mod' added to the manual
...
Plus some other improvements in the manual.
2022-10-19 16:30:39 -03:00
Roberto Ierusalimschy
14d2803e55
Details
...
Some cast operations rewritten to use respective macros.
2022-10-19 16:29:54 -03:00
Roberto Ierusalimschy
7f12bf40c4
Portability issue in a test for 'string.format'
2022-10-19 16:20:11 -03:00
Roberto Ierusalimschy
26be27459b
Negation in constant folding of '>>' may overflow
2022-09-23 11:08:10 -03:00
Roberto Ierusalimschy
cfbe378f90
Small simplification in overflow check in 'getfield'
...
Subtracting a small non-negative int from a non-negative int cannot
overflow, and adding a non-negative int to INT_MIN cannot overflow.
2022-09-23 10:57:35 -03:00
Roberto Ierusalimschy
a1089b415a
Bug: 'utf8.codes' accepts spurious continuation bytes
2022-09-23 10:41:16 -03:00
Roberto Ierusalimschy
f8c4c4fcf2
New test for table rehash
2022-09-16 17:05:22 -03:00
Roberto Ierusalimschy
71bc69c2af
Note in the manual about using '...' as an expression
2022-09-08 17:21:02 -03:00
Roberto Ierusalimschy
cd56f222b7
Corrected error message in 'table.remove'
2022-09-07 12:21:46 -03:00
Roberto Ierusalimschy
69b77b6fde
Changed the growth rate of string buffers
...
The growth rate of string buffers was reduced from 2 to 1.5 (3/2).
As string buffers start larger (256~1024 bytes), they don't need to
grow that fast. Moreover, a lower rate allows multiplicative growth up
to larger sizes (3/2 of the maximum). (After that, the growth becomes
linear, which is mostly useless.)
2022-09-06 10:58:55 -03:00
Roberto Ierusalimschy
997f11f543
Bug: 'break' may not properly close variable in a 'for' loop
...
Function 'leaveblock' was generating "break" label before removing
variables from the closing block. If 'createlabel' created a 'close'
instruction (which it did when matching a goto/break that exited
the scope of an upvalue), that instruction would use the wrong level.
2022-08-24 17:36:47 -03:00
Roberto Ierusalimschy
02060b7a37
Simpler handling of Byte Order Mark (BOM)
2022-08-23 16:08:53 -03:00
Roberto Ierusalimschy
a1f77a234a
Bug: set correct pause when (re)entering gen. collection.
2022-08-23 16:06:23 -03:00
Roberto Ierusalimschy
c6cea857a4
Better documentation for 'multires' expressions
...
Manual has a new section explaining multires expressions, lists of
expressions, and adjustments. This commit also corrects some comments
in the code.
2022-08-19 14:10:18 -03:00
Roberto Ierusalimschy
d61b0c6028
More checks and documentation for uses of EXTRA_STACK
2022-05-26 15:14:54 -03:00
Roberto Ierusalimschy
196bb94d66
Bug: 'lua_settop' may use an invalid pointer to stack
2022-05-25 17:41:39 -03:00
Roberto Ierusalimschy
603b2c64ad
'luaV_concat' can use invalidated pointer to stack
...
Bug introduced in commit 42d40581 .
2022-05-23 17:50:47 -03:00
Roberto Ierusalimschy
4a00f61276
'lua_checkstack' doesn't need to check stack overflow
...
'luaD_growstack' already checks that. This commit also fixes an
internal bug in 'luaD_growstack': a large 'n' could cause an arithmetic
overflow when computing 'needed'.
2022-05-23 10:38:03 -03:00
Roberto Ierusalimschy
42d40581dd
Save stack space while handling errors
...
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.
This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error".
2022-05-20 13:14:33 -03:00
Roberto Ierusalimschy
e435aaabef
Details (identation and typos)
2022-05-10 11:13:39 -03:00
Roberto Ierusalimschy
315639d3bb
Factoring out common parts of 'codearith' and 'codebitwise'
2022-05-06 17:52:46 -03:00
Roberto Ierusalimschy
c764ca71a6
Bug: Wrong code generation in bitwise operations
2022-04-25 14:42:51 -03:00
Roberto Ierusalimschy
295cde9454
New release number (5.4.5)
2022-04-07 10:52:15 -03:00
Roberto Ierusalimschy
f3cfd5bf2b
Details
...
Comments + manual + identation + asserts about stack limits that were
not allowing the use of the full stack
2022-04-01 13:55:44 -03:00
Roberto Ierusalimschy
8426d9b4d4
Avoid computing invalid addresses
...
luaV_execute should compute 'ra' only when the instruction uses it.
Computing an illegal address is undefined behavior even if the address
is never dereferenced.
2022-02-18 13:22:25 -03:00
Roberto Ierusalimschy
1f3c6f4534
Bug: Lua can generate wrong code when _ENV is <const>
2022-02-15 12:28:46 -03:00
Roberto Ierusalimschy
25b143dd34
Bug: lua.c assumes that argv has at least one element
2022-02-07 10:16:35 -03:00
Roberto Ierusalimschy
5d708c3f9c
Explanation of borders in the manual
...
The explanation includes the limit case of maxinteger being a border.
It also avoids the term "natural", which might include large floats
with natural values.
2022-01-13 08:15:03 -03:00
Roberto Ierusalimschy
8dd2c912d2
Detail
...
Warnings with clang when using long double for Lua floats.
2022-01-03 09:12:17 -03:00
Roberto Ierusalimschy
05ac2409ee
New year (2022)
2022-01-02 07:11:08 -03:00
Roberto Ierusalimschy
597a53bbc6
Bug: finalizer calling exit can corrupt finalization order
...
'os.exit' can call lua_close again, separating new finalizers
created after all previous finalizers were already separated.
2021-12-22 09:00:52 -03:00
Roberto Ierusalimschy
86ec152433
Details
...
correction in macro for hard tests + type in comment
2021-12-21 07:39:25 -03:00
Roberto Ierusalimschy
cf613cdc6f
Bug: finalizers can be called with an invalid stack
...
The call to 'checkstackGC' can run finalizers, which will find an
inconsistent CallInfo, as 'ci' is half updated at the point of call.
2021-12-15 11:29:07 -03:00
Roberto Ierusalimschy
066e0f93c4
Fix debug information about finalizers
...
The flag CIST_FIN does not mark a finalizer, but the function that was
running when the finalizer was called. (So, the function did not call
the finalizer, but it looks that way in the stack.)
2021-12-14 12:50:05 -03:00
Roberto Ierusalimschy
0bfc572e51
Bug: GC is not reentrant
...
As the GC is not reentrant, finalizers should not be able to invoke it.
2021-12-13 10:41:17 -03:00
Roberto Ierusalimschy
1de95e97ef
Bug: Lua stack still active when closing a state
2021-12-10 10:53:54 -03:00
Roberto Ierusalimschy
ad3942adba
Main 'mainposition' replaced by 'mainpositionTV'
...
Handle values in table keys as the special cases they are, and not
the other way around.
2021-11-25 11:07:17 -03:00
Roberto Ierusalimschy
48835c76c8
Wrong assert in 'collectvalidlines'
2021-11-25 10:11:05 -03:00
Roberto Ierusalimschy
6b3e116d44
Corrected bug in 'luaD_tryfuncTM'
...
The pointer to the metamethod can be invalidated by a finalizer that
can run during a GC in 'checkstackGCp'. (This commit also fixes a
detail in the manual.) Bug introduced in commit 91673a8ec .
2021-11-16 14:35:06 -03:00
Roberto Ierusalimschy
e8deac5a41
Avoid OP_VARARGPREP for active lines
...
when building the table 'activelines' for a vararg function, this
first instruction does not make the first line active.
2021-11-10 15:07:14 -03:00
Roberto Ierusalimschy
bfbff3703e
Bug: Wrong status in coroutine during reset
...
When closing variables during 'coroutine.close' or 'lua_resetthread',
the status of a coroutine must be set to LUA_OK; a coroutine should
not run with any other status. (See assertion in 'lua_callk'.)
After the reset, the status should be kept as normal, as any error
was already reported.
2021-11-08 11:55:25 -03:00
Roberto Ierusalimschy
74d99057a5
Bug: C stack overflow with coroutines
...
'coroutine.resume' did not increment counter of C calls when
continuing execution after a protected error (that is,
while running 'precover').
2021-11-03 15:04:18 -03:00
Roberto Ierusalimschy
1fce5bea81
More uniform implementation for tail calls
...
'luaD_pretailcall' mimics 'luaD_precall', handling call metamethods
and calling C functions directly. That makes the code in the
interpreter loop simpler.
This commit also goes back to emulating the tail call in 'luaD_precall'
with a goto, as C compilers may not do proper tail calls and the C
stack can overflow much sooner than the Lua stack (which grows as the
metamethod is added to it).
2021-10-29 13:41:24 -03:00
Roberto Ierusalimschy
3699446aaf
Removed goto's in 'luaD_precall'
...
(plus a detail in lauxlib.h.)
2021-10-18 11:58:40 -03:00
Roberto Ierusalimschy
0e5071b5fb
Avoid taking the address of a 'TValue' field
...
That structure can be packed in the future.
2021-10-11 13:52:26 -03:00
Roberto Ierusalimschy
87a9573b2e
Documentation
...
Better explanation about the guaranties of multiple assignment in
the manual.
2021-10-11 13:49:13 -03:00
Roberto Ierusalimschy
deac067ed3
Avoid overflows when incrementing parameters in C
...
Any C function can receive maxinteger as an integer argument, and
therefore cannot increment it without some care (e.g., doing unsigned
arithmetic as the core does).
2021-09-22 13:10:39 -03:00
Roberto Ierusalimschy
2ff3471722
Using 'inline' in some functions
...
According to ISO C, "making a function an inline function suggests that
calls to the function be as fast as possible." (Not available in C89.)
2021-09-15 11:18:41 -03:00
Roberto Ierusalimschy
9db4bfed6b
Revamp of format validation in 'string.format'
...
When calling 'sprintf', not all conversion specifiers accept all
flags; some combinations are undefined behavior.
2021-09-03 13:14:56 -03:00
Roberto Ierusalimschy
91673a8ec0
'luaD_tryfuncTM' checks stack space by itself
2021-08-18 12:05:06 -03:00
Roberto Ierusalimschy
41871f1803
Undo simplification of tail calls (commit 901d760)
...
Not that simpler and slower.
2021-08-18 11:21:33 -03:00
Roberto Ierusalimschy
a393ac2554
Detail in 'testes/math.lua'
...
Added a print with the random seeds used in the tests of 'random'.
2021-08-18 10:46:18 -03:00
Roberto Ierusalimschy
65434b4d1b
Option '-l' can give a name for the global variable.
...
Sintax for this option now is '-l [globname=]modname'.
2021-08-16 13:57:19 -03:00
Roberto Ierusalimschy
59acd79c05
Added tests for string reuse by the scanner
2021-08-11 11:19:33 -03:00
Roberto Ierusalimschy
e2c07dcbf7
Improved documentation for 'lua_getinfo'
2021-08-11 11:18:10 -03:00
Roberto Ierusalimschy
439e45a2f6
Bug: luaL_tolstring may get confused with negative index
...
When object has a '__name' metafield, 'luaL_tolstring' used the
received index after pushing a string on the stack.
2021-07-22 13:48:43 -03:00
Roberto Ierusalimschy
62fb934427
Bug: Negation in 'luaV_shiftr' may overflow
...
Negation of an unchecked lua_Integer overflows with mininteger.
2021-07-22 13:44:53 -03:00
Roberto Ierusalimschy
8a32e0aa4a
Correction on documentation of string-buffer operations
...
All string-buffer operations can potentially change the stack in
unspecified ways; the push/pop documentation in the manual should
reflect that.
2021-07-21 11:33:58 -03:00
Roberto Ierusalimschy
dbdc74dc55
Simplification in the parameters of 'luaD_precall'
...
The parameters 'nresults' and 'delta1', in 'luaD_precall', were never
meaningful simultaneously. So, they were combined in a single parameter
'retdel'.
2021-06-30 12:53:21 -03:00
Roberto Ierusalimschy
6a0dace25a
Bug: 'local function' can assign to '<const>' variables
2021-06-20 15:36:36 -03:00
Roberto Ierusalimschy
04e19712a5
C functions can be tail called, too
...
A tail call to a C function can have the behavior of a "real" tail
call, reusing the stack frame of the caller.
2021-06-14 13:28:21 -03:00
Roberto Ierusalimschy
901d760093
Simpler implementation for tail calls
...
Tail calls handled by 'luaD_precall', like regular calls, to avoid
code duplication.
2021-06-11 13:41:07 -03:00
Roberto Ierusalimschy
c0ed74c1e1
Avoid the term "undefined behavior" in the manual
2021-06-09 13:24:49 -03:00
Roberto Ierusalimschy
fc6c74f100
'index2value' more robust
...
'index2value' accepts pseudo-indices also when called from a Lua
function, through a hook.
2021-05-24 16:48:43 -03:00
Roberto Ierusalimschy
1e6918d553
Details
...
- Removed unused (and trivial) definition LUA_UNSIGNEDBITS
- Alignment structure in pack/unpack moved to a narrower scope
2021-05-24 16:48:09 -03:00
Roberto Ierusalimschy
681297187e
Bug: yielding in '__close' mess up number of returns
...
Yielding in a __close metamethod called when returning vararg results
changes the top and so messes up the number of returned values.
2021-04-16 15:41:44 -03:00
Roberto Ierusalimschy
5148954eed
Align error messages for calling non-callable values
...
'pcall(foo)' message was "attempt to call a table value", while
'pcall(function () foo() end) message was "global 'foo' is not callable".
2021-04-12 16:50:34 -03:00
Roberto Ierusalimschy
d205f3a484
Bug: Lua source should not use C99 comments ("//")
2021-04-10 10:19:21 -03:00
Roberto Ierusalimschy
47cffdc723
Bug: tbc variables in "for" loops don't avoid tail calls
2021-04-07 14:59:26 -03:00
Roberto Ierusalimschy
36de01d988
Changes in cache for function constants
...
In 'lcode.c', when adding constants to the list of constants of a
function, integers represent themselves in the cache and floats
with integral values get a small delta to avoid collision with
integers. (This change avoids creating artificial addresses; the old
implementation converted integers to pointers to index the cache.)
2021-03-30 14:49:18 -03:00
Roberto Ierusalimschy
7fbe215808
New hash function for integer keys
...
When integer keys do not form a sequence, it is better to use all their
bits to compute their hashes. (The previous implementation was quite bad
for integer keys with common lower bits, and disastrous for integer keys
changing only in their upper 32 bits.)
2021-03-29 15:47:18 -03:00
Roberto Ierusalimschy
bf10593a3a
Allow yields inside '__pairs'
2021-03-29 12:57:32 -03:00
Roberto Ierusalimschy
bef250eb8d
Details
...
Comments and small improvements in the manual.
2021-03-29 11:47:12 -03:00
Roberto Ierusalimschy
ba81adaad9
Next release number (5.4.4)
2021-03-29 11:26:07 -03:00