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

fixed issues regarding unsigned comparison with 0 #20

Closed
wants to merge 2 commits into from

Conversation

lenerd
Copy link
Collaborator

@lenerd lenerd commented Mar 9, 2017

This should deal with some of the issues from #17.

I changed the return value in the error case, such that it returns the number of bytes received. Otherwise it would convert the negative error value to a positive number and use that.

@lenerd
Copy link
Collaborator Author

lenerd commented Mar 9, 2017

Well, it detects errors now.

Testing AES circuit in Boolean sharing
socket recv error: 9
Testing AES circuit in Boolean sharing
Socket error : Bad file descriptor
113.289	0.005	22.115	135.408	11511542	353600	42
116.729	0.004	22.024	138.757	11511551	353600	42
Testing AES circuit in Yao sharing
socket recv error: 9
Socket error : Bad file descriptor
socket recv error: 9
Socket error : Bad file descriptor
make: *** [runtest] Error 141

* check return values of open/close
* read, recv return signed values
* Send: call send in a loop, handle errors
* Receive: forward flags
* Receive: print message if socket is close by peer
@lenerd
Copy link
Collaborator Author

lenerd commented Mar 17, 2017

The Bad file descriptor errors are result of a data race: The main thread closes the socket while another thread is still reading from it.

Excerpt of ThreadSanitizer's output (there are some more races):

WARNING: ThreadSanitizer: data race (pid=26886)
  Write of size 8 at 0x7da000008040 by main thread:
    #0 close <null> (aes.exe+0x00000047016f)
    #1 CSocket::Close() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/../util/../util/socket.h:114:3 (aes.exe+0x0000005b6ad0)
    #2 ABYParty::Cleanup() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:144:18 (aes.exe+0x0000005b16f1)
    #3 ABYParty::~ABYParty() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:92:2 (aes.exe+0x0000005b1273)
    #4 test_aes_circuit(e_role, char*, SECURITYLEVELS, unsigned int, unsigned int, e_mt_gen_alg, e_sharing, unsigned short, bool, bool) /home/lennart/git/ABY/src/examples/aes/common/aescircuit.cpp:143:2 (aes.exe+0x0000004f9685)
    #5 main <null> (aes.exe+0x000000503885)

  Previous read of size 8 at 0x7da000008040 by thread T8:
    #0 recv <null> (aes.exe+0x00000048f951)
    #1 CSocket::Receive(void*, unsigned long, int) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/../util/../util/socket.h:273:10 (aes.exe+0x0000005bdac4)
    #2 RcvThread::ThreadMain() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/../ot/../util/rcvthread.h:124:14 (aes.exe+0x0000005bd6c4)
    #3 CThread::ThreadMainHandler(void*) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/ot/../util/thread.h:192:10 (aes.exe+0x00000050d852)

  Location is file descriptor 4 created by main thread at:
    #0 connect <null> (aes.exe+0x00000046fc1d)
    #1 CSocket::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned short, long) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/util/crypto/../socket.h:235:13 (aes.exe+0x0000005ccb31)
    #2 Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, short, std::vector<CSocket*, std::allocator<CSocket*> >&, int) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/util/connection.cpp:36:20 (aes.exe+0x0000005cba88)
    #3 ABYParty::ABYPartyConnect() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:512:9 (aes.exe+0x0000005b6338)
    #4 ABYParty::EstablishConnection() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:489:13 (aes.exe+0x0000005b0fd1)
    #5 ABYParty::ABYParty(e_role, char*, SECURITYLEVELS, unsigned int, unsigned int, e_mt_gen_alg, unsigned int, unsigned short) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:74:7 (aes.exe+0x0000005afe39)
    #6 test_aes_circuit(e_role, char*, SECURITYLEVELS, unsigned int, unsigned int, e_mt_gen_alg, e_sharing, unsigned short, bool, bool) /home/lennart/git/ABY/src/examples/aes/common/aescircuit.cpp:24:24 (aes.exe+0x0000004f8a0b)
    #7 main <null> (aes.exe+0x000000503885)

  Thread T8 (tid=26896, finished) created by main thread at:
    #0 pthread_create <null> (aes.exe+0x00000046b886)
    #1 CThread::Start() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/../ot/../util/thread.h:143:17 (aes.exe+0x0000005b11de)
    #2 ABYParty::EstablishConnection() /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:502 (aes.exe+0x0000005b11de)
    #3 ABYParty::ABYParty(e_role, char*, SECURITYLEVELS, unsigned int, unsigned int, e_mt_gen_alg, unsigned int, unsigned short) /home/lennart/git/ABY/src/examples/lowmc/../../abycore/aby/abyparty.cpp:74:7 (aes.exe+0x0000005afe39)
    #4 test_aes_circuit(e_role, char*, SECURITYLEVELS, unsigned int, unsigned int, e_mt_gen_alg, e_sharing, unsigned short, bool, bool) /home/lennart/git/ABY/src/examples/aes/common/aescircuit.cpp:24:24 (aes.exe+0x0000004f8a0b)
    #5 main <null> (aes.exe+0x000000503885)

SUMMARY: ThreadSanitizer: data race (/home/lennart/git/ABY/bin/aes.exe+0x47016f) in close

@dd23
Copy link
Member

dd23 commented Jun 30, 2017

Thanks for your PR.
I have manually merged your changes to ENCRYPTO_utils.
I'll look into the data races next.

@dd23 dd23 closed this Jun 30, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants