bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#19393: 25.0.50; Emacs cannot determine coding system of ISO-8859 enc


From: Wolfgang Jenkner
Subject: bug#19393: 25.0.50; Emacs cannot determine coding system of ISO-8859 encoded files
Date: Wed, 14 Jan 2015 20:41:21 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix)

On Tue, Jan 13 2015, Wolfgang Jenkner wrote:

> Here's a simple change in src/buffer.c that reduces the time to six
> seconds or so, but only for newer versions of FreeBSD.
>
> It takes advantage of the MAP_EXCL flag for mmap(2), which has been
> recently added[1] and is also available in 10-STABLE and 10.1-RELEASE.

There remains the problem, though, that emacs on FreeBSD also uses
gmalloc and hence, IIUC, sbrk() for memory allocation, and at this point
I'm too ignorant about almost everything involved here to be confident
that mmap()ed pages can't overlap with the process (BSS) data segment
when MAP_EXCL | MAP_FIXED is among the flags.

Without the MAP_EXCL mmap flag they definitely can overlap, as the
following test program shows when it is _statically_ linked.

Here's the output when I run it:

r0 = 0x800663000
Cannot allocate memory
r2 = 0x800662000

-- >8 --
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
#include <errno.h>

int
main ()
{
        int n;
        void *r0, *r1, *r2;

        n = getpagesize();

        r0 = mmap(NULL, n, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);

        if (r0 == MAP_FAILED || brk(r0) != 0 || sbrk(0) != r0)
                return (1);
        
        fprintf(stderr, "r0 = %p\n", r0);

        errno = 0;
        r1 = mmap(r0 - n, n, PROT_READ | PROT_WRITE,
                  MAP_ANON | MAP_EXCL | MAP_FIXED, -1, 0);
        if (r1 == MAP_FAILED)
                perror(NULL);
        else
                fprintf(stderr, "r1 = %p\n", r1);

        errno = 0;
        r2 = mmap(r0 - n, n, PROT_READ | PROT_WRITE,
                  MAP_ANON | MAP_FIXED, -1, 0);
        if (r2 == MAP_FAILED)
                perror(NULL);
        else
                fprintf(stderr, "r2 = %p\n", r2);


        return (0);
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]