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

Running test on mac-os #37

Open
berserkr opened this issue Jul 14, 2017 · 5 comments
Open

Running test on mac-os #37

berserkr opened this issue Jul 14, 2017 · 5 comments

Comments

@berserkr
Copy link

berserkr commented Jul 14, 2017

I am getting segfaults with the current master branch on mac OS. Somehow the function ptr is not reference properly...

Platform:

Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Here is some debugging information:

There is a running process, kill it and restart?: [Y/n] yes
Process 25413 exited with status = 9 (0x00000009)
Process 25418 launched: './testnoham' (x86_64)
Running tests...
test_ntruprime_inv_int ✓
test_ntruprime_inv_poly ✓
testnoham was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 25418 stopped

  • thread test_key() stack date currupted #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000010000495a testnoham`test_mult_int at test_poly.c:82 [opt]
    79 NtruIntPoly a1 = {11, {-1, 1, 1, 0, -1, 0, 1, 0, 0, 1, -1}};
    80 NtruIntPoly b1 = {11, {14, 11, 26, 24, 14, 16, 30, 7, 25, 6, 19}};
    81 NtruIntPoly c1;
    -> 82 ntru_mult_int(&a1, &b1, &c1, 32-1);
    83 NtruIntPoly c1_exp = {11, {3, 25, -10, 21, 10, 7, 6, 7, 5, 29, -7}};
    84 valid &= equals_poly_mod(&c1_exp, &c1, 32);
    85
    (lldb) print ntru_mult_int
    (uint8_t (*)(NtruIntPoly *, NtruIntPoly *, NtruIntPoly *, uint16_t)) $0 = 0x0000000000000000
    (lldb) print &ntru_mult_int
    (uint8_t (**)(NtruIntPoly *, NtruIntPoly *, NtruIntPoly *, uint16_t)) $1 = 0x000000010000a328
    (lldb) print ntru_mult_int
    (uint8_t (
    )(NtruIntPoly *, NtruIntPoly *, NtruIntPoly *, uint16_t)) $2 = 0x0000000000000000
    (lldb) step
    Process 25418 stopped
  • thread test_key() stack date currupted #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
    error: memory read failed for 0x0
    (lldb) bt
  • thread test_key() stack date currupted #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)

It is as if the function ptr are not allocated: ntru_mult_int

I know for sure, it is hitting:

#elif __SSSE3__ ntru_mult_int = &ntru_mult_int_sse; ntru_mult_tern = ntru_mult_tern_sse; ntru_to_arr = ntru_to_arr_sse; ntru_mod_mask = ntru_mod_sse;

in poly.c, however, not sure what is going on :( Any ideas?

@pschlump
Copy link

I am seeing this issue also.
I have tested on Linux (ubuntu 16.04) and it is working. On Mac OS I have tried it with both
the clang compiler from Apple (XCode) and with gcc 7.1.0 and I get the same error.

@pschlump
Copy link

The problem is global variables that are re-declared in multiple places instead of declared once and then "extern" in other places. Specifically there are 5 function pointers in src/poly.h that need to be
extern in the .h file and then declared in src/poly.c.

I will have a pull request within a day - as soon as I have tested this across all the different architectures. The pull request will also allow for compilation with llvm (clang) on mac.

pschlump added a commit to pschlump/libntru that referenced this issue Jul 17, 2017
@berserkr
Copy link
Author

Working for me now after applying your changes @pschlump

@pschlump
Copy link

pschlump commented Aug 3, 2017

The reason for using the ifdef(s) in the code instead of just disabling SSE/AVX2 is because the problem is compile dependent - not mac-os dependent. I have not determined how to get the
clang compiler to generate/use SSE/AVX2 - the gcc compiler (not the fake gcc that ships with
apple's dev tools, but is actually clang) will compile the code correctly. There is no reason to
punish the people using gcc with bad performance when only the clang folks have the problem.

If somebody knows how to get SSE/AVX2 to work in clang please add a note to this and I will re-build
the pull request with that in it.

jserv pushed a commit to jserv/libntru that referenced this issue Aug 16, 2018
@mouse07410
Copy link

#47 fixes this and #46. Tested with GCC-10 and Clang-10.

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