From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2f65a0aa1447a438f388be943ab38c4a@felloff.net> Date: Mon, 2 Mar 2015 11:23:00 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] pool curalloc bug Topicbox-Message-UUID: 470689a6-ead9-11e9-9d60-3106f5b1d025 the problem with curalloc was the following: poolallocl() allocates, trims, and then adds the resulting block size to curalloc. and poolfreel() subtracts the blocksize from curalloc. so far so good. problem is when we try to merge arenas, the last block in the bottom arena is extended up to the start of the top arena to encompass the space between, and then it is trimmed back to its old *data* size. depending on the size of the gab, the free data might be accounted for in the Btail datasize or it might get its own free block if it is big enougth. in the first case, the block size would'v been increased (we got some extra space at the end) but this was not accounted for in curalloc. so poolfreel() will subtract a bigger value than was added to curalloc, hence the underflow. the fix is to account for the changed block size in curalloc when merging arenas. curalloc is also not properly maintained in poolallocalign(), but thats not in the testcase. -- cinap