Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport commit for fix recording of string.char() without arguments #6371

Closed
Buristan opened this issue Aug 20, 2021 · 1 comment
Closed
Assignees
Labels
bug Something isn't working crash luajit
Milestone

Comments

@Buristan
Copy link
Collaborator

Reproducer:

src/tarantool -e '
for i = 1, 100 do local s = string.char() end
'
tarantool: lj_record.c:137: rec_check_slots: Assertion `itype2irt(tv) == ((IRType)(((tr)>>24) & IRT_TYPE))' failed.
Aborted
'

The issue is fixed via commit LuaJIT/LuaJIT@dfa692b7 in the upstream.

@Buristan Buristan added crash bug Something isn't working luajit 1sp labels Aug 20, 2021
@Buristan Buristan added this to the 1.10.12 milestone Aug 20, 2021
@Buristan Buristan self-assigned this Aug 20, 2021
Buristan pushed a commit to tarantool/luajit that referenced this issue Aug 20, 2021
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. When JIT
machinery records the aforementioned call it doesn't handle case without
arguments. Each recording fast function expects 1 result by default.
Hence, when return from this call is recorded the framelink slot is used
as a result. It is loaded into the corresponding slot as an IR with
`IRT_NUM` type. It leads to assertion failure in `rec_check_slots()`,
when a next bytecode is recorded, because type of TV on the stack
(`LJ_STR`) isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference into the corresponding slot.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Buristan pushed a commit to tarantool/luajit that referenced this issue Aug 20, 2021
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. When JIT
machinery records the aforementioned call it doesn't handle this case.
Each recording fast function expects 1 result by default.  Hence, when
return from this call is recorded the framelink slot is used as a
result. It is loaded into the corresponding slot as an IR with `IRT_NUM`
type. It leads to assertion failure in `rec_check_slots()`, when a next
bytecode is recorded, because type of TValue on the stack (`LJ_STR`)
isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference into the corresponding slot.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Buristan pushed a commit to tarantool/luajit that referenced this issue Sep 1, 2021
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded the framelink slot (the top slot value) is considered as a
result to yield. It is loaded into the corresponding slot as an IR with
`IRT_NUM` type. It leads to assertion failure in `rec_check_slots()`,
when a next bytecode is recorded, because type of TValue on the stack
(`LJ_STR`) isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference into the corresponding slot. It reuses assumption
of one result by default, hence there is no case for `i == 1` in the
code.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
@kyukhin kyukhin modified the milestones: 1.10.12, 1.10.13 Dec 30, 2021
Buristan pushed a commit to tarantool/luajit that referenced this issue Jan 28, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded some garbarge value is considered as a result to yield. It
is loaded into the corresponding slot as an IR with `IRT_NUM` type. It
leads to assertion failure in `rec_check_slots()`, when a next bytecode
is recorded, because type of TValue on the stack (`LJ_STR`) isn't the
same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference into the corresponding slot. It reuses assumption
of one result by default, hence there is no case for `i == 1` in the
code.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Buristan pushed a commit to tarantool/luajit that referenced this issue Jan 28, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded some garbarge value is considered as a result to yield. It
is loaded into the corresponding slot as an IR with `IRT_NUM` type. It
leads to assertion failure in `rec_check_slots()`, when a next bytecode
is recorded, because type of TValue on the stack (`LJ_STR`) isn't the
same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference into the corresponding slot. It reuses assumption
of one result by default, hence there is no case for `i == 1` in the
code.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
igormunkin pushed a commit to tarantool/luajit that referenced this issue Jan 28, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded, some garbage value is considered as a result to be yielded.
It is loaded from the corresponding slot as an IR with `IRT_NUM` type.
It leads to assertion failure in `rec_check_slots()`, when a next
bytecode is recorded, because type of TValue on the stack (`LJ_STR`)
isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference as a result value.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Part of tarantool/tarantool#6548

Reviewed-by: Sergey Ostanevich <sergos@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
(cherry picked from commit f3e4906)
igormunkin pushed a commit to tarantool/luajit that referenced this issue Jan 28, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded, some garbage value is considered as a result to be yielded.
It is loaded from the corresponding slot as an IR with `IRT_NUM` type.
It leads to assertion failure in `rec_check_slots()`, when a next
bytecode is recorded, because type of TValue on the stack (`LJ_STR`)
isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference as a result value.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Part of tarantool/tarantool#6548

Reviewed-by: Sergey Ostanevich <sergos@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
(cherry picked from commit f3e4906)
igormunkin added a commit that referenced this issue Jan 29, 2022
* Actually implement maxirconst trace limit.
* Fix string.char() recording with no arguments.

Closes #6371
Part of #6548
igormunkin added a commit that referenced this issue Jan 29, 2022
* Actually implement maxirconst trace limit.
* Fix string.char() recording with no arguments.

Closes #6371
Part of #6548
igormunkin added a commit that referenced this issue Jan 29, 2022
* Actually implement maxirconst trace limit.
* Fix string.char() recording with no arguments.

Closes #6371
Part of #6548
@igormunkin
Copy link
Collaborator

The issue is resolved in scope of tarantool/luajit@f3e4906. The submodule was updated in tarantool in 2.10.0-beta2-68-g87461d5c7 (87461d5), 2.8.3-26-g5c7464403 (5c74644), 1.10.12-24-gb3982d4d0 (b3982d4).

yanshtunder pushed a commit that referenced this issue Feb 8, 2022
* Actually implement maxirconst trace limit.
* Fix string.char() recording with no arguments.

Closes #6371
Part of #6548
igormunkin pushed a commit to tarantool/luajit that referenced this issue Jun 16, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded, some garbage value is considered as a result to be yielded.
It is loaded from the corresponding slot as an IR with `IRT_NUM` type.
It leads to assertion failure in `rec_check_slots()`, when a next
bytecode is recorded, because type of TValue on the stack (`LJ_STR`)
isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference as a result value.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Part of tarantool/tarantool#6548

Reviewed-by: Sergey Ostanevich <sergos@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
igormunkin pushed a commit to tarantool/luajit that referenced this issue Jun 16, 2022
(cherry picked from commit dfa692b)

`string.char()` call without arguments yields an empty string. JIT
recording machinery doesn’t handle this case. Each recording of a fast
function expects 1 result by default. Hence, when return from this call
is recorded, some garbage value is considered as a result to be yielded.
It is loaded from the corresponding slot as an IR with `IRT_NUM` type.
It leads to assertion failure in `rec_check_slots()`, when a next
bytecode is recorded, because type of TValue on the stack (`LJ_STR`)
isn't the same as IR (and TRef) type.

This patch handles the case without arguments by the loading of IR with
empty string reference as a result value.

Sergey Kaplun:
* added the description and the test for the problem

Resolves tarantool/tarantool#6371
Part of tarantool/tarantool#6548

Reviewed-by: Sergey Ostanevich <sergos@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
@igormunkin igormunkin removed the teamL label Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash luajit
Projects
None yet
Development

No branches or pull requests

3 participants