Skip to content

Fix memory allocate during request processing #54

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

Merged
merged 3 commits into from
Jun 1, 2020

Conversation

LeonidVas
Copy link
Collaborator

@LeonidVas LeonidVas commented May 13, 2020

Before introducing a txn memory region box_txn_alloc() allocates memory using the fiber.gc region and can be used without box_txn_begin(). Now the similar trick doesn't work (a transaction must be started).
To allocate memory on region without start a transaction, the region was added to struct memcached_connection.

Fixes #53

@LeonidVas LeonidVas linked an issue May 13, 2020 that may be closed by this pull request
@LeonidVas LeonidVas requested a review from Totktonada May 13, 2020 09:09
LeonidVas added 3 commits May 14, 2020 16:22
The tarantool modules tests shouldn't compare box.stat()
output because it can include different numbers of fields
in different versions of tarantool.
Before introducing a txn memory region box_txn_alloc()
allocates memory using the fiber.gc region and can be
used without box_txn_begin(). Now the similar trick
doesn't work (a transaction must be started).
To allocate memory on region without start a transaction,
the region was added to struct memcached_connection.

Fixes #53
@LeonidVas LeonidVas force-pushed the lvasilev/gh-53-fix-memory-allocate branch from 6591b28 to 954c0af Compare May 14, 2020 13:23
Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Totktonada
Copy link
Member

Got segfault on both master and this patchset on tarantool 2.5.0-62-gbb7c3d167 (debug) when run tests (cd test && ./test-run.py).

#0  0x00007f3f837665f1 in raise () from /lib64/libc.so.6
#1  0x00007f3f8375053b in abort () from /lib64/libc.so.6
#2  0x000056508e4b15b7 in sig_fatal_cb (signo=11, siginfo=0x7f3f6cb7f3f0, context=0x7f3f6cb7f2c0) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/main.cc:301
#3  <signal handler called>
#4  0x00007f3f84767eab in slab_from_ptr (ptr=0x7f3f810300a0, slab_mask=0) at /home/alex/p/tarantool-meta/memcached/third_party/small/small/slab_cache.h:203
#5  0x00007f3f847680ce in mempool_free (pool=0x56508feebb50, ptr=0x7f3f810300a0) at /home/alex/p/tarantool-meta/memcached/third_party/small/small/mempool.h:274
#6  0x00007f3f84768416 in iobuf_delete (ibuf=0x7f3f810300a0, obuf=0x7f3f81040480) at /home/alex/p/tarantool-meta/memcached/memcached/internal/network.c:69
#7  0x00007f3f8476acf8 in memcached_handler (p=0x56508feec040, fd=22) at /home/alex/p/tarantool-meta/memcached/memcached/internal/memcached.c:258
#8  0x000056508e675c6b in lj_vm_ffi_call () at buildvm_x86.dasc:2578
#9  0x000056508e69bfe9 in lj_ccall_func (L=L@entry=0x4149e370, cd=<optimized out>) at lj_ccall.c:1150
#10 0x000056508e6716c8 in lj_cf_ffi_meta___call (L=0x4149e370) at lib_ffi.c:230
#11 0x000056508e673cbb in lj_BC_FUNCC () at buildvm_x86.dasc:809
#12 0x000056508e650a56 in lua_pcall (L=0x4149e370, nargs=<optimized out>, nresults=-1, errfunc=<optimized out>) at lj_api.c:1158
#13 0x000056508e5e4822 in luaT_call (L=0x4149e370, nargs=3, nreturns=-1) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lua/utils.c:1053
#14 0x000056508e5dd150 in lua_fiber_run_f (ap=0x7f3f81001470) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lua/fiber.c:443
#15 0x000056508e4b0e69 in fiber_cxx_invoke(fiber_func, typedef __va_list_tag __va_list_tag *) (f=0x56508e5dd0dc <lua_fiber_run_f>, ap=0x7f3f81001470)
    at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lib/core/fiber.h:782
