coredump on solaris
Matt Mackall
mpm at selenic.com
Fri Jun 17 07:01:21 UTC 2005
On Fri, Jun 17, 2005 at 01:59:28PM +0800, Soh Tk-r28629 wrote:
> I am running hg-0.5b on Solaris 2.6 with Python 2.4 and gcc 2.95.3.
> However, when I tried to run hg on the mercurial hourly snapshot, hg
> crashed with coredump (bus error). The followings are the error
> message and gdb's stack trace. Any clue?
> #0 0xee9910d8 in decode (bin=0x207ae9 "", len=198) at mercurial/mpatch.c:203
This is the code in question:
while (bin < end) {
lt->start = ntohl(*(uint32_t *)bin);
lt->end = ntohl(*(uint32_t *)(bin + 4));
lt->len = ntohl(*(uint32_t *)(bin + 8));
lt->data = bin + 12;
bin += 12 + lt->len;
lt++;
}
Notice that bin is not nicely aligned (0x207ae9), which will make lots
of RISC boxes unhappy when we try to unpack things.
Guess I'll have to fix that. Try this (in tip):
# HG changeset patch
# User mpm at selenic.com
# Node ID a29decbf7475110ecf7108a49a0f1cfb47379097
# Parent 4862a134e2c2516f09324d12a0036c073b190ada
mpatch: attempt to handle unpack alignment issues on Solaris
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
mpatch: attempt to handle unpack alignment issues on Solaris
manifest hash: e185dc380bab61cf11a9973ee3ddd2e904e56299
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCsnOtywK+sNU5EO8RAlzQAJ9YIhbL8BJjT+J/pOiQVES2wsF0igCgnFRl
ok5f8i8GbNk77sRbpsGnUF0=
=m0Zh
-----END PGP SIGNATURE-----
--- a/mercurial/mpatch.c Fri Jun 17 06:32:55 2005
+++ b/mercurial/mpatch.c Fri Jun 17 06:54:37 2005
@@ -195,15 +195,17 @@
struct flist *l;
struct frag *lt;
char *end = bin + len;
+ char decode[12]; /* for dealing with alignment issues */
/* assume worst case size, we won't have many of these lists */
l = lalloc(len / 12);
lt = l->tail;
while (bin < end) {
- lt->start = ntohl(*(uint32_t *)bin);
- lt->end = ntohl(*(uint32_t *)(bin + 4));
- lt->len = ntohl(*(uint32_t *)(bin + 8));
+ memcpy(decode, bin, 12);
+ lt->start = ntohl(*(uint32_t *)decode);
+ lt->end = ntohl(*(uint32_t *)(decode + 4));
+ lt->len = ntohl(*(uint32_t *)(decode + 8));
lt->data = bin + 12;
bin += 12 + lt->len;
lt++;
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list