<div dir="ltr">I modify Luajit 2.0.2 as following and luajit works like a charm.<br><br>--- lj_arch.h.ori 2014-02-15 15:31:02.455765000 +0000<br>+++ lj_arch.h 2014-02-15 15:31:39.595775000 +0000<br>@@ -67,7 +67,7 @@<br>
#elif defined(__MACH__) && defined(__APPLE__)<br> #define LUAJIT_OS LUAJIT_OS_OSX<br> #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \<br>- defined(__NetBSD__) || defined(__OpenBSD__)<br>+ defined(__NetBSD__) || defined(__OpenBSD__)|| defined(__DragonFly__)<br>
#define LUAJIT_OS LUAJIT_OS_BSD<br> #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)<br> #define LUAJIT_OS LUAJIT_OS_POSIX<br><br><br>-#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)<br>
+#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)|| defined(__DragonFly__)<br><br> /* OSX and FreeBSD mmap() use a naive first-fit linear search.<br> ** That's perfect for us. Except that -pagezero_size must be set for OSX,<br>
@@ -197,6 +197,8 @@<br> */<br> #if LJ_TARGET_OSX<br> #define MMAP_REGION_START ((uintptr_t)0x10000)<br>+#elif defined(__DragonFly__)<br>+#define MMAP_REGION_START ((uintptr_t)0x10000)<br> #else<br> #define MMAP_REGION_START ((uintptr_t)0x10000000)<br>
#endif<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-15 15:36 GMT+08:00 lhmwzy <span dir="ltr"><<a href="mailto:lhmwzy@gmail.com" target="_blank">lhmwzy@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">The John Marino'patch was following:<br><div><br><br>--- <a href="http://lj_arch.h.org" target="_blank">lj_arch.h.org</a> 2014-02-14 16:32:03.125932000 +0000<br>
+++ lj_arch.h 2014-02-14 16:32:34.725951000 +0000<div class=""><br><br>@@ -67,7 +67,7 @@<br>#elif defined(__MACH__) && defined(__APPLE__)<br>#define LUAJIT_OS LUAJIT_OS_OSX<br>#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \<br>
- defined(__NetBSD__) || defined(__OpenBSD__)<br></div>+ defined(__NetBSD__) || defined(__OpenBSD__)|| defined(__DragonFly__)<div class=""><br>#define LUAJIT_OS LUAJIT_OS_BSD<br>#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)<br>
#define LUAJIT_OS LUAJIT_OS_POSIX<br><br></div>--- <a href="http://lj_alloc.c.org" target="_blank">lj_alloc.c.org</a> 2014-02-14 16:33:19.015979000 +0000<br>+++ lj_alloc.c 2014-02-14 16:32:50.225961000 +0000<br>@@ -188,6 +188,33 @@<br>
return ptr;<br>
}<br><br>+#elif defined(__DragonFly__)<br>+<br>+#define MMAP_REGION_START ((uintptr_t)0x1000)<br>+#define MMAP_REGION_END ((uintptr_t)0x80000000)<br>+<br>+static LJ_AINLINE void *CALL_MMAP(size_t size)<br>+{<br>+ int olderr = errno;<br>
+ /* Hint for next allocation. Doesn't need to be thread-safe. */<br>+ static uintptr_t alloc_hint = MMAP_REGION_START;<br>+ int retry = 0;<br>+ for (;;) {<br>+ void *p = mmap((void *)alloc_hint, size, MMAP_PROT, MMAP_FLAGS, -1, 0);<br>
+ if ((uintptr_t)p >= 0 && (uintptr_t)p + size < MMAP_REGION_END) {<br>+ alloc_hint = (uintptr_t)p + size;<br>+ errno = olderr;<br>+ return p;<br>+ }<br>+ if (p != CMFAIL) munmap(p, size);<br>+ if (retry) break;<br>
+ retry = 1;<br>+ alloc_hint += 0x100000;<br>+ }<br>+ errno = olderr;<br>+ return CMFAIL;<br>+}<br>+</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-15 15:34 GMT+08:00 lhmwzy <span dir="ltr"><<a href="mailto:lhmwzy@gmail.com" target="_blank">lhmwzy@gmail.com</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Here is the modify<br><br>--- lj_arch.h 2014-02-15 15:31:39.595775000 +0000<br>+++ lj_arch.h.ori 2014-02-15 15:31:02.455765000 +0000<br>
@@ -67,7 +67,7 @@<br> #elif defined(__MACH__) && defined(__APPLE__)<br>
#define LUAJIT_OS LUAJIT_OS_OSX<br> #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \<br>- defined(__NetBSD__) || defined(__OpenBSD__)|| defined(__DragonFly__)<br>+ defined(__NetBSD__) || defined(__OpenBSD__)<br>
#define LUAJIT_OS LUAJIT_OS_BSD<br> #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)<br> #define LUAJIT_OS LUAJIT_OS_POSIX<br><br>--- lj_alloc.c 2014-02-15 15:32:47.735793000 +0000<br>
+++ lj_alloc.c.ori 2014-02-15 15:31:12.435768000 +0000<br>@@ -188,7 +188,7 @@<br> return ptr;<br> }<br><br>-#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)|| defined(__DragonFly__)<br>
+#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)<br><br> /* OSX and FreeBSD mmap() use a naive first-fit linear search.<br> ** That's perfect for us. Except that -pagezero_size must be set for OSX,<br>
@@ -202,7 +202,7 @@<br> #endif<br> #define MMAP_REGION_END ((uintptr_t)0x80000000)<br><br>-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)|| defined(__DragonFly__)<br>+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)<br>
#include <sys/resource.h><br> #endif<br><br>@@ -212,7 +212,7 @@<br> /* Hint for next allocation. Doesn't need to be thread-safe. */<br> static uintptr_t alloc_hint = MMAP_REGION_START;<br> int retry = 0;<br>
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)|| defined(__DragonFly__)<br>+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)<br> static int rlimit_modified = 0;<br> if (LJ_UNLIKELY(rlimit_modified == 0)) {<br>
struct rlimit rlim;<br><br></div>When make completed,run luajit<br>./luajit<br>./luajit: cannot create state: not enough memory<br><br></div>kdump result:<br>kdump<br> 2424 ktrace RET ktrace 0<br> 2424 ktrace CALL execve(0x7ffffffffb97,0x7ffffffff948,0x7ffffffff958)<br>
2424 ktrace NAMI "./luajit"<br> 2424 ktrace NAMI "/usr/libexec/ld-elf.so.2"<br> 2424 luajit RET execve 0<br> 2424 luajit CALL __sysctl(0x7fffffffefe0,0x2,0x800897b60,0x7fffffffefd8,0,0)<br>
2424 luajit RET __sysctl 0<br> 2424 luajit CALL mmap(0,0x8000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0,0)<br> 2424 luajit RET mmap 6901760/0x695000<br> 2424 luajit CALL issetugid<br> 2424 luajit RET issetugid 0<br>
2424 luajit CALL lstat(0x80069a000,0x7fffffffeef0)<br> 2424 luajit NAMI "/etc"<br> 2424 luajit RET lstat 0<br> 2424 luajit CALL lstat(0x80069a000,0x7fffffffeef0)<br> 2424 luajit NAMI "/etc/libmap.conf"<br>
2424 luajit RET lstat -1 errno 2 No such file or directory<br> 2424 luajit CALL open(0x80069a000,O_CLOEXEC,<unused>0)<br> 2424 luajit NAMI "/etc/libmap.conf"<br> 2424 luajit RET open -1 errno 2 No such file or directory<br>
2424 luajit CALL access(0x80069a000,F_OK)<br> 2424 luajit NAMI "/usr/lib/gcc47/libm.so.4"<br> 2424 luajit RET access -1 errno 2 No such file or directory<br> 2424 luajit CALL open(0x80068c906,O_CLOEXEC,<unused>0x8)<br>
2424 luajit NAMI "/var/run/ld-elf.so.hints"<br> 2424 luajit RET open 3<br> 2424 luajit CALL read(0x3,0x7fffffffed60,0x80)<br> 2424 luajit GIO fd 3 read 128 bytes<br> "Ehnt\^A\0\0\0\M^@\0\0\0>\0\0\0\0\0\0\0=\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\<br>
\0\0\0\0\0\0\0"<br> 2424 luajit RET read 128/0x80<br> 2424 luajit CALL lseek(0x3,0,0x80,SEEK_SET)<br> 2424 luajit RET lseek 128/0x80<br> 2424 luajit CALL read(0x3,0x800697180,0x3e)<br> 2424 luajit GIO fd 3 read 62 bytes<br>
"/usr/lib:/usr/lib/compat:/usr/local/lib:/usr/local/lib/event2\0"<br> 2424 luajit RET read 62/0x3e<br> 2424 luajit CALL close(0x3)<br> 2424 luajit RET close 0<br> 2424 luajit CALL access(0x80069a000,F_OK)<br>
2424 luajit NAMI "/usr/lib/libm.so.4"<br> 2424 luajit RET access 0<br> 2424 luajit CALL open(0x800699040,O_CLOEXEC,<unused>0x8)<br> 2424 luajit NAMI "/usr/lib/libm.so.4"<br> 2424 luajit RET open 3<br>
2424 luajit CALL fstat(0x3,0x7fffffffef70)<br> 2424 luajit RET fstat 0<br> 2424 luajit CALL mmap(0,0x1000,PROT_READ,MAP_PRIVATE,0x3,0,0)<br> 2424 luajit RET mmap 6934528/0x69d000<br> 2424 luajit CALL mmap(0,0x22a000,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,0xffffffff,0,0)<br>
2424 luajit RET mmap 9027584/0x89c000<br> 2424 luajit CALL mmap(0x80089c000,0x2a000,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,0x3,0,0)<br> 2424 luajit RET mmap 9027584/0x89c000<br> 2424 luajit CALL mmap(0x800ac5000,0x1000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,0x3,0,0x29000)<br>
2424 luajit RET mmap 11292672/0xac5000<br> 2424 luajit CALL munmap(0x80069d000,0x1000)<br> 2424 luajit RET munmap 0<br> 2424 luajit CALL close(0x3)<br> 2424 luajit RET close 0<br> 2424 luajit CALL access(0x80069a000,F_OK)<br>
2424 luajit NAMI "/usr/lib/gcc47/libc.so.8"<br> 2424 luajit RET access -1 errno 2 No such file or directory<br> 2424 luajit CALL access(0x80069a000,F_OK)<br> 2424 luajit NAMI "/usr/lib/libc.so.8"<br>
2424 luajit RET access 0<br> 2424 luajit CALL open(0x800699080,O_CLOEXEC,<unused>0x8)<br> 2424 luajit NAMI "/usr/lib/libc.so.8"<br> 2424 luajit RET open 3<br> 2424 luajit CALL fstat(0x3,0x7fffffffef70)<br>
2424 luajit RET fstat 0<br> 2424 luajit CALL mmap(0,0x1000,PROT_READ,MAP_PRIVATE,0x3,0,0)<br> 2424 luajit RET mmap 6934528/0x69d000<br> 2424 luajit CALL mmap(0,0x34e000,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,0xffffffff,0,0)<br>
2424 luajit RET mmap 11296768/0xac6000<br> 2424 luajit CALL mmap(0x800ac6000,0x123000,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,0x3,0,0)<br> 2424 luajit RET mmap 11296768/0xac6000<br> 2424 luajit CALL mmap(0x800de9000,0xc000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,0x3,0,0x123000)<br>
2424 luajit RET mmap 14585856/0xde9000<br> 2424 luajit CALL mmap(0x800df5000,0x1f000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,0xffffffff,0,0)<br> 2424 luajit RET mmap 14635008/0xdf5000<br> 2424 luajit CALL munmap(0x80069d000,0x1000)<br>
2424 luajit RET munmap 0<br> 2424 luajit CALL close(0x3)<br> 2424 luajit RET close 0<br> 2424 luajit CALL mmap(0,0x19000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0x800000000,0)<br> 2424 luajit RET mmap 6934528/0x69d000<br>
2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff880)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL set_tls_area(0,0x7ffffffff960,0x10)<br>
2424 luajit RET set_tls_area 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff8b0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br>
2424 luajit CALL issetugid<br> 2424 luajit RET issetugid 0<br> 2424 luajit CALL open(0x800bbf388,O_RDONLY,<unused>0xfffffffffffffff7)<br> 2424 luajit NAMI "/dev/urandom"<br> 2424 luajit RET open 3<br>
2424 luajit CALL read(0x3,0x800df5ea0,0x40)<br> 2424 luajit GIO fd 3 read 64 bytes<br> "Sk\M-X\M-vH\M-s\r\M-y\b1C?\M^JeWt\M-Sq\M-L,\M-w:P\M-*\^U\M^Q$\M-uV/\M^@\M-+q\M-\\M^Z\^]\M^W?\\_1\M-d^\M-S\^C\^R\<br>
f\M-3[\M-%\M^OE\^R\M-h\M-T\M-A\M-NBm+\M-kX\M^Ym"<br> 2424 luajit RET read 64/0x40<br> 2424 luajit CALL close(0x3)<br> 2424 luajit RET close 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff870)<br>
2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff870)<br> 2424 luajit RET sigprocmask 0<br>
2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff870)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br>
2424 luajit RET sigprocmask 0<br> 2424 luajit CALL setrlimit(RLIMIT_DATA,0x7ffffffff910)<br> 2424 luajit RET setrlimit 0<br> 2424 luajit CALL mmap(0x10000000,0x20000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0,0)<br>
2424 luajit RET mmap 7036928/0x6b6000<br> 2424 luajit CALL munmap(0x8006b6000,0x20000)<br> 2424 luajit RET munmap 0<br> 2424 luajit CALL mmap(0x10000000,0x20000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,0xffffffff,0,0)<br>
2424 luajit RET mmap 7036928/0x6b6000<br> 2424 luajit CALL munmap(0x8006b6000,0x20000)<br> 2424 luajit RET munmap 0<br> 2424 luajit CALL write(0x2,0x7ffffffff230,0xa)<br> 2424 luajit GIO fd 2 wrote 10 bytes<br>
"./luajit: "<br> 2424 luajit RET write 10/0xa<br> 2424 luajit CALL write(0x2,0x7ffffffff230,0x27)<br> 2424 luajit GIO fd 2 wrote 39 bytes<br> "cannot create state: not enough memory<br>
"<br> 2424 luajit RET write 39/0x27<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff820)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br>
2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff7c0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br>
2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff7c0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_BLOCK,0x800897a10,0x7ffffffff7c0)<br>
2424 luajit RET sigprocmask 0<br> 2424 luajit CALL sigprocmask(SIG_SETMASK,0x800897a30,0)<br> 2424 luajit RET sigprocmask 0<br> 2424 luajit CALL exit(0x1)<br><br><div><div><br></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-02-15 15:26 GMT+08:00 Alex Hornung <span dir="ltr"><<a href="mailto:alex@alexhornung.com" target="_blank">alex@alexhornung.com</a>></span>:<div><div><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div>
On 15/02/14 07:24, lhmwzy wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div>I make buildworld and make kernel after your fix<br>
</div>
But the luajit won't work unless use John Marino'patch<br>
</div>
</blockquote></div>
What does 'doesn't work' mean? You still need to add a ||
defined(__DragonFly__) if you don't use marino's patch. That should
then build and work fine.<br>
<br>
Cheers,<br>
Alex<div><br>
<br>
<blockquote type="cite">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-02-15 15:21 GMT+08:00 Alex Hornung
<span dir="ltr"><<a href="mailto:alex@alexhornung.com" target="_blank">alex@alexhornung.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div> <br>
<div>On 15/02/14 02:07, lhmwzy wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>To use this fix<br>
</div>
buildworld or buildkernel is needed?<br>
</div>
</blockquote>
<br>
</div>
You need to rebuild the kernel for this to work.
<div>
<div><br>
<br>
<blockquote type="cite">
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014-02-15 4:59 GMT+08:00
Alex Hornung <span dir="ltr"><<a href="mailto:alexh@crater.dragonflybsd.org" target="_blank">alexh@crater.dragonflybsd.org</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
commit
d9c783bb278bae8373395931126396bb6d6cdd71<br>
Author: Alex Hornung <<a href="mailto:alex@alexhornung.com" target="_blank">alex@alexhornung.com</a>><br>
Date: Fri Feb 14 20:57:16 2014 +0000<br>
<br>
mmap - honour hint address (properly) even
if randomization is on<br>
<br>
Summary of changes:<br>
sys/vm/vm_map.c | 5 +----<br>
1 file changed, 1 insertion(+), 4
deletions(-)<br>
<br>
<a href="http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/d9c783bb278bae8373395931126396bb6d6cdd71" target="_blank">http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/d9c783bb278bae8373395931126396bb6d6cdd71</a><br>
<span><font color="#888888"><br>
<br>
--<br>
DragonFly BSD source repository<br>
</font></span></blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div></div>
</blockquote></div></div></div><br></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div>