#16 0x000056508e606a71 in fiber_loop (data=0x0) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lib/core/fiber.c:869
#17 0x000056508e7493b4 in coro_init () at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/third_party/coro/coro.c:110

Don't sure, how it is related to the problem you solve here. My intention was to get some 'problem solved' criteria: say, run tests om memcached from master branch against recent tarantool, get fail and then run your branch and get (full or partial) success.

It would be glad, if you'll glance on this segfault.

@LeonidVas
Copy link
Collaborator Author

Got segfault on both master and this patchset on tarantool 2.5.0-62-gbb7c3d167 (debug) when run tests (cd test && ./test-run.py).

#0  0x00007f3f837665f1 in raise () from /lib64/libc.so.6
#1  0x00007f3f8375053b in abort () from /lib64/libc.so.6
#2  0x000056508e4b15b7 in sig_fatal_cb (signo=11, siginfo=0x7f3f6cb7f3f0, context=0x7f3f6cb7f2c0) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/main.cc:301
#3  <signal handler called>
#4  0x00007f3f84767eab in slab_from_ptr (ptr=0x7f3f810300a0, slab_mask=0) at /home/alex/p/tarantool-meta/memcached/third_party/small/small/slab_cache.h:203
#5  0x00007f3f847680ce in mempool_free (pool=0x56508feebb50, ptr=0x7f3f810300a0) at /home/alex/p/tarantool-meta/memcached/third_party/small/small/mempool.h:274
#6  0x00007f3f84768416 in iobuf_delete (ibuf=0x7f3f810300a0, obuf=0x7f3f81040480) at /home/alex/p/tarantool-meta/memcached/memcached/internal/network.c:69
#7  0x00007f3f8476acf8 in memcached_handler (p=0x56508feec040, fd=22) at /home/alex/p/tarantool-meta/memcached/memcached/internal/memcached.c:258
#8  0x000056508e675c6b in lj_vm_ffi_call () at buildvm_x86.dasc:2578
#9  0x000056508e69bfe9 in lj_ccall_func (L=L@entry=0x4149e370, cd=<optimized out>) at lj_ccall.c:1150
#10 0x000056508e6716c8 in lj_cf_ffi_meta___call (L=0x4149e370) at lib_ffi.c:230
#11 0x000056508e673cbb in lj_BC_FUNCC () at buildvm_x86.dasc:809
#12 0x000056508e650a56 in lua_pcall (L=0x4149e370, nargs=<optimized out>, nresults=-1, errfunc=<optimized out>) at lj_api.c:1158
#13 0x000056508e5e4822 in luaT_call (L=0x4149e370, nargs=3, nreturns=-1) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lua/utils.c:1053
#14 0x000056508e5dd150 in lua_fiber_run_f (ap=0x7f3f81001470) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lua/fiber.c:443
#15 0x000056508e4b0e69 in fiber_cxx_invoke(fiber_func, typedef __va_list_tag __va_list_tag *) (f=0x56508e5dd0dc <lua_fiber_run_f>, ap=0x7f3f81001470)
    at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lib/core/fiber.h:782
#16 0x000056508e606a71 in fiber_loop (data=0x0) at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/src/lib/core/fiber.c:869
#17 0x000056508e7493b4 in coro_init () at /usr/src/debug/dev-db/tarantool-9999/tarantool-9999/third_party/coro/coro.c:110

Don't sure, how it is related to the problem you solve here. My intention was to get some 'problem solved' criteria: say, run tests om memcached from master branch against recent tarantool, get fail and then run your branch and get (full or partial) success.

It would be glad, if you'll glance on this segfault.

D'oh! I tested it only with a release build. But this is a different bug (see #59)

@Totktonada
Copy link
Member

Run the existing test suites on master (+small update) and on this branch (+small update). The tests don't pass on master and pass on the branch, so now I verified that the problem is actually fixed.

@Totktonada Totktonada merged commit 8401d47 into master Jun 1, 2020
@Totktonada Totktonada deleted the lvasilev/gh-53-fix-memory-allocate branch June 1, 2020 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ER_NO_TRANSACTION on tarantool-2.2+
2 participants