Bug#908137: luajit: lightuserdata problem with > 47 bit address space on arm64

2020-12-18 Thread Gianfranco Costamagna
control: tags -1 patch pending

NMU uploaded in sid

G.
On Mon, 5 Oct 2020 13:57:12 +0200 Santiago Ruano =?iso-8859-1?Q?Rinc=F3n?= 
 wrote:
> Control: tags -1 fixed-upstream
> 
> On Thu, 06 Sep 2018 16:54:30 +0300 Adrian Bunk  wrote:
> > Source: luajit
> > Version: 2.0.4+dfsg-1
> > Severity: serious
> > Forwarded: https://github.com/LuaJIT/LuaJIT/pull/230#issuecomment-260205661
> > 
> > This is an RFC regarding what to do for avoiding runtime
> > problems on arm64 like e.g. #907729.
> > 
> > The big hammer would be to drop luajit on arm64,
> > reverse dependencies are already able to cope
> > with luajit not available on s390x.
> > 
> > 
> 
> From the latest comment by upstream on the same PR
> https://github.com/LuaJIT/LuaJIT/pull/230#issuecomment-701054121
> it seems this has been fixed now. This is the relevant commit:
> https://github.com/LuaJIT/LuaJIT/commit/e9af1abec542e6f9851ff2368e7f196b6382a44c
diff -Nru luajit-2.1.0~beta3+dfsg/debian/changelog 
luajit-2.1.0~beta3+dfsg/debian/changelog
--- luajit-2.1.0~beta3+dfsg/debian/changelog2017-10-25 11:24:21.0 
+0200
+++ luajit-2.1.0~beta3+dfsg/debian/changelog2020-12-18 09:49:24.0 
+0100
@@ -1,3 +1,11 @@
+luajit (2.1.0~beta3+dfsg-5.2) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * debian/patches/e9af1abec542e6f9851ff2368e7f196b6382a44c.patch:
+- cherry-pick upstream fix for arm64 issue (Closes: #908137)
+
+ -- Gianfranco Costamagna   Fri, 18 Dec 2020 
09:49:24 +0100
+
 luajit (2.1.0~beta3+dfsg-5.1) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -Nru 
luajit-2.1.0~beta3+dfsg/debian/patches/e9af1abec542e6f9851ff2368e7f196b6382a44c.patch
 
luajit-2.1.0~beta3+dfsg/debian/patches/e9af1abec542e6f9851ff2368e7f196b6382a44c.patch
--- 
luajit-2.1.0~beta3+dfsg/debian/patches/e9af1abec542e6f9851ff2368e7f196b6382a44c.patch
   1970-01-01 01:00:00.0 +0100
+++ 
luajit-2.1.0~beta3+dfsg/debian/patches/e9af1abec542e6f9851ff2368e7f196b6382a44c.patch
   2020-12-18 09:49:24.0 +0100
@@ -0,0 +1,564 @@
+From e9af1abec542e6f9851ff2368e7f196b6382a44c Mon Sep 17 00:00:00 2001
+From: Mike Pall 
+Date: Wed, 30 Sep 2020 01:31:27 +0200
+Subject: [PATCH] Add support for full-range 64 bit lightuserdata.
+
+---
+ doc/status.html   | 11 -
+ src/jit/dump.lua  |  4 +++-
+ src/lib_debug.c   | 12 +-
+ src/lib_jit.c | 14 ++--
+ src/lib_package.c |  8 +++
+ src/lib_string.c  |  2 +-
+ src/lj_api.c  | 40 +
+ src/lj_ccall.c|  2 +-
+ src/lj_cconv.c|  2 +-
+ src/lj_crecord.c  |  6 ++---
+ src/lj_dispatch.c |  2 +-
+ src/lj_ir.c   |  6 +++--
+ src/lj_obj.c  |  5 +++--
+ src/lj_obj.h  | 57 ++-
+ src/lj_snap.c |  9 +++-
+ src/lj_state.c|  6 +
+ src/lj_strfmt.c   |  2 +-
+ 17 files changed, 121 insertions(+), 67 deletions(-)
+
+#diff --git a/doc/status.html b/doc/status.html
+#index 0aafe13a2..fd0ae8bae 100644
+#--- a/doc/status.html
+#+++ b/doc/status.html
+#@@ -91,17 +91,6 @@ Current Status
+# lua_atpanic on x64. This issue will be fixed with the new
+# garbage collector.
+# 
+#-
+#-LuaJIT on 64 bit systems provides a limited range of 47 bits for the
+#-legacy lightuserdata data type.
+#-This is only relevant on x64 systems which use the negative part of the
+#-virtual address space in user mode, e.g. Solaris/x64, and on ARM64 systems
+#-configured with a 48 bit or 52 bit VA.
+#-Avoid using lightuserdata to hold pointers that may point outside
+#-of that range, e.g. variables on the stack. In general, avoid this data
+#-type for new code and replace it with (much more performant) FFI bindings.
+#-FFI cdata pointers can address the full 64 bit range.
+#-
+# 
+# 
+# 
+Index: luajit/src/jit/dump.lua
+===
+--- luajit.orig/src/jit/dump.lua
 luajit/src/jit/dump.lua
+@@ -315,7 +315,9 @@
+   local tn = type(k)
+   local s
+   if tn == "number" then
+-if band(sn or 0, 0x3) ~= 0 then
++if t < 12 then
++  s = k == 0 and "NULL" or format("[0x%08x]", k)
++elseif band(sn or 0, 0x3) ~= 0 then
+   s = band(sn, 0x2) ~= 0 and "contpc" or "ftsz"
+ elseif k == 2^52+2^51 then
+   s = "bias"
+Index: luajit/src/lib_debug.c
+===
+--- luajit.orig/src/lib_debug.c
 luajit/src/lib_debug.c
+@@ -231,8 +231,8 @@
+   int32_t n = lj_lib_checkint(L, 2) - 1;
+   if ((uint32_t)n >= fn->l.nupvalues)
+ lj_err_arg(L, 2, LJ_ERR_IDXRNG);
+-  setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) :
+-  (void *)>c.upvalue[n]);
++  lua_pushlightuserdata(L, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) :
++ (void *)>c.upvalue[n]);
+   return 1;
+ }
+ 
+@@ -283,13 +283,13 @@
+ 
+ /*  */
+ 

