Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make test fails at 6.2 Numbers #1006

Open
mbamac opened this issue Oct 13, 2024 · 3 comments
Open

make test fails at 6.2 Numbers #1006

mbamac opened this issue Oct 13, 2024 · 3 comments

Comments

@mbamac
Copy link

mbamac commented Oct 13, 2024

on macOS Sequoia, M1 chip:

2 failures (0.9%).
FAIL: (/ -4611686018427387904 -1)
    expected 4611686018427387904 but got -4611686018427387904
    on line 910 of file "tests/r7rs-tests.scm"
FAIL: (quotient -4611686018427387904 -1)
    expected 4611686018427387904 but got -4611686018427387904
    on line 911 of file "tests/r7rs-tests.scm"
@SwitchAxe
Copy link

Disabling compiler optimizations with make XCFLAGS="-O0" fixes it for me on a M3 macbook air

@ashinn
Copy link
Owner

ashinn commented Jan 21, 2025

I can't reproduce this on Sonoma with an M1 chip.

Note these two cases are testing division of the most negative fixnum by -1, resulting in the smallest positive number which needs to be represented as a bignum. The relevant code for this case is in SEXP_OP_DIV in vm.c:

if ((sexp_sint_t)tmp1 < 0 && (sexp_sint_t)tmp2 < 0 && (sexp_sint_t)_ARG1 < 0) {
    _ARG1 = sexp_quotient(ctx, tmp1=sexp_fixnum_to_bignum(ctx, tmp1), tmp2);
}

i.e. in the (/ fixnum fixnum) path we check if both inputs are negative and the result is also negative, we recompute by converting the first input to a bignum. I can't debug this if I can't reproduce though...

@SwitchAxe
Copy link

I fear some undefined behavior may be the culprit... if i try with the apple-provided gcc (the one based on clang 16) the tests fail, but with homebrew gcc (i.e. upstream gcc 14.2.0 i suppose) all tests pass successfully, so @ashinn you may be able to reproduce this by using clang 16 (or its gcc frontend) as the compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants