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

Server errors out when executing functions that return () #3

Open
Abhiroop opened this issue Jan 6, 2023 · 7 comments
Open

Server errors out when executing functions that return () #3

Abhiroop opened this issue Jan 6, 2023 · 7 comments

Comments

@Abhiroop
Copy link
Owner

Abhiroop commented Jan 6, 2023

The problem seems to be with sending the bytestring over TCP. It encodes () as a message with size 0 and the receiving Client does not like this and crashes with the error

EnclaveIFC-exe: Network.Socket.recvBuf: invalid argument (non-positive length)
@Rewbert
Copy link
Collaborator

Rewbert commented Jan 6, 2023

Lmao is this from the binary constraint? Sounds like a weird implementation choice of them

@Abhiroop
Copy link
Owner Author

Abhiroop commented Jan 6, 2023

Yeah, a silly implementation indeed. The Binary instance of () has this remark "The () type need never be written to disk: values of singleton type can be reconstructed from the type alone".

https://hackage.haskell.org/package/binary-0.8.9.1/docs/src/Data.Binary.Class.html#line-193

@Rewbert
Copy link
Collaborator

Rewbert commented Jan 6, 2023

It's not wrong I guess, but in this case I guess we evaluate () for its side effects. Maybe we can give our own instance somehow

@Abhiroop
Copy link
Owner Author

Abhiroop commented Jan 6, 2023

Defining a new instance would be the principled approach but worth some hassle (construct your own newtype, etc). My makeshift patch was to send \0 whenever the result evaluates to (). If the client tries to decode this then of course a can of worms open

@Abhiroop
Copy link
Owner Author

Abhiroop commented Jan 7, 2023

Temp patch - f889f6a

@Abhiroop
Copy link
Owner Author

This 491d579 should allow removing the temp patch.

@Abhiroop Abhiroop reopened this Jan 18, 2023
@Abhiroop
Copy link
Owner Author

(Needs testing before closing)

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

2 participants