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

ignore: testing signatures in github #57

Closed
wants to merge 55 commits into from
Closed

Conversation

dnut
Copy link
Contributor

@dnut dnut commented Dec 13, 2023

No description provided.

0xNineteen and others added 25 commits October 5, 2023 18:09
the problem was that it would deinit the node before returning node data. this almost always worked fine because you would need the allocator to reuse or unmap the memory to actually see a problem, and this was typically not happening before the return statement on the next line of code was executed. but on rare occasion the address would be unmapped, causing a segfault.

the solution is to defer the deinit so it happens after the return statement copies the value
All enums are deserialized with the assumption they have a size of 32 bits in bincode. ShredType however is a struct in rust and enum in zig. It is serialized as 8 bits. This causes deserialization errors reading the data from mainnet because it grabs 32 bits and reads a much larger number than any of the enum variants in zig.

Add logic to bincode implementation that looks for a declaration called BincodeSize within the enum. If it exists, use that instead of u32. Set it to u8 for ShredType.
# Root cause
Multiple contacts with the same pubkey were being passed to the rotate method. This resulted in duplicate items being included in the array, but the hashmap internally prevents there from being duplicates. So the next time rotate is called, it would iterate through the array and attempt to deinit the same hashmap entry twice.

# Solution
Duplicates are detected and skipped during the insertion loop by checking for their presence in the hashmap.

# Alternate Solution
This could have also been addressed with a simpler approach: Remove the peers field from ActiveSet. This field does not seem necessary, since the same data is already in the hashmap.

Even though it would be simpler code, it is a more significant change in behavior and compatibility. To be safe, I decided not to take this approach.
this is the alternate solution for the double free bug fix.
- remove comment
- use HashMap.count for ActiveSet.len
- use getOrPut to avoid repeated lookups in ActiveSet.rotate
@dnut dnut closed this Dec 13, 2023
@0xNineteen 0xNineteen deleted the dnut/gossip-sign-fix branch December 22, 2023 17:57
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