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

PANIC: unprotected error in call to Lua API (not enough memory) on select from large space #562

Closed
anei opened this issue Oct 7, 2014 · 12 comments · Fixed by #9179
Closed
Assignees
Labels
3.0 Target is 3.0 and all newer release/master branches bug Something isn't working crash lua luajit

Comments

@anei
Copy link

anei commented Oct 7, 2014

Tarantool crashes on select from a large space:

In interactive mode run:

box.cfg{slab_alloc_arena = 4.0}                                                  
s = box.schema.space.create('t')                                             
s:create_index('ind', {parts = {1, 'num'}})                                                                                                               
i = 0
console = require('console')
console.delimiter('!')                                                             
while i < 50000000 do                                                            
    s:auto_increment{i}                                                          
    i = i + 1                                                                    
end!

#s:select{}

(I used hash to suppress output if Tarantool will not crash)
I got:

tarantool> #s:select{}
PANIC: unprotected error in call to Lua API (not enough memory)
2014-10-07 17:49:09.258 [59753] main/101/spawner I> Exiting: master shutdown

After restart I got same error, but Tarantool did'nt shutdown, it just stopped to react.

tarantool: version 1.6.3-341-gf82473f

@kostja
Copy link
Contributor

kostja commented Oct 7, 2014

Thank you for a bug report.

@kostja kostja added this to the 1.6.4 milestone Oct 7, 2014
@kostja kostja added crash bug Something isn't working labels Oct 7, 2014
@rtsisyk
Copy link
Contributor

rtsisyk commented Oct 9, 2014

1.6.3-487-gf4722a6

box.cfg{slab_alloc_arena = 0.2, wal_mode = 'none'}
...

2014-10-09 15:44:02.554 [26075] main/101/interactive small.h:281 E> ER_MEMORY_ISSUE: Failed to allocate 23 bytes in slab allocator for tuple
---
- error: Failed to allocate 23 bytes in slab allocator for tuple
...

tarantool> #s:select{}!
---
- 3401079
...

Probably you have broken build.
Did you use our official build from tarantool.org/dist/?

@anei
Copy link
Author

anei commented Oct 9, 2014

