[email protected] - Resolves memory overflow warnings#20474
Open
cabelo wants to merge 2 commits intoggml-org:masterfrom
Open
[email protected] - Resolves memory overflow warnings#20474cabelo wants to merge 2 commits intoggml-org:masterfrom
cabelo wants to merge 2 commits intoggml-org:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make sure to read the contributing guidelines before submitting a PR
fix(repack): resolves memory overflow warnings and declaration error in make_block_*
Fixes multiple
warning: writing 32 bytes into a region of size 0 [-Wstringop-overflow=]in
make_block_q4_0x4,make_block_q4_0x8, etc., caused by the use ofmemcpyindynamically calculated offsets, which confuses static analysis in GCC 13+.
Adds explicit bounds checking (
if+GGML_ASSERT) before eachmemcpy,ensuring that
src_offsetanddst_offsetdo not exceed the sizes of the arrays(
qs[]) within the blocks.Replaces
memcpydirectly withstd::memcpy(C++) to avoid aliasing problems andimprove compatibility with compiler optimizations. - Adds
static_assertto validate block sizes (block_q4_0x4::qs == 64,block_q4_Kx8::qs == 1024, etc.), preventing future errors ifQK_*changes.Fixes compilation error
make_block_q4_0x4 was not declared in this scopeby declaring all auxiliary functionsmake_block_*asstaticat the top of therepack.cppfile, beforeextern "C", following good C++ practices (internal binding).No changes to algorithm logic — only memory safety and compatibility with modern compilers (GCC ≥13, Clang ≥14).
Before:
After