Thus said Richard Hipp on Tue, 09 Feb 2016 07:39:57 -0500: > The input to checksum() should normally be a pointer to a buffer > obtained from malloc(). And such buffers should always be 8-byte > aligned (or 4-byte aligned on Windows). So I'm not sure how this is > happening. There must be some path somewhere in Fossil whereby > delta_create() or delta_apply() is called with a pointer into the > middle of an allocated buffer, rather than a pointer to the beginning > of the buffer.
In some cases, the input to checksum(), specifically, zIn (which is actually zOut in the caller delta_create), may not actually be obtained from malloc(). I am able to reproduce this particular assertion with the following: $ touch file $ fossil add file ADDED file $ fossil commit -m added New_Version: 5c966f6fe56d2efd262865f0a504fd102bb0c078 $ fossil mv file other RENAME file other $ mv file other $ fossil stash save -m renamed assertion "(z - (const unsigned char*)0)%4==0" failed: file "./src/delta.c", line 231, function "checksum" Abort trap (core dumped) Given that blob_zero initializes pBlob->aData here: http://www.fossil-scm.org/index.html/artifact/831a63c8c61dbfdb5fe629a473cd7b01104478fc?txt=1&ln=262+266 Then, stash tries to read a file that is empty: http://www.fossil-scm.org/index.html/artifact/ced32acae9b125f723c6473f30cdfdf8b530dc37?txt=1&ln=123+126 In this case, pBlob->aData has not been allocated by malloc() because the file was empty (file size of 0 so the blob was never altered from its initial state). And sure enough, the address of memory for zIn (a buffer pointing to pBlob->aData) on one invocation on my system: Breakpoint 4, checksum (zIn=0x36127dfb "", N=0) at delta.c:226 226 static unsigned int checksum(const char *zIn, size_t N){ $ echo 'puts [expr {0x36127dfb % 4}]' | tclsh 3 Which is why the assertion fails. I propose that blob_delta_create should use blob_materialize instead of blob_buffer here: http://www.fossil-scm.org/index.html/info/75ddc3687acbdb32 Thanks, Andy -- TAI64 timestamp: 4000000057f4a4f8 _______________________________________________ fossil-users mailing list [email protected] http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