Tarantool was installed from official debian repository (http://tarantool.org/dist/master/debian/ wheezy/main)

Try to set larger value for slab_alloc_arena, 4.0 will be fine.

@alyapunov
Copy link
Contributor

It seems to be a luajit problem. Luajit crashes when someone creates a table with big amount of cdata objects with finalizers, tarantool tuples as an example.
We've delivered the problem to luajit team, and one day it'll be fixed.
http://www.freelists.org/post/luajit/PANIC-in-lj-cdata-setfin-on-out-of-memory
http://www.freelists.org/post/luajit/PANIC-in-lj-cdata-setfin-on-out-of-memory,1
Now we can only suggest avoiding huge (>10^5) tables with tuples. And I also think that huge tables with tuples is always a bad idea despite of this issue is solved or not.

@kostja kostja reopened this Oct 29, 2014
@kostja
Copy link
Contributor

kostja commented Oct 29, 2014

Please add expect-fail test case to our test suite.

@kostja kostja modified the milestones: 1.6.5, 1.6.4 Nov 24, 2014
@kostja kostja closed this as completed in 2ea3b40 Feb 9, 2015
@nabihach
Copy link

nabihach commented Sep 4, 2016

One way to fix this is to install torch with Lua 5.2 instead of LuaJIT, as described here: http://torch.ch/docs/getting-started.html#_

@kostja kostja reopened this Mar 24, 2018
@kostja kostja modified the milestones: 1.6.5, 1.10.1 Mar 24, 2018
@unera
Copy link
Collaborator

unera commented Mar 24, 2018

#0  0x4e68c9 in print_backtrace+9
#1  0x4ceb29 in tarantool_panic_handler+29
#2  0x500823 in lj_err_throw+73
#3  0x500a1b in lj_err_mem+3b
#4  0x500478 in lj_mem_realloc+48
#5  0x502d35 in lj_tab_resize+f5
#6  0x5030ad in rehashtab+1ad
#7  0x4fff5d in gc_onestep+59d
#8  0x500134 in lj_gc_step+54
#9  0x50d368 in lua_pushcclosure+e8
#10 0x4c0b63 in box_lua_call+43
#11 0x4bf249 in box_process_call+129
#12 0x410b42 in _ZL15tx_process_callP4cmsg+d2
#13 0x4e8194 in cmsg_deliver+14
#14 0x4e8d19 in fiber_pool_f+c9
#15 0x40e73c in _ZL16fiber_cxx_invokePFiP13__va_list_tagES0_+c
#16 0x4e3630 in fiber_loop+30
#17 0x613f3f in coro_init+3f
#18 (nil) in +3f
2018-03-24 06:08:56.351 [24160] main/134492/main C> not enough memory
  • I don't select more than 150 tuples per select
  • I don't use iproto select/insert/etc, only iproto lua call
  • The application doesn't use any fibers.
  • database size - 26 Mb, arena 6Gb, Host RAM - 10Gb

tuple example:

---
- - [1, '7637666', 'da4cebb246c8fe108ca0ff12c5a52a06', 1521021450, 37.657672, 55.823722,
    'cancelled_user']
  - [2, '7640375', 'ed5b3a4784628a6e5bde1479676db882', 1521021444, 37.523618, 55.773072,
    'cancelled_user']
...

before dead situation (box.runtime):

@kyukhin kyukhin removed this from the wishlist milestone Jun 24, 2022
@igormunkin igormunkin added 1.10 Target is 1.10 and all newer release/master branches and removed teamL labels Sep 15, 2022
@igormunkin igormunkin added 3.0 Target is 3.0 and all newer release/master branches and removed 1.10 Target is 1.10 and all newer release/master branches labels May 25, 2023
@igormunkin
Copy link
Collaborator

Should be finally fixed when LuaJIT/LuaJIT@d5bbf9c is backported.

@rtsisyk
Copy link
Contributor

rtsisyk commented Aug 31, 2023

Wow, it's been a while. Thanks for fixing.

mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 5, 2023
Thanks to Maxim Kokryashkin. LuaJIT#1034

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Resolves tarantool/tarantool#8652
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 5, 2023
Thanks to Maxim Kokryashkin. LuaJIT#1034

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 5, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 5, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 5, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin added a commit to mkokryashkin/tarantool that referenced this issue Sep 5, 2023
Fix frame for on-trace out-of-memory error.
Fix frame for more types of on-trace error messages.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT bump
NO_TEST=LuaJIT bump
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 8, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 8, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 11, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with frame, as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin added a commit to mkokryashkin/tarantool that referenced this issue Sep 11, 2023
Fix frame for on-trace out-of-memory error.
Fix frame for more types of on-trace error messages.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT bump
NO_TEST=LuaJIT bump
mkokryashkin pushed a commit to tarantool/luajit that referenced this issue Sep 11, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with the frame as the previous
one, but now for the table overflow error in the `err_msgv`
function. The test for the problem uses the table of GC
finalizers, although they are not required to reproduce the
issue. They are only used to make the test as simple as possible.

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825
mkokryashkin added a commit to mkokryashkin/tarantool that referenced this issue Sep 11, 2023
Fix frame for on-trace out-of-memory error.
Fix frame for more types of on-trace error messages.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT bump
NO_TEST=LuaJIT bump
igormunkin pushed a commit to tarantool/luajit that referenced this issue Sep 25, 2023
Thanks to Maxim Kokryashkin.

(cherry-picked from commit d5bbf9c)

This patch fixes the same issue with the frame as the previous one, but
now for the table overflow error in the `err_msgv` function. The test
for the problem uses the table of GC finalizers, although they are not
required to reproduce the issue. They are only used to make the test as
simple as possible.

Maxim Kokryashkin:
* added the description and the test for the problem

Resolves tarantool/tarantool#562
Part of tarantool/tarantool#8825

Reviewed-by: Sergey Bronnikov <sergeyb@tarantool.org>
Reviewed-by: Sergey Kaplun <skaplun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
igormunkin added a commit to igormunkin/tarantool that referenced this issue Sep 26, 2023
* Handle table unsinking in the presence of IRFL_TAB_NOMM.
* Fix handling of instable types in TNEW/TDUP load forwarding.
* Fix frame for more types of on-trace error messages.
* Fix frame for on-trace out-of-memory error.
* Fix predict_next() in parser (again).
* Always exit after machine code page protection change fails.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT submodule bump
NO_TEST=LuaJIT submodule bump
igormunkin added a commit to igormunkin/tarantool that referenced this issue Sep 26, 2023
* test: fix fix-mips64-spare-side-exit-patching
* test: fix `fillmcode()` generator helper
* MIPS: Fix "bad FP FLOAD" assertion.
* Handle table unsinking in the presence of IRFL_TAB_NOMM.
* Fix handling of instable types in TNEW/TDUP load forwarding.
* Fix frame for more types of on-trace error messages.
* Fix frame for on-trace out-of-memory error.
* Fix predict_next() in parser (again).
* Always exit after machine code page protection change fails.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT submodule bump
NO_TEST=LuaJIT submodule bump
igormunkin added a commit to igormunkin/tarantool that referenced this issue Sep 27, 2023
* test: fix fix-mips64-spare-side-exit-patching
* test: fix `fillmcode()` generator helper
* MIPS: Fix "bad FP FLOAD" assertion.
* Handle table unsinking in the presence of IRFL_TAB_NOMM.
* Fix handling of instable types in TNEW/TDUP load forwarding.
* Fix frame for more types of on-trace error messages.
* Fix frame for on-trace out-of-memory error.
* Fix predict_next() in parser (again).
* Always exit after machine code page protection change fails.

Closes tarantool#562
Part of tarantool#8825

NO_DOC=LuaJIT submodule bump
NO_TEST=LuaJIT submodule bump
igormunkin added a commit that referenced this issue Sep 27, 2023
* test: fix fix-mips64-spare-side-exit-patching
* test: fix `fillmcode()` generator helper
* MIPS: Fix "bad FP FLOAD" assertion.
* Handle table unsinking in the presence of IRFL_TAB_NOMM.
* Fix handling of instable types in TNEW/TDUP load forwarding.
* Fix frame for more types of on-trace error messages.
* Fix frame for on-trace out-of-memory error.
* Fix predict_next() in parser (again).
* Always exit after machine code page protection change fails.

Closes #562
Part of #8825

NO_DOC=LuaJIT submodule bump
NO_TEST=LuaJIT submodule bump
@igormunkin
Copy link
Collaborator

The issue is finally resolved in scope of tarantool/luajit@7b98314 and submodule is bumped in scope of fcb41bb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 Target is 3.0 and all newer release/master branches bug Something isn't working crash lua luajit
Projects
None yet
Development

Successfully merging a pull request may close this issue.