-
Notifications
You must be signed in to change notification settings - Fork 451
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
ocr_bitmap can run out of buffer memory copying the "last font tag" #1586
base: master
Are you sure you want to change the base?
ocr_bitmap can run out of buffer memory copying the "last font tag" #1586
Conversation
…nto qualip-ocr_bitmap-last_font_tag
…nto qualip-ocr_bitmap-last_font_tag
Hi @cfsmp3, the only Rust formatting issue that's left and I don't know how to fix is:
Can you please enlighten me? |
You would need to use an unsafe block, because as the message error states, a race condition could arise.
I believe, though it depends on if the C code is single threaded, which I haven't checked. |
…nto qualip-ocr_bitmap-last_font_tag
@wylited, thanks for the tip. Unfortunately, it doesn't solve the warning: diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs
index 8b014cd1..597e14e4 100644
--- a/src/rust/src/lib.rs
+++ b/src/rust/src/lib.rs
@@ -282,7 +282,10 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch
tlt_config = _tlt_config.to_ctype(&opt);
// Convert the rust struct (CcxOptions) to C struct (ccx_s_options), so that it can be used by the C code
- ccx_options.copy_from_rust(opt);
+ // safety: the C code is single-threaded and opt is locally scoped, so accessing `ccx_options` and `opt` is safe.^M
+ unsafe {^M
+ ccx_options.copy_from_rust(opt);^M
+ }^M
if !_capitalization_list.is_empty() {
capitalization_list = _capitalization_list.to_ctype(); I did end up finding a solution which is to copy to a temporary ccx_options before assigning that copy to the static. See 6264d5b But, when I merged with latest master, someone already worked on fixing that issue by completely changing the C call to use a A couple more of my formatting fixes got lost in the merge. Oh well. (On second look, all of them :-( ) Please approve if this is up to code! |
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit d276fb1...:
All tests passing on the master branch were passed completely. NOTE: The following tests have been failing on the master branch as well as the PR:
Check the result page for more info. |
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 0912ac8...:
All tests passing on the master branch were passed completely. NOTE: The following tests have been failing on the master branch as well as the PR:
Congratulations: Merging this PR would fix the following tests:
Check the result page for more info. |
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Version: 0.94
During OCR of a VOB PS, ccextractor can run out of buffer space if it has to copy all text since the last font tag (which can also be the beginning of the input):
I believe the bug existed since that piece of code was introduced way back in 2017 (#844)
The fix simply makes sure the allocated buffer is big enough for this extra string.
Example crash under gdb:
Before actually reaching this point I also had to fix an ASAN error with process_spu using
memcpy
on overlapping buffers. I can't say I understand why the buffers would be overlapping but usingmemmove
at least fixes the error.