You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<
8000
script type="application/json" data-target="react-app.embeddedData">{"payload":{"commit":{"oid":"b3e184a5d4fdbc43d2cb99865ea2e073c09b9584","url":"/postgres/postgres/commit/b3e184a5d4fdbc43d2cb99865ea2e073c09b9584","authoredDate":"2023-02-21T18:47:46.000-05:00","committedDate":"2023-02-21T18:48:15.000-05:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eFix erroneous Valgrind markings in AllocSetRealloc.\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"If asked to decrease the size of a large (\u0026gt;8K) palloc chunk,\nAllocSetRealloc could improperly change the Valgrind state of memory\nbeyond the new end of the chunk: it would mark data UNDEFINED as far\nas the old end of the chunk after having done the realloc(3) call,\nthus tromping on the state of memory that no longer belongs to it.\nOne would normally expect that memory to now be marked NOACCESS,\nso that this mislabeling might prevent detection of later errors.\nIf realloc() had chosen to move the chunk someplace else (unlikely,\nbut well within its rights) we could also mismark perfectly-valid\nDEFINED data as UNDEFINED, causing false-positive valgrind reports\nlater. Also, any malloc bookkeeping data placed within this area\nmight now be wrongly marked, causing additional problems.\n\nFix by replacing relevant uses of \"oldsize\" with \"Min(size, oldsize)\".\nIt's sufficient to mark as far as \"size\" when that's smaller, because\nwhatever remains in the new chunk size will be marked NOACCESS below,\nand we expect realloc() to have taken care of marking the memory\nbeyond the new official end of the chunk.\n\nWhile we're here, also rename the function's \"oldsize\" variable\nto \"oldchksize\" to more clearly explain what it actually holds,\nnamely the distance to the end of the chunk (that is, requested size\nplus trailing padding). This is more consistent with the use of\n\"size\" and \"chksize\" to hold the new requested size and chunk size.\nAdd a new variable \"oldsize\" in the one stanza where we're actually\ntalking about the old requested size.\n\nOversight in commit \u003ca class=\"commit-link\" data-hovercard-type=\"commit\" data-hovercard-url=\"https://github.com/postgres/postgres/commit/c477f3e449d1a7322c2453e9cd9d6b710ae91577/hovercard\" href=\"https://github.com/postgres/postgres/commit/c477f3e449d1a7322c2453e9cd9d6b710ae91577\"\u003e\u003ctt\u003ec477f3e\u003c/tt\u003e\u003c/a\u003e. Back-patch to all supported branches,\nas that was, just in case anybody wants to do valgrind testing on back\nbranches.\n\nKarina Litskevich\n\nDiscussion: \u003ca href=\"https://postgr.es/m/CACiT8iaAET-fmzjjZLjaJC4zwSJmrFyL7LAdHwaYyjjQOQ4hcg@mail.gmail.com\" rel=\"nofollow\"\u003ehttps://postgr.es/m/CACiT8iaAET-fmzjjZLjaJC4zwSJmrFyL7LAdHwaYyjjQOQ4hcg@mail.gmail.com\u003c/a\u003e","authors":[{"login":"tglsfdc","displayName":"Tom Lane","avatarUrl":"https://avatars.githubusercontent.com/u/8755309?v=4","path":"/tglsfdc","isGitHub":false}],"committerAttribution":false,"committer":{"login":"tglsfdc","displayName":"Tom Lane","avatarUrl":"https://avatars.githubusercontent.com/u/8755309?v=4","path":"/tglsfdc","isGitHub":false},"parents":["a1f45f69bbfc4b44c8adb708e4a4f6db65a67a64"],"globalRelayId":"C_kwDOAA4m0toAKGIzZTE4NGE1ZDRmZGJjNDNkMmNiOTk4NjVlYTJlMDczYzA5Yjk1ODQ","sha1":"a1f45f69bbfc4b44c8adb708e4a4f6db65a67a64","sha2":"b3e184a5d4fdbc43d2cb99865ea2e073c09b9584"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":1111,"text":"@@ -1112,7 +1112,7 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1112,7 +1112,7 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":0,"left":1111,"right":1111},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1112,"text":" \tAllocBlock\tblock;","html":" \t\u003cspan class=pl-smi\u003eAllocBlock\u003c/span\u003e\t\u003cspan class=pl-s1\u003eblock\u003c/span\u003e;","displayNoNewLineWarning":false,"position":1,"left":1112,"right":1112},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1113,"text":" \tAllocSet\tset;","html":" \t\u003cspan class=pl-smi\u003eAllocSet\u003c/span\u003e\t\u003cspan class=pl-s1\u003eset\u003c/span\u003e;","displayNoNewLineWarning":false,"position":2,"left":1113,"right":1113},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1114,"text":" \tMemoryChunk *chunk = PointerGetMemoryChunk(pointer);","html":" \t\u003cspan class=pl-smi\u003eMemoryChunk\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-s1\u003echunk\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003ePointerGetMemoryChunk\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e);","displayNoNewLineWarning":false,"position":3,"left":1114,"right":1114},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1115,"text":"-\tSize\t\toldsize;","html":"-\t\u003cspan class=\"pl-smi\"\u003eSize\u003c/span\u003e\t\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e;","displayNoNewLineWarning":false,"position":4,"left":1115,"right":1114},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1115,"text":"+\tSize\t\toldchksize;","html":"+\t\u003cspan class=\"pl-smi\"\u003eSize\u003c/span\u003e\t\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e;","displayNoNewLineWarning":false,"position":5,"left":1115,"right":1115},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1116,"text":" \tint\t\t\tfidx;","html":" \t\u003cspan class=pl-smi\u003eint\u003c/span\u003e\t\t\t\u003cspan class=pl-s1\u003efidx\u003c/span\u003e;","displayNoNewLineWarning":false,"position":6,"left":1116,"right":1116},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1117,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":7,"left":1117,"right":1117},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1118,"text":" \t/* Allow access to private part of chunk header. */","html":" \t\u003cspan class=pl-c\u003e/* Allow access to private part of chunk header. */\u003c/span\u003e","displayNoNewLineWarning":false,"position":8,"left":1118,"right":1118},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1139,"text":"@@ -1140,11 +1140,11 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1140,11 +1140,11 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":9,"left":1139,"right":1139},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1140,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":10,"left":1140,"right":1140},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1141,"text":" \t\tset = block-\u003easet;","html":" \t\t\u003cspan class=pl-s1\u003eset\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003eblock\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003easet\u003c/span\u003e;","displayNoNewLineWarning":false,"position":11,"left":1141,"right":1141},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1142,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":12,"left":1142,"right":1142},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1143,"text":"-\t\toldsize = block-\u003eendptr - (char *) pointer;","html":"-\t\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eblock\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003eendptr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e (\u003cspan class=\"pl-smi\"\u003echar\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e) \u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e;","displayNoNewLineWarning":false,"position":13,"left":1143,"right":1142},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1143,"text":"+\t\toldchksize = block-\u003eendptr - (char *) pointer;","html":"+\t\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eblock\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003eendptr\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e (\u003cspan class=\"pl-smi\"\u003echar\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e) \u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e;","displayNoNewLineWarning":false,"position":14,"left":1143,"right":1143},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1144,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":15,"left":1144,"right":1144},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1145,"text":" #ifdef MEMORY_CONTEXT_CHECKING","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eMEMORY_CONTEXT_CHECKING\u003c/span\u003e","displayNoNewLineWarning":false,"position":16,"left":1145,"right":1145},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1146,"text":" \t\t/* Test for someone scribbling on unused space in chunk */","html":" \t\t\u003cspan class=pl-c\u003e/* Test for someone scribbling on unused space in chunk */\u003c/span\u003e","displayNoNewLineWarning":false,"position":17,"left":1146,"right":1146},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1147,"text":"-\t\tAssert(chunk-\u003erequested_size \u003c oldsize);","html":"-\t\t\u003cspan class=\"pl-en\"\u003eAssert\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":18,"left":1147,"right":1146},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1147,"text":"+\t\tAssert(chunk-\u003erequested_size \u003c oldchksize);","html":"+\t\t\u003cspan class=\"pl-en\"\u003eAssert\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":19,"left":1147,"right":1147},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1148,"text":" \t\tif (!sentinel_ok(pointer, chunk-\u003erequested_size))","html":" \t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (!\u003cspan class=pl-en\u003esentinel_ok\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e, \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e))","displayNoNewLineWarning":false,"position":20,"left":1148,"right":1148},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1149,"text":" \t\t\telog(WARNING, \"detected write past chunk end in %s %p\",","html":" \t\t\t\u003cspan class=pl-en\u003eelog\u003c/span\u003e(\u003cspan class=pl-c1\u003eWARNING\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;detected write past chunk end in %s %p\u0026quot;\u003c/span\u003e,","displayNoNewLineWarning":false,"position":21,"left":1149,"right":1149},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1150,"text":" \t\t\t\t set-\u003eheader.name, chunk);","html":" \t\t\t\t \u003cspan class=pl-s1\u003eset\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eheader\u003c/span\u003e.\u003cspan class=pl-c1\u003ename\u003c/span\u003e, \u003cspan class=pl-s1\u003echunk\u003c/span\u003e);","displayNoNewLineWarning":false,"position":22,"left":1150,"right":1150},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1186,"text":"@@ -1187,21 +1187,29 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1187,21 +1187,29 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":23,"left":1186,"right":1186},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1187,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":24,"left":1187,"right":1187},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1188,"text":" #ifdef MEMORY_CONTEXT_CHECKING","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eMEMORY_CONTEXT_CHECKING\u003c/span\u003e","displayNoNewLineWarning":false,"position":25,"left":1188,"right":1188},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1189,"text":" #ifdef RANDOMIZE_ALLOCATED_MEMORY","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eRANDOMIZE_ALLOCATED_MEMORY\u003c/span\u003e","displayNoNewLineWarning":false,"position":26,"left":1189,"right":1189},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1190,"text":"-\t\t/* We can only fill the extra space if we know the prior request */","html":"-\t\t\u003cspan class=pl-c\u003e/* We can only fill the extra space if we know the prior request */\u003c/span\u003e","displayNoNewLineWarning":false,"position":27,"left":1190,"right":1189},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1190,"text":"+","html":"+","displayNoNewLineWarning":false,"position":28,"left":1190,"right":1190},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1191,"text":"+\t\t/*","html":"+\t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":29,"left":1190,"right":1191},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1192,"text":"+\t\t * We can only randomize the extra space if we know the prior request.","html":"+\u003cspan class=pl-c\u003e\t\t * We can only randomize the extra space if we know the prior request.\u003c/span\u003e","displayNoNewLineWarning":false,"position":30,"left":1190,"right":1192},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1193,"text":"+\t\t * When using Valgrind, randomize_mem() also marks memory UNDEFINED.","html":"+\u003cspan class=pl-c\u003e\t\t * When using Valgrind, randomize_mem() also marks memory UNDEFINED.\u003c/span\u003e","displayNoNewLineWarning":false,"position":31,"left":1190,"right":1193},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1194,"text":"+\t\t */","html":"+\u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":32,"left":1190,"right":1194},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1195,"text":" \t\tif (size \u003e chunk-\u003erequested_size)","html":" \t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (\u003cspan class=pl-s1\u003esize\u003c/span\u003e \u003cspan class=pl-c1\u003e\u0026gt;\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e)","displayNoNewLineWarning":false,"position":33,"left":1191,"right":1195},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1196,"text":" \t\t\trandomize_mem((char *) pointer + chunk-\u003erequested_size,","html":" \t\t\t\u003cspan class=pl-en\u003erandomize_mem\u003c/span\u003e((\u003cspan class=pl-smi\u003echar\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e) \u003cspan class=pl-s1\u003epointer\u003c/span\u003e \u003cspan class=pl-c1\u003e+\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e,","displayNoNewLineWarning":false,"position":34,"left":1192,"right":1196},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1197,"text":" \t\t\t\t\t\t size - chunk-\u003erequested_size);","html":" \t\t\t\t\t\t \u003cspan class=pl-s1\u003esize\u003c/span\u003e \u003cspan class=pl-c1\u003e-\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e);","displayNoNewLineWarning":false,"position":35,"left":1193,"right":1197},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1194,"text":"-#endif","html":"-\u003cspan class=\"pl-k\"\u003e#\u003cspan class=\"x x-first x-last\"\u003eendif\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":36,"left":1194,"right":1197},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1198,"text":"+#else","html":"+\u003cspan class=\"pl-k\"\u003e#\u003cspan class=\"x x-first x-last\"\u003eelse\u003c/span\u003e\u003c/span\u003e","displayNoNewLineWarning":false,"position":37,"left":1194,"right":1198},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1199,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":38,"left":1195,"right":1199},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1200,"text":" \t\t/*","html":" \t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":39,"left":1196,"right":1200},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1197,"text":"-\t\t * realloc() (or randomize_mem()) will have left any newly-allocated","html":"-\u003cspan class=pl-c\u003e\t\t * realloc() (or randomize_mem()) will have left any newly-allocated\u003c/span\u003e","displayNoNewLineWarning":false,"position":40,"left":1197,"right":1200},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1198,"text":"-\t\t * part UNDEFINED, but we may need to adjust trailing bytes from the","html":"-\u003cspan class=pl-c\u003e\t\t * part UNDEFINED, but we may need to adjust trailing bytes from the\u003c/span\u003e","displayNoNewLineWarning":false,"position":41,"left":1198,"right":1200},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1199,"text":"-\t\t * old allocation.","html":"-\u003cspan class=pl-c\u003e\t\t * old allocation.\u003c/span\u003e","displayNoNewLineWarning":false,"position":42,"left":1199,"right":1200},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1201,"text":"+\t\t * If this is an increase, realloc() will have marked any","html":"+\u003cspan class=pl-c\u003e\t\t * If this is an increase, realloc() will have marked any\u003c/span\u003e","displayNoNewLineWarning":false,"position":43,"left":1199,"right":1201},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1202,"text":"+\t\t * newly-allocated part (from oldchksize to chksize) UNDEFINED, but we","html":"+\u003cspan class=pl-c\u003e\t\t * newly-allocated part (from oldchksize to chksize) UNDEFINED, but we\u003c/span\u003e","displayNoNewLineWarning":false,"position":44,"left":1199,"right":1202},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1203,"text":"+\t\t * also need to adjust trailing bytes from the old allocation (from","html":"+\u003cspan class=pl-c\u003e\t\t * also need to adjust trailing bytes from the old allocation (from\u003c/span\u003e","displayNoNewLineWarning":false,"position":45,"left":1199,"right":1203},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1204,"text":"+\t\t * chunk-\u003erequested_size to oldchksize) as they are marked NOACCESS.","html":"+\u003cspan class=pl-c\u003e\t\t * chunk-\u0026gt;requested_size to oldchksize) as they are marked NOACCESS.\u003c/span\u003e","displayNoNewLineWarning":false,"position":46,"left":1199,"right":1204},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1205,"text":"+\t\t * Make sure not to mark too many bytes in case chunk-\u003erequested_size","html":"+\u003cspan class=pl-c\u003e\t\t * Make sure not to mark too many bytes in case chunk-\u0026gt;requested_size\u003c/span\u003e","displayNoNewLineWarning":false,"position":47,"left":1199,"right":1205},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1206,"text":"+\t\t * \u003c size \u003c oldchksize.","html":"+\u003cspan class=pl-c\u003e\t\t * \u0026lt; size \u0026lt; oldchksize.\u003c/span\u003e","displayNoNewLineWarning":false,"position":48,"left":1199,"right":1206},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1207,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":49,"left":1200,"right":1207},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1208,"text":" #ifdef USE_VALGRIND","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eUSE_VALGRIND\u003c/span\u003e","displayNoNewLineWarning":false,"position":50,"left":1201,"right":1208},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1202,"text":"-\t\tif (oldsize \u003e chunk-\u003erequested_size)","html":"-\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e)","displayNoNewLineWarning":false,"position":51,"left":1202,"right":1208},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1209,"text":"+\t\tif (Min(size, oldchksize) \u003e chunk-\u003erequested_size)","html":"+\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-en x x-first\"\u003eMin\u003c/span\u003e\u003cspan class=\"x\"\u003e(\u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003esize\u003c/span\u003e\u003cspan class=\"x\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003eoldchksize\u003c/span\u003e\u003cspan class=\"x x-last\"\u003e)\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e)","displayNoNewLineWarning":false,"position":52,"left":1202,"right":1209},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1210,"text":" \t\t\tVALGRIND_MAKE_MEM_UNDEFINED((char *) pointer + chunk-\u003erequested_size,","html":" \t\t\t\u003cspan class=pl-en\u003eVALGRIND_MAKE_MEM_UNDEFINED\u003c/span\u003e((\u003cspan class=pl-smi\u003echar\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e) \u003cspan class=pl-s1\u003epointer\u003c/span\u003e \u003cspan class=pl-c1\u003e+\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e,","displayNoNewLineWarning":false,"position":53,"left":1203,"right":1210},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1204,"text":"-\t\t\t\t\t\t\t\t\t\toldsize - chunk-\u003erequested_size);","html":"-\t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003eoldsize\u003c/span\u003e \u003cspan class=pl-c1\u003e-\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e);","displayNoNewLineWarning":false,"position":54,"left":1204,"right":1210},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1211,"text":"+\t\t\t\t\t\t\t\t\t\tMin(size, oldchksize) - chunk-\u003erequested_size);","html":"+\t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-en\u003eMin\u003c/span\u003e(\u003cspan class=pl-s1\u003esize\u003c/span\u003e, \u003cspan class=pl-s1\u003eoldchksize\u003c/span\u003e) \u003cspan class=pl-c1\u003e-\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e);","displayNoNewLineWarning":false,"position":55,"left":1204,"right":1211},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1212,"text":"+#endif","html":"+\u003cspan class=pl-k\u003e#endif\u003c/span\u003e","displayNoNewLineWarning":false,"position":56,"left":1204,"right":1212},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1213,"text":" #endif","html":" \u003cspan class=pl-k\u003e#endif\u003c/span\u003e","displayNoNewLineWarning":false,"position":57,"left":1205,"right":1213},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1214,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":58,"left":1206,"right":1214},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1215,"text":" \t\tchunk-\u003erequested_size = size;","html":" \t\t\u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003esize\u003c/span\u003e;","displayNoNewLineWarning":false,"position":59,"left":1207,"right":1215},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1218,"text":"@@ -1211,11 +1219,14 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1211,11 +1219,14 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":60,"left":1210,"right":1218},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1219,"text":" #else\t\t\t\t\t\t\t/* !MEMORY_CONTEXT_CHECKING */","html":" \u003cspan class=pl-k\u003e#else\u003c/span\u003e\t\t\t\t\t\t\t\u003cspan class=pl-c\u003e/* !MEMORY_CONTEXT_CHECKING */\u003c/span\u003e","displayNoNewLineWarning":false,"position":61,"left":1211,"right":1219},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1220,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":62,"left":1212,"right":1220},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1221,"text":" \t\t/*","html":" \t\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":63,"left":1213,"right":1221},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1214,"text":"-\t\t * We don't know how much of the old chunk size was the actual","html":"-\u003cspan class=pl-c\u003e\t\t * We don\u0026#39;t know how much of the old chunk size was the actual\u003c/span\u003e","displayNoNewLineWarning":false,"position":64,"left":1214,"right":1221},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1215,"text":"-\t\t * allocation; it could have been as small as one byte. We have to be","html":"-\u003cspan class=pl-c\u003e\t\t * allocation; it could have been as small as one byte. We have to be\u003c/span\u003e","displayNoNewLineWarning":false,"position":65,"left":1215,"right":1221},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1216,"text":"-\t\t * conservative and just mark the entire old portion DEFINED.","html":"-\u003cspan class=pl-c\u003e\t\t * conservative and just mark the entire old portion DEFINED.\u003c/span\u003e","displayNoNewLineWarning":false,"position":66,"left":1216,"right":1221},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1222,"text":"+\t\t * We may need to adjust marking of bytes from the old allocation as","html":"+\u003cspan class=pl-c\u003e\t\t * We may need to adjust marking of bytes from the old allocation as\u003c/span\u003e","displayNoNewLineWarning":false,"position":67,"left":1216,"right":1222},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1223,"text":"+\t\t * some of them may be marked NOACCESS. We don't know how much of the","html":"+\u003cspan class=pl-c\u003e\t\t * some of them may be marked NOACCESS. We don\u0026#39;t know how much of the\u003c/span\u003e","displayNoNewLineWarning":false,"position":68,"left":1216,"right":1223},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1224,"text":"+\t\t * old chunk size was the requested size; it could have been as small","html":"+\u003cspan class=pl-c\u003e\t\t * old chunk size was the requested size; it could have been as small\u003c/span\u003e","displayNoNewLineWarning":false,"position":69,"left":1216,"right":1224},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1225,"text":"+\t\t * as one byte. We have to be conservative and just mark the entire","html":"+\u003cspan class=pl-c\u003e\t\t * as one byte. We have to be conservative and just mark the entire\u003c/span\u003e","displayNoNewLineWarning":false,"position":70,"left":1216,"right":1225},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1226,"text":"+\t\t * old portion DEFINED. Make sure not to mark memory beyond the new","html":"+\u003cspan class=pl-c\u003e\t\t * old portion DEFINED. Make sure not to mark memory beyond the new\u003c/span\u003e","displayNoNewLineWarning":false,"position":71,"left":1216,"right":1226},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1227,"text":"+\t\t * allocation in case it's smaller than the old one.","html":"+\u003cspan class=pl-c\u003e\t\t * allocation in case it\u0026#39;s smaller than the old one.\u003c/span\u003e","displayNoNewLineWarning":false,"position":72,"left":1216,"right":1227},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1228,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":73,"left":1217,"right":1228},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1218,"text":"-\t\tVALGRIND_MAKE_MEM_DEFINED(pointer, oldsize);","html":"-\t\t\u003cspan class=\"pl-en\"\u003eVALGRIND_MAKE_MEM_DEFINED\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e, \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":74,"left":1218,"right":1228},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1229,"text":"+\t\tVALGRIND_MAKE_MEM_DEFINED(pointer, Min(size, oldchksize));","html":"+\t\t\u003cspan class=\"pl-en\"\u003eVALGRIND_MAKE_MEM_DEFINED\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e, \u003cspan class=\"pl-en x x-first\"\u003eMin\u003c/span\u003e\u003cspan class=\"x\"\u003e(\u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003esize\u003c/span\u003e\u003cspan class=\"x\"\u003e, \u003c/span\u003e\u003cspan class=\"pl-s1 x\"\u003eoldchksize\u003c/span\u003e\u003cspan class=\"x x-last\"\u003e)\u003c/span\u003e);","displayNoNewLineWarning":false,"position":75,"left":1218,"right":1229},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1230,"text":" #endif","html":" \u003cspan class=pl-k\u003e#endif\u003c/span\u003e","displayNoNewLineWarning":false,"position":76,"left":1219,"right":1230},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1231,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":77,"left":1220,"right":1231},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1232,"text":" \t\t/* Ensure any padding bytes are marked NOACCESS. */","html":" \t\t\u003cspan class=pl-c\u003e/* Ensure any padding bytes are marked NOACCESS. */\u003c/span\u003e","displayNoNewLineWarning":false,"position":78,"left":1221,"right":1232},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1250,"text":"@@ -1240,11 +1251,11 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1240,11 +1251,11 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":79,"left":1239,"right":1250},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1251,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":80,"left":1240,"right":1251},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1252,"text":" \tfidx = MemoryChunkGetValue(chunk);","html":" \t\u003cspan class=pl-s1\u003efidx\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eMemoryChunkGetValue\u003c/span\u003e(\u003cspan class=pl-s1\u003echunk\u003c/span\u003e);","displayNoNewLineWarning":false,"position":81,"left":1241,"right":1252},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1253,"text":" \tAssert(FreeListIdxIsValid(fidx));","html":" \t\u003cspan class=pl-en\u003eAssert\u003c/span\u003e(\u003cspan class=pl-en\u003eFreeListIdxIsValid\u003c/span\u003e(\u0
8000
03cspan class=pl-s1\u003efidx\u003c/span\u003e));","displayNoNewLineWarning":false,"position":82,"left":1242,"right":1253},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1243,"text":"-\toldsize = GetChunkSizeFromFreeListIdx(fidx);","html":"-\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eGetChunkSizeFromFreeListIdx\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003efidx\u003c/span\u003e);","displayNoNewLineWarning":false,"position":83,"left":1243,"right":1253},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1254,"text":"+\toldchksize = GetChunkSizeFromFreeListIdx(fidx);","html":"+\t\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eGetChunkSizeFromFreeListIdx\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003efidx\u003c/span\u003e);","displayNoNewLineWarning":false,"position":84,"left":1243,"right":1254},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1255,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":85,"left":1244,"right":1255},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1256,"text":" #ifdef MEMORY_CONTEXT_CHECKING","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eMEMORY_CONTEXT_CHECKING\u003c/span\u003e","displayNoNewLineWarning":false,"position":86,"left":1245,"right":1256},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1257,"text":" \t/* Test for someone scribbling on unused space in chunk */","html":" \t\u003cspan class=pl-c\u003e/* Test for someone scribbling on unused space in chunk */\u003c/span\u003e","displayNoNewLineWarning":false,"position":87,"left":1246,"right":1257},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1247,"text":"-\tif (chunk-\u003erequested_size \u003c oldsize)","html":"-\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":88,"left":1247,"right":1257},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1258,"text":"+\tif (chunk-\u003erequested_size \u003c oldchksize)","html":"+\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1\"\u003echunk\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003erequested_size\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":89,"left":1247,"right":1258},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1259,"text":" \t\tif (!sentinel_ok(pointer, chunk-\u003erequested_size))","html":" \t\t\u003cspan class=pl-k\u003eif\u003c/span\u003e (!\u003cspan class=pl-en\u003esentinel_ok\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e, \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e))","displayNoNewLineWarning":false,"position":90,"left":1248,"right":1259},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1260,"text":" \t\t\telog(WARNING, \"detected write past chunk end in %s %p\",","html":" \t\t\t\u003cspan class=pl-en\u003eelog\u003c/span\u003e(\u003cspan class=pl-c1\u003eWARNING\u003c/span\u003e, \u003cspan class=pl-s\u003e\u0026quot;detected write past chunk end in %s %p\u0026quot;\u003c/span\u003e,","displayNoNewLineWarning":false,"position":91,"left":1249,"right":1260},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1261,"text":" \t\t\t\t set-\u003eheader.name, chunk);","html":" \t\t\t\t \u003cspan class=pl-s1\u003eset\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003eheader\u003c/span\u003e.\u003cspan class=pl-c1\u003ename\u003c/span\u003e, \u003cspan class=pl-s1\u003echunk\u003c/span\u003e);","displayNoNewLineWarning":false,"position":92,"left":1250,"right":1261},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1265,"text":"@@ -1255,7 +1266,7 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1255,7 +1266,7 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":93,"left":1254,"right":1265},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1266,"text":" \t * allocated area already is \u003e= the new size. (In particular, we will","html":" \u003cspan class=pl-c\u003e\t * allocated area already is \u0026gt;= the new size. (In particular, we will\u003c/span\u003e","displayNoNewLineWarning":false,"position":94,"left":1255,"right":1266},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1267,"text":" \t * fall out here if the requested size is a decrease.)","html":" \u003cspan class=pl-c\u003e\t * fall out here if the requested size is a decrease.)\u003c/span\u003e","displayNoNewLineWarning":false,"position":95,"left":1256,"right":1267},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1268,"text":" \t */","html":" \u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":96,"left":1257,"right":1268},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1258,"text":"-\tif (oldsize \u003e= size)","html":"-\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e \u0026gt;= \u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":97,"left":1258,"right":1268},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1269,"text":"+\tif (oldchksize \u003e= size)","html":"+\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e \u0026gt;= \u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":98,"left":1258,"right":1269},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1270,"text":" \t{","html":" \t{","displayNoNewLineWarning":false,"position":99,"left":1259,"right":1270},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1271,"text":" #ifdef MEMORY_CONTEXT_CHECKING","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eMEMORY_CONTEXT_CHECKING\u003c/span\u003e","displayNoNewLineWarning":false,"position":100,"left":1260,"right":1271},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1272,"text":" \t\tSize\t\toldrequest = chunk-\u003erequested_size;","html":" \t\t\u003cspan class=pl-smi\u003eSize\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003eoldrequest\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e;","displayNoNewLineWarning":false,"position":101,"left":1261,"right":1272},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1288,"text":"@@ -1278,10 +1289,10 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1278,10 +1289,10 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":102,"left":1277,"right":1288},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1289,"text":" \t\t\t\t\t\t\t\t\t\tsize - oldrequest);","html":" \t\t\t\t\t\t\t\t\t\t\u003cspan class=pl-s1\u003esize\u003c/span\u003e \u003cspan class=pl-c1\u003e-\u003c/span\u003e \u003cspan class=pl-s1\u003eoldrequest\u003c/span\u003e);","displayNoNewLineWarning":false,"position":103,"left":1278,"right":1289},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1290,"text":" \t\telse","html":" \t\t\u003cspan class=pl-k\u003eelse\u003c/span\u003e","displayNoNewLineWarning":false,"position":104,"left":1279,"right":1290},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1291,"text":" \t\t\tVALGRIND_MAKE_MEM_NOACCESS((char *) pointer + size,","html":" \t\t\t\u003cspan class=pl-en\u003eVALGRIND_MAKE_MEM_NOACCESS\u003c/span\u003e((\u003cspan class=pl-smi\u003echar\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e) \u003cspan class=pl-s1\u003epointer\u003c/span\u003e \u003cspan class=pl-c1\u003e+\u003c/span\u003e \u003cspan class=pl-s1\u003esize\u003c/span\u003e,","displayNoNewLineWarning":false,"position":105,"left":1280,"right":1291},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1281,"text":"-\t\t\t\t\t\t\t\t\t oldsize - size);","html":"-\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":106,"left":1281,"right":1291},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1292,"text":"+\t\t\t\t\t\t\t\t\t oldchksize - size);","html":"+\t\t\t\t\t\t\t\t\t \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":107,"left":1281,"right":1292},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1293,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":108,"left":1282,"right":1293},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1294,"text":" \t\t/* set mark to catch clobber of \"unused\" space */","html":" \t\t\u003cspan class=pl-c\u003e/* set mark to catch clobber of \u0026quot;unused\u0026quot; space */\u003c/span\u003e","displayNoNewLineWarning":false,"position":109,"left":1283,"right":1294},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1284,"text":"-\t\tif (size \u003c oldsize)","html":"-\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":110,"left":1284,"right":1294},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1295,"text":"+\t\tif (size \u003c oldchksize)","html":"+\t\t\u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e (\u003cspan class=\"pl-s1\"\u003esize\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026lt;\u003c/span\u003e \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e)","displayNoNewLineWarning":false,"position":111,"left":1284,"right":1295},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1296,"text":" \t\t\tset_sentinel(pointer, size);","html":" \t\t\t\u003cspan class=pl-en\u003eset_sentinel\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e, \u003cspan class=pl-s1\u003esize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":112,"left":1285,"right":1296},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1297,"text":" #else\t\t\t\t\t\t\t/* !MEMORY_CONTEXT_CHECKING */","html":" \u003cspan class=pl-k\u003e#else\u003c/span\u003e\t\t\t\t\t\t\t\u003cspan class=pl-c\u003e/* !MEMORY_CONTEXT_CHECKING */\u003c/span\u003e","displayNoNewLineWarning":false,"position":113,"left":1286,"right":1297},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1298,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":114,"left":1287,"right":1298},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1300,"text":"@@ -1290,7 +1301,7 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1290,7 +1301,7 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":115,"left":1289,"right":1300},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1301,"text":" \t\t * the old request or shrinking it, so we conservatively mark the","html":" \u003cspan class=pl-c\u003e\t\t * the old request or shrinking it, so we conservatively mark the\u003c/span\u003e","displayNoNewLineWarning":false,"position":116,"left":1290,"right":1301},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1302,"text":" \t\t * entire new allocation DEFINED.","html":" \u003cspan class=pl-c\u003e\t\t * entire new allocation DEFINED.\u003c/span\u003e","displayNoNewLineWarning":false,"position":117,"left":1291,"right":1302},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1303,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":118,"left":1292,"right":1303},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1293,"text":"-\t\tVALGRIND_MAKE_MEM_NOACCESS(pointer, oldsize);","html":"-\t\t\u003cspan class=\"pl-en\"\u003eVALGRIND_MAKE_MEM_NOACCESS\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e, \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldsize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":119,"left":1293,"right":1303},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1304,"text":"+\t\tVALGRIND_MAKE_MEM_NOACCESS(pointer, oldchksize);","html":"+\t\t\u003cspan class=\"pl-en\"\u003eVALGRIND_MAKE_MEM_NOACCESS\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003epointer\u003c/span\u003e, \u003cspan class=\"pl-s1 x x-first x-last\"\u003eoldchksize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":120,"left":1293,"right":1304},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1305,"text":" \t\tVALGRIND_MAKE_MEM_DEFINED(pointer, size);","html":" \t\t\u003cspan class=pl-en\u003eVALGRIND_MAKE_MEM_DEFINED\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e, \u003cspan class=pl-s1\u003esize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":121,"left":1294,"right":1305},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1306,"text":" #endif","html":" \u003cspan class=pl-k\u003e#endif\u003c/span\u003e","displayNoNewLineWarning":false,"position":122,"left":1295,"right":1306},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1307,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":123,"left":1296,"right":1307},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1323,"text":"@@ -1313,6 +1324,7 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1313,6 +1324,7 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":124,"left":1312,"right":1323},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1324,"text":" \t\t * memory indefinitely. See pgsql-hackers archives for 2007-08-11.)","html":" \u003cspan class=pl-c\u003e\t\t * memory indefinitely. See pgsql-hackers archives for 2007-08-11.)\u003c/span\u003e","displayNoNewLineWarning":false,"position":125,"left":1313,"right":1324},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1325,"text":" \t\t */","html":" \u003cspan class=pl-c\u003e\t\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":126,"left":1314,"right":1325},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1326,"text":" \t\tAllocPointer newPointer;","html":" \t\t\u003cspan class=pl-smi\u003eAllocPointer\u003c/span\u003e \u003cspan class=pl-s1\u003enewPointer\u003c/span\u003e;","displayNoNewLineWarning":false,"position":127,"left":1315,"right":1326},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1327,"text":"+\t\tSize\t\toldsize;","html":"+\t\t\u003cspan class=pl-smi\u003eSize\u003c/span\u003e\t\t\u003cspan class=pl-s1\u003eoldsize\u003c/span\u003e;","displayNoNewLineWarning":false,"position":128,"left":1315,"right":1327},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1328,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":129,"left":1316,"right":1328},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1329,"text":" \t\t/* allocate new chunk */","html":" \t\t\u003cspan class=pl-c\u003e/* allocate new chunk */\u003c/span\u003e","displayNoNewLineWarning":false,"position":130,"left":1317,"right":1329},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1330,"text":" \t\tnewPointer = AllocSetAlloc((MemoryContext) set, size);","html":" \t\t\u003cspan class=pl-s1\u003enewPointer\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eAllocSetAlloc\u003c/span\u003e((\u003cspan class=pl-smi\u003eMemoryContext\u003c/span\u003e) \u003cspan class=pl-s1\u003eset\u003c/span\u003e, \u003cspan class=pl-s1\u003esize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":131,"left":1318,"right":1330},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1348,"text":"@@ -1337,6 +1349,7 @@ AllocSetRealloc(void *pointer, Size size)","html":"@@ -1337,6 +1349,7 @@ AllocSetRealloc(void *pointer, Size size)","displayNoNewLineWarning":false,"position":132,"left":1336,"right":1348},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1349,"text":" #ifdef MEMORY_CONTEXT_CHECKING","html":" \u003cspan class=pl-k\u003e#ifdef\u003c/span\u003e \u003cspan class=pl-c1\u003eMEMORY_CONTEXT_CHECKING\u003c/span\u003e","displayNoNewLineWarning":false,"position":133,"left":1337,"right":1349},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1350,"text":" \t\toldsize = chunk-\u003erequested_size;","html":" \t\t\u003cspan class=pl-s1\u003eoldsize\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003echunk\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erequested_size\u003c/span\u003e;","displayNoNewLineWarning":false,"position":134,"left":1338,"right":1350},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1351,"text":" #else","html":" \u003cspan class=pl-k\u003e#else\u003c/span\u003e","displayNoNewLineWarning":false,"position":135,"left":1339,"right":1351},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1352,"text":"+\t\toldsize = oldchksize;","html":"+\t\t\u003cspan class=pl-s1\u003eoldsize\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-s1\u003eoldchksize\u003c/span\u003e;","displayNoNewLineWarning":false,"position":136,"left":1339,"right":1352},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1353,"text":" \t\tVALGRIND_MAKE_MEM_DEFINED(pointer, oldsize);","html":" \t\t\u003cspan class=pl-en\u003eVALGRIND_MAKE_MEM_DEFINED\u003c/span\u003e(\u003cspan class=pl-s1\u003epointer\u003c/span\u003e, \u003cspan class=pl-s1\u003eoldsize\u003c/span\u003e);","displayNoNewLineWarning":false,"position":137,"left":1340,"right":1353},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1354,"text":" #endif","html":" \u003cspan class=pl-k\u003e#endif\u003c/span\u003e","displayNoNewLineWarning":false,"position":138,"left":1341,"right":1354},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1355,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":139,"left":1342,"right":1355}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":1645,"linesChanged":53,"newTreeEntry":{"lineCount":1645,"path":"src/backend/utils/mmgr/aset.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/utils/mmgr/aset.c","mode":100644},"linesAdded":33,"linesDeleted":20,"path":"src/backend/utils/mmgr/aset.c","pathDigest":"5984bd8de2c03c90c0659436eb52af31507831a14204bb8ea40fbcd2431013c8","status":"MODIFIED","truncatedReason":null,"oldOid":"a1f45f69bbfc4b44c8adb708e4a4f6db65a67a64","newOid":"b3e184a5d4fdbc43d2cb99865ea2e073c09b9584","copilotChatReference":null,"deletedSha":"a1f45f69bbfc4b44c8adb708e4a4f6db65a67a64","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/b3e184a5d4fdbc43d2cb99865ea2e073c09b9584","fileTreeExpanded":true,"headerInfo":{"additions":33,"deletions":20,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":5256,"lineShownCount":140},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"nDJOiJZtV5ZIRzpCzZkHa7JT6ERvsmdluyEh7VdqxC4NoxDT_eiHS6GlKT8eLf7SCl278q-JNpK46eQwtnmDMw"},"/users/diffview?diff=unified":{"post":"QYrA09a0qb_g7MnJAO08ce4l7Jp1_ttUWWhTSS2QRwzQG56IvTF5YgkO2rTTWcXIViu_LLXFiqNaoJaUzIMAEQ"},"/notifications/thread":{"post":"cx2NpVP2Z3vVpRkTw7uoBvdpQHCTYynPjGScV4-yC702u8o29YEo4nAUuz5v9cSZrE7UIrrdrMkxxfzhUUm5Lg"}}},"title":"Fix erroneous Valgrind markings in AllocSetRealloc. · postgres/postgres@b3e184a","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}
Fix erroneous Valgrind markings in AllocSetRealloc.
If asked to decrease the size of a large (>8K) palloc chunk,
AllocSetRealloc could improperly change the Valgrind state of memory
beyond the new end of the chunk: it would mark data UNDEFINED as far
as the old end of the chunk after having done the realloc(3) call,
thus tromping on the state of memory that no longer belongs to it.
One would normally expect that memory to now be marked NOACCESS,
so that this mislabeling might prevent detection of later errors.
If realloc() had chosen to move the chunk someplace else (unlikely,
but well within its rights) we could also mismark perfectly-valid
DEFINED data as UNDEFINED, causing false-positive valgrind reports
later. Also, any malloc bookkeeping data placed within this area
might now be wrongly marked, causing additional problems.
Fix by replacing relevant uses of "oldsize" with "Min(size, oldsize)".
It's sufficient to mark as far as "size" when that's smaller, because
whatever remains in the new chunk size will be marked NOACCESS below,
and we expect realloc() to have taken care of marking the memory
beyond the new official end of the chunk.
While we're here, also rename the function's "oldsize" variable
to "oldchksize" to more clearly explain what it actually holds,
namely the distance to the end of the chunk (that is, requested size
plus trailing padding). This is more consistent with the use of
"size" and "chksize" to hold the new requested size and chunk size.
Add a new variable "oldsize" in the one stanza where we're actually
talking about the old requested size.
Oversight in commit c477f3e. Back-patch to all supported branches,
as that was, just in case anybody wants to do valgrind testing on back
branches.
Karina Litskevich
Discussion: https://postgr.es/m/CACiT8iaAET-fmzjjZLjaJC4zwSJmrFyL7LAdHwaYyjjQOQ4hcg@mail.gmail.com
0 commit comments