Bug#908137: luajit: lightuserdata problem with > 47 bit address space on arm64

2020-10-05 Thread Santiago Ruano Rincón
Control: tags -1 fixed-upstream

On Thu, 06 Sep 2018 16:54:30 +0300 Adrian Bunk  wrote:
> Source: luajit
> Version: 2.0.4+dfsg-1
> Severity: serious
> Forwarded: https://github.com/LuaJIT/LuaJIT/pull/230#issuecomment-260205661
> 
> This is an RFC regarding what to do for avoiding runtime
> problems on arm64 like e.g. #907729.
> 
> The big hammer would be to drop luajit on arm64,
> reverse dependencies are already able to cope
> with luajit not available on s390x.
> 
> 

From the latest comment by upstream on the same PR
https://github.com/LuaJIT/LuaJIT/pull/230#issuecomment-701054121
it seems this has been fixed now. This is the relevant commit:
https://github.com/LuaJIT/LuaJIT/commit/e9af1abec542e6f9851ff2368e7f196b6382a44c


signature.asc
Description: PGP signature


Bug#908137: luajit: lightuserdata problem with > 47 bit address space on arm64

2018-09-06 Thread Adrian Bunk
Source: luajit
Version: 2.0.4+dfsg-1
Severity: serious
Forwarded: https://github.com/LuaJIT/LuaJIT/pull/230#issuecomment-260205661

This is an RFC regarding what to do for avoiding runtime
problems on arm64 like e.g. #907729.

The big hammer would be to drop luajit on arm64,
reverse dependencies are already able to cope
with luajit not available on s390x.