On Tue, May 24, 2016 at 11:51:08AM +0100, Stuart Henderson wrote:
> I've collected the known problems so far at
> https://docs.google.com/spreadsheets/d/1RjfH2_ecaUc_G5kmPAKbH00w0qcR-vWljTiUb4UCVXI/edit?usp=sharing
Regarding lang/hugs, there's this masterpiece in src/builtin.c:
/*
* Allocate len bytes which are readable, writable, and executable.
*
* ToDo: If this turns out to be a performance bottleneck, one could
* e.g. cache the last VirtualProtect/mprotect-ed region and do
* nothing in case of a cache hit.
*/
static void* local mallocBytesRWX(int len) {
void *addr = (void *)malloc(len);
#if defined(i386_HOST_ARCH) && defined(_WIN32)
/* This could be necessary for processors which distinguish between
READ and EXECUTE memory accesses, e.g. Itaniums. */
DWORD dwOldProtect = 0;
if (VirtualProtect(addr, len, PAGE_EXECUTE_READWRITE, ) == 0) {
ERRMSG(0) "mallocBytesRWX: failed to protect 0x%p\n", addr
EEND;
}
#elif defined(openbsd_HOST_OS) || defined(linux_HOST_OS)
/* malloced memory isn't executable by default on OpenBSD */
uintptr_t pageSize = sysconf(_SC_PAGESIZE);
uintptr_t mask = ~(pageSize - 1);
uintptr_t startOfFirstPage = ((uintptr_t)addr ) & mask;
uintptr_t startOfLastPage = ((uintptr_t)addr + len - 1) & mask;
uintptr_t size = startOfLastPage - startOfFirstPage + pageSize;
if (mprotect((void*)startOfFirstPage,
(size_t)size, PROT_EXEC | PROT_READ | PROT_WRITE) != 0)
{
ERRMSG(0) "mallocBytesRWX: failed to protect 0x%p\n", addr
EEND;
}
#endif
return addr;
}
IIRC, I once wrote that the ports tree isn't a software museum, so
instead of trying to fix it, i'd just cimpletely remove it from the
tree, and maybe other ancient haskell implementations (yes, I mean
you, nhc98!).
I know that I tried to preserve that old shit a year ago (or even
less), but it's just in the way and no longer maintained upstream.
Ciao,
Kili