KPM: new[]/delete mismatch in vision::Image and leaked imageInfo in kpmDeleteHandle
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- computer-vision
Research direction
Start with the allocation in vision::Image::alloc (lib/SRC/KPM/FreakMatcher/framework/image.cpp, around line 149) and the destructor around line 118, which the shared_ptr deleter uses. Then read kpmDeleteHandle in lib/SRC/KPM/kpmHandle.cpp (lines 245-246) and kpmSetRefDataSet in lib/SRC/KPM/kpmMatching.cpp (line 243) to see how per-page imageInfo is freed on replacement. Done when an ASan build of webarkit_nft_core_test reports no alloc-dealloc-mismatch or leaks from these sites.
Written by the indexing model from the issue text.
Description
Description
AddressSanitizer runs of the NFT core tests (webarkit/jsartoolkitNFT#683, webarkit_nft_core_test, 49 tests passing) found two pre-existing problems in the vendored KPM code. Neither is in the new core.
1. Allocation/deallocation mismatch in vision::Image
vision::Image::alloc (lib/SRC/KPM/FreakMatcher/framework/image.cpp:149) allocates with new unsigned char[...], and the buffer is owned by a std::shared_ptr<unsigned char> with the default deleter, which calls delete (not delete[]) in vision::Image::~Image (image.cpp:118). ASan aborts on alloc-dealloc-mismatch (operator new [] vs operator delete) in the first KPM test.
Fix: give the shared_ptr an array deleter (std::default_delete<unsigned char[]>()), or use std::shared_ptr<unsigned char[]> where the standard allows.
2. Leaked per-page imageInfo in kpmDeleteHandle
With ASAN_OPTIONS=alloc_dealloc_mismatch=0, LeakSanitizer reports 6732 bytes in 54 allocations. All 40 leak reports are allocated in kpmSetRefDataSet (lib/SRC/KPM/kpmMatching.cpp:243), which allocates each page's imageInfo array. kpmDeleteHandle (kpmHandle.cpp:245-246) frees pageInfo but not the per-page imageInfo; only a later kpmSetRefDataSet frees them when it replaces a set.
Fix: in kpmDeleteHandle, free each pageInfo[i].imageInfo before freeing pageInfo, mirroring what kpmSetRefDataSet does on replacement.
Notes
With these (and the thread_sub.c mutex issue), sanitizer runs exit non-zero even when the code under test is clean, so a sanitizer CI job would need suppressions until they are fixed.
- Dominant language
- C++
- Stars
- 21
- Forks
- 8
- Avg merge
- 7h 30m
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from webarkit/WebARKitLib
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
webarkit/WebARKitLib#101 ·
Maintainers usually reply within 1 day
-
Sync workflow: handle a conflicting sync branch with no open PR, and PRs the workflow did not openOpenCI enhancement
Difficulty 3/5 Half a day Newbie friendliness 45/100
webarkit/WebARKitLib#92 ·
Maintainers usually reply within 1 day
-
Optical tracker: frames without a marker run detection twice since the #53 full-resolution retryOpenC/C++ code enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
webarkit/WebARKitLib#91 ·
Maintainers usually reply within 1 day
-
C/C++ code enhancement
Difficulty 4/5 3-5 days Newbie friendliness 25/100
webarkit/WebARKitLib#87 ·
Maintainers usually reply within 1 day
-
Real-world pose scale from a physical marker width at init (ArtoolkitX-style), not the _pattern.size/2 pixel centre offsetMay be free again @kalwalt claimed this 104 days ago, and no pull request is open. Openenhancement question
webarkit/WebARKitLib#62 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in webarkit/WebARKitLib
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nasa/fprime#6225 · 1 comment ·
Maintainers usually reply within 1 day
-
content good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
cpinitiative/usaco-guide#6699 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
codepointerapp/codepointer#231 ·
-
enhancement source/qq
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
metasequoiaime/msime-windows#1054 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
amnezia-vpn/amnezia-client#3297 · 1 comment ·
Maintainers usually reply within 1 day