• Bug#1063446: libmozjs-115-dev: cannot call JS::CanonicalizeNaN(double)

    From Simon McVittie@21:1/5 to Simon McVittie on Thu Feb 8 12:00:01 2024
    On Thu, 08 Feb 2024 at 10:37:33 +0000, Simon McVittie wrote:
    Simplified steps to reproduce:
    Try to compile the attached, with:
    g++ test.cpp -o test $(pkgconf --cflags --libs mozjs-115)

    Oops, really attached now.

    I'm preparing a possible patch (but it will take a long time to test,
    because compiling mozjs on mips64el is extremely slow).

    Untested patch attached. I'm trying to build with this change on eberlin.

    smcv

    // Copyright 2024 Simon McVittie
    // SPDX-License-Identifier: MIT

    #include <cinttypes>
    #include <cstdio>

    #include <jsapi.h>
    #include <js/Initialization.h>

    int main(int argc, char** argv)
    {
    // Smoke-test
    const char* reason = JS_InitWithFailureDiagnostic();
    if (reason) {
    std::fprintf(stderr, "Fatal error: %s\n", reason);
    return 1;
    }
    JSContext* cx = JS_NewContext(32 * 1024 * 1024);

    // https://bugs.debian.org/1063446
    uint64_t u64;
    double d = JS::CanonicalizeNaN(0.0/0.0);
    static_assert(sizeof(u64) == sizeof(d));
    memcpy(&u64, &d, sizeof(d));
    std::printf("Representation of a canonicalized NaN: %" PRIx64 "\n", u64);

    JS_DestroyContext(cx);
    JS_ShutDown();
    return 0;
    }

    From ac5a01642f111e88cb80aa54b1ee438b3bc6d07e Mon Sep 17 00:00:00 2001
    From: Simon McVittie <smcv@debian.org>
    Date: Thu, 8 Feb 2024 10:36:53 +0000
    Subject: [PATCH] Export js::detail::CanonicalizedNaNBits on architectures that
    use it

    Otherwise the inline function JS::CanonicalizeNaN(double), which is
    called by gjs, cannot validly refer to it.

    Bug-Debian: https://bugs.debian.org/1063446
    Signed-off-by: Simon McVittie <smcv@debian.org>

    Gbp-Pq: Name Export-js-detail-CanonicalizedNaNBits-on-architectures-th.patch ---
    js/public/Value.h | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/js/public/Value.h b/js/public/Value.h
    index de8db0fed8..d934b59dd4 100644
    --- a/js/public/Value.h
    +++ b/js/public/Value.h
    @@ -445,7 +445,7 @@ constexpr uint64_t CanonicalizedNaNSignificand = 0x8000000000000;
    #endif

    #if defined(JS_RUNTIME_CANONICAL_NAN)
    -extern uint64_t CanonicalizedNaNBits;
    +extern JS_PUBLIC_DATA uint64_t CanonicalizedNaNBits;
    #else
    constexpr uint64_t CanonicalizedNaNBits =
    mozilla::SpecificNaNBits<double, detail::CanonicalizedNaNSignBit,
    --
    2.43.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Simon McVittie on Thu Feb 8 22:10:01 2024
    On Thu, 08 Feb 2024 at 10:37:33 +0000, Simon McVittie wrote:
    Package: libmozjs-115-dev
    Justification: makes gjs FTBFS (#1063433)

    I believe mozjs115_115.7.0-3 should fix this.

    wb-team: Please could someone with wanna-build access schedule gjs
    on mips64el to be built after the fixed version of mozjs115 becomes
    available? I believe the correct spelling is:

    dw gjs_1.78.3-1 . unstable . mips64el . -m 'libmozjs-115-dev (>= 115.7.0-3)'

    mips team, or mozjs experts: Please could someone look into upstreaming
    the attached mips-specific patch?

    Thanks,
    smcv

    From: Simon McVittie <smcv@debian.org>
    Date: Thu, 8 Feb 2024 10:36:53 +0000
    Subject: Export js::detail::CanonicalizedNaNBits on architectures that use it

    Otherwise the inline function JS::CanonicalizeNaN(double), which is
    called by gjs, cannot validly refer to it.

    Bug-Debian: https://bugs.debian.org/1063446
    Signed-off-by: Simon McVittie <smcv@debian.org>
    ---
    js/public/Value.h | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/js/public/Value.h b/js/public/Value.h
    index de8db0f..d934b59 100644
    --- a/js/public/Value.h
    +++ b/js/public/Value.h
    @@ -445,7 +445,7 @@ constexpr uint64_t CanonicalizedNaNSignificand = 0x8000000000000;
    #endif

    #if defined(JS_RUNTIME_CANONICAL_NAN)
    -extern uint64_t CanonicalizedNaNBits;
    +extern JS_PUBLIC_DATA uint64_t CanonicalizedNaNBits;
    #else
    constexpr uint64_t CanonicalizedNaNBits =
    mozilla::SpecificNaNBits<double, detail::CanonicalizedNaNSignBit,

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)