Skip to content

Fix memory leaks reported by ASAN (with suppressions turned off) part 2#10491

Merged
locker merged 5 commits intotarantool:masterfrom
nshy:fix-memleaks-p2
Aug 30, 2024
Merged

Fix memory leaks reported by ASAN (with suppressions turned off) part 2#10491
locker merged 5 commits intotarantool:masterfrom
nshy:fix-memleaks-p2

Conversation

@nshy
Copy link
Contributor

@nshy nshy commented Aug 29, 2024

Part of #10211

Factored out from all-in-one PR #10207

Closes #10484
Closes #10485
Closes #10487
Closes #10489
Closes #10490

@nshy nshy requested a review from a team as a code owner August 29, 2024 12:43
@nshy nshy requested a review from locker August 29, 2024 12:59
@coveralls
Copy link

coveralls commented Aug 29, 2024

Coverage Status

coverage: 87.213% (-0.009%) from 87.222%
when pulling 8512c08 on nshy:fix-memleaks-p2
into 49e459e
on tarantool:master
.

@locker locker assigned nshy and unassigned locker Aug 30, 2024
@nshy nshy force-pushed the fix-memleaks-p2 branch from b652866 to 7718166 Compare August 30, 2024 10:33
@nshy nshy assigned locker and unassigned nshy Aug 30, 2024
@locker locker assigned nshy and unassigned locker Aug 30, 2024
nshy added 5 commits August 30, 2024 13:50
Besides mentioned tarantool#10484 we fix another memleak
(filter_temporary_ddl_stmt() error path) that introduced by the same
commit 96a5224 ("box: factor out new_tuple def construction").

Closes tarantool#10484
Part-of tarantool#10211

NO_TEST=covered by existing tests
NO_DOC=bugfix
Besides mentioned tarantool#10485 we also fix a similar memleak (updating user)
that introduced by the same commit 5b32bb7 ("alter: Refactor
access_check outside constructors").

Closes tarantool#10485
Part-of tarantool#10211

NO_TEST=covered by existing tests
NO_DOC=bugfix
The issue is we increment `page_count` only on page write. If we fail
for some reason before then page info `min_key` in leaked.

LSAN report for 'vinyl/recovery_quota.test.lua':

```
2024-07-05 13:30:34.605 [478603] main/103/on_shutdown vy_scheduler.c:1668 E> 512/0: failed to compact range (-inf..inf)

=================================================================
==478603==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x5e4ebafcae09 in malloc (/home/shiny/dev/tarantool/build-asan-debug/src/tarantool+0x1244e09) (BuildId: 20c5933d67a3831c4f43f6860379d58d35b81974)
    tarantool#1 0x5e4ebb3f9b69 in vy_key_dup /home/shiny/dev/tarantool/src/box/vy_stmt.c:308:14
    tarantool#2 0x5e4ebb49b615 in vy_page_info_create /home/shiny/dev/tarantool/src/box/vy_run.c:257:23
    tarantool#3 0x5e4ebb48f59f in vy_run_writer_start_page /home/shiny/dev/tarantool/src/box/vy_run.c:2196:6
    tarantool#4 0x5e4ebb48c6b6 in vy_run_writer_append_stmt /home/shiny/dev/tarantool/src/box/vy_run.c:2287:6
    tarantool#5 0x5e4ebb72877f in vy_task_write_run /home/shiny/dev/tarantool/src/box/vy_scheduler.c:1132:8
    tarantool#6 0x5e4ebb73305e in vy_task_compaction_execute /home/shiny/dev/tarantool/src/box/vy_scheduler.c:1485:9
    tarantool#7 0x5e4ebb73e152 in vy_task_f /home/shiny/dev/tarantool/src/box/vy_scheduler.c:1795:6
    tarantool#8 0x5e4ebb01e0b1 in fiber_cxx_invoke(int (*)(__va_list_tag*), __va_list_tag*) /home/shiny/dev/tarantool/src/lib/core/fiber.h:1331:10
    tarantool#9 0x5e4ebc389ee0 in fiber_loop /home/shiny/dev/tarantool/src/lib/core/fiber.c:1182:18
    tarantool#10 0x5e4ebd3e9595 in coro_init /home/shiny/dev/tarantool/third_party/coro/coro.c:108:3

SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
```

Closes tarantool#10489
Part-of tarantool#10211

NO_TEST=covered by existing tests
NO_DOC=bugfix
`ffi.C.tnt_iconv_open` returns pointer to `struct iconv`. In this case
`__gc` in metatable is not bound to the object.

Closes tarantool#10487
Part-of tarantool#10211

NO_TEST=covered by existing tests
NO_DOC=bugfix
When replica is deleted from cluster it receives the deletion statement
and then connection to master is closed by master. Since the commit
25aac11 ("box: apply deletion of replica from `_cluster` on the
deleted replica") we kill applier to master on the deletion. Thus the
exit message produced due to EOF on connection to master is never
executed. This message in next in queue after the deletion statement.
As a result the exit message diag with SocketError from applier thread
is not freed.

Closes tarantool#10490
Part-of tarantool#10211

NO_TEST=covered by existing tests
NO_DOC=bugfix
@nshy nshy force-pushed the fix-memleaks-p2 branch from 7718166 to 8512c08 Compare August 30, 2024 10:51
@nshy nshy added the full-ci Enables all tests for a pull request label Aug 30, 2024
@nshy nshy assigned locker and unassigned nshy Aug 30, 2024
@locker locker merged commit 6f0e194 into tarantool:master Aug 30, 2024
@locker
Copy link
Member

locker commented Aug 30, 2024

Cherry-picked to 2.11 and 3.2.

@nshy nshy deleted the fix-memleaks-p2 branch August 30, 2024 13:58
@nshy nshy mentioned this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

4 participants