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

Fix memory leak on snapshot loading. #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yossigo
Copy link
Contributor

@yossigo yossigo commented Oct 8, 2018

All nodes expect local should be removed when loading a snapshot, and
any prior knowledge about them should be void.

All nodes expect local should be removed when loading a snapshot, and
any prior knowledge about them should be void.
@willemt
Copy link
Owner

willemt commented Nov 17, 2018

I'm getting some AddressSanitizer errors on clang. I will need to look at this a little more.

==99515==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000006498 at pc 0x00010f85936a bp 0x7ffee03b9520 sp 0x7ffee03b9518
WRITE of size 8 at 0x603000006498 thread T0
    #0 0x10f859369 in raft_node_set_next_idx raft_node.c:68
    #1 0x10f87f259 in TestRaft_leader_sends_appendentries_when_node_next_index_was_compacted test_snapshotting.c:544
    #2 0x10f8844fd in CuTestRun CuTest.c:132
    #3 0x10f885b0e in CuSuiteRun CuTest.c:262
    #4 0x10f85b279 in RunAllTests main_test.c:331
    #5 0x7fff5fc5b014 in start (libdyld.dylib:x86_64+0x1014)

0x603000006498 is located 8 bytes inside of 32-byte region [0x603000006490,0x6030000064b0)
freed by thread T0 here:
    #0 0x10f963fdd in wrap_free (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x56fdd)
    #1 0x10f85394b in raft_begin_load_snapshot raft_server.c:1400
    #2 0x10f87f1e7 in TestRaft_leader_sends_appendentries_when_node_next_index_was_compacted test_snapshotting.c:539
    #3 0x10f8844fd in CuTestRun CuTest.c:132
    #4 0x10f885b0e in CuSuiteRun CuTest.c:262
    #5 0x10f85b279 in RunAllTests main_test.c:331
    #6 0x7fff5fc5b014 in start (libdyld.dylib:x86_64+0x1014)

previously allocated by thread T0 here:
    #0 0x10f964367 in wrap_calloc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x57367)
    #1 0x10f859136 in raft_node_new raft_node.c:42
    #2 0x10f8511e2 in raft_add_node_internal raft_server.c:973
    #3 0x10f87f009 in TestRaft_leader_sends_appendentries_when_node_next_index_was_compacted test_snapshotting.c:511
    #4 0x10f8844fd in CuTestRun CuTest.c:132
    #5 0x10f885b0e in CuSuiteRun CuTest.c:262
    #6 0x10f85b279 in RunAllTests main_test.c:331
    #7 0x7fff5fc5b014 in start (libdyld.dylib:x86_64+0x1014)

@yossigo
Copy link
Contributor Author

yossigo commented Nov 18, 2018

@willemt missed that one, a problem with the test that violates proper usage (not re-configuring nodes after snapshot loading).

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.

2 participants