-
Notifications
You must be signed in to change notification settings - Fork 616
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 (libzkp): free Rust CString by from_raw
#998
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #998 +/- ##
========================================
Coverage 48.13% 48.14%
========================================
Files 100 100
Lines 10591 10591
========================================
+ Hits 5098 5099 +1
+ Misses 5071 5070 -1
Partials 422 422
Flags with carried forward coverage won't be shown. Click here to find out more. |
822fdc6
to
0da926f
Compare
btw do you need to fix this in l2geth ccc? |
d380e1e
to
1fd5038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
from_raw
from_raw
if cfg.ProofType == message.ProofTypeBatch { | ||
C.init_batch_prover(paramsPathStr, assetsPathStr) | ||
rawVK = C.get_batch_vk() | ||
} else if cfg.ProofType == message.ProofTypeChunk { | ||
C.init_chunk_prover(paramsPathStr, assetsPathStr) | ||
rawVK = C.get_chunk_vk() | ||
} | ||
defer C.free_c_chars(rawVK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rawVK is newed in go code, so it should be released in defer C.free(unsafe.Pointer(rawVK))
?
Purpose or design rationale of this PR
Proof results and VKs are returned by vec_to_c_char or string_to_c_char as
*const c_char
which calls CString::into_raw, reference its doc, the C ptr must be freed byCString::from_raw
(memory leak otherwise).free_c_chars
.Test
The memory available could restore (
983 -> 983
) when running a loop (50 chunks from yesterday to morning of today).The chunk-prover and batch-prover are created for each run of loop.
PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
Deployment tag versioning
Has
tag
incommon/version.go
been updated or have you addedbump-version
label to this PR?Breaking change label
Does this PR have the
breaking-change
label?