[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 - odd gdb results
The following reply was made to PR pkg/46190; it has been noted by GNATS.
From: Matthew Mondor <mm_lists%pulsar-zone.net@localhost>
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
odd gdb results
Date: Tue, 1 May 2012 04:39:13 -0400
Someone else on IRC was having issues with BitchX on NetBSD/AMD64,
and we both agreed it was very similar to this PR's issue. While
trying to come up with the smallest test case that could reproduce
the problem, the following became obvious:
On the amd64 ELF ABI, the C default return value (int) is 32-bit.
Thus, calling any function working on pointers that is lacking a
prototype can be fatal and result in corrupted pointers with the
high 32-bit set to 0xffffffff. I'm not sure if this could somehow
be mitigated, but it might require breaking compatibility.
void *buf = malloc(size);
if (buf == NULL)
err(EXIT_FAILURE, "malloc(%ld)", size);
char *str = (char *)my_malloc(2048);
(void)printf("%c %p\n", (str ? '1' : '0'), str);
if (str != NULL)
cc -Wall -c -o mymalloc.o mymalloc.c
cc -Wall -c -o main.o main.c
cc -Wall -o test main.o mymalloc.o
 Segmentation fault (core dumped) ./test
rlwrap is probably missing some prototype(s)/headers which it should
include, and I'll post a further followup once I can patch it to
work on amd64.
Main Index |
Thread Index |