qdm12 / hbc

API of homomorphic binary operations such as binary comparisons or binary divisions using the library HElib
28 stars 5 forks source link

Segmentation Fault when running TEST_CIRC_SEQ and TEST_CIRC_ARITHM #3

Closed jepperson2 closed 7 years ago

jepperson2 commented 7 years ago

Downloaded and compiled HElib (most files last updated as of 30 Dec 2016) using GMP 6.1.2 and NTL 10.5.0. Though it took some fiddling to get everything set up (some troubles with tr1 libraries trying to be used and not being able to be found), Test_General runs properly and everything seems to be smooth sailing on that front.

Heard about hbc tried to integrate it to use the comparator and division functions. Ran into trouble with TEST_CIRC_SEQ and TEST_CIRC_ARITHM when running ./hbc. Compiled and built properly using HElib as described above along with adding flags to use std=c++11.

I believe the trouble may be coming from mismatches in NLT version expected (hbc mentions 9.9.0 and I have 10.5.0). I get an error stating: HE: copy: WARNING! This combined with some troubles I had with getting HElib to work makes me believe it's some issue with unordered_map or shared_ptr? Not quite sure yet...

This causes a seg fault I believe because the copy function passes back an empty new_map_key and the TESTs try to access some index in this empty mkt that doesn't exist.

The trouble is I'm not familiar enough with either NLT or hbc to have much success debugging this issue. Any help is appreciated :)

qdm12 commented 7 years ago

Just fixed it. I've updated pretty much everything also. It certainly works with the Ubuntu VM with Vagrant, and should work if you manually install everything by following the instructions of my readme.md. Please let me know if you have any other question, I'll be happy to help. Good luck !

jepperson2 commented 7 years ago

Thank you for your prompt response! I really appreciate the work you've put into this API.

I updated hbc with your most recent changes and tried again with the manual install I had been using and it had the same issue. As per your suggestion I used the Ubuntu VM with Vagrant and it worked! I checked to see how you compiled HElib and I think that may be the trouble I was having. When I compiled HElib I used: CFLAGS = -g -O2 -std=c++11 -pthread -DFHE_THREADS -DFHE_BOOT_THREADS -fmax-errors=2

Whereas the Vagrant file compiled it with CFLAGS = -g -O2 -std=c++11 -fmax-errors=2.

Because I don't need multi-threading at this point I will proceed with HElib compiled as is, but I may come back to fiddle with trying to get it to work with multi-threading enabled.

Cheers!

qdm12 commented 7 years ago

Ah that explains it. I will try with multi threading probably tomorrow. My code was developed without multi threading in mind so that might be why it doesn't work. Or it could be HElib failing as I've seen it failed a check when doing make check. I'll reopen the issue until I try to fix it at least. Thanks!

qdm12 commented 7 years ago

I just tested in the Vagrant box with the flags of the build for HElib CFLAGS = -g -O2 -std=c++11 -pthread -DFHE_THREADS -DFHE_BOOT_THREADS -fmax-errors=2, and recompiled everything from scratch and it appears to work still.

However you were right initially. This is from the comparison map_ctxts.find(k) == map_ctxts.end() line 30 in he.cpp which uses the unordered map from boost/unordered_map.hpp (see he.h). It must be because you failed to install libboost on your OS for some reason.

On the other hand, I am opened to modifications to replace the unordered map with a built-in structure of yours, that would be great. But as I recall I tried many times and I needed the properties of the unordered map for some reason. You'll have to dig a bit to find why as I can't really remember.

Hope that helps! Good luck! 😃