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

Width of int type. #23

Open
aherrmann opened this issue Jul 13, 2018 · 3 comments
Open

Width of int type. #23

aherrmann opened this issue Jul 13, 2018 · 3 comments

Comments

@aherrmann
Copy link
Contributor

The width of the type int differs between evaluation and protobufs encoding. The protobufs encoding uses int32, the evaluator uses a wider type.

E.g. the following program (int_max + 1)

2147483647 + 1

Produces the following log on the server (no overflow):

2018-07-13 15:23:11 +00:00: INF [application] Process and eval: (fun (in[s: Cstruct.t list)
                                      -> (fun (outs: Cstruct.t list)
                                           -> (2147483647 + 1))) => 2147483648.

But returns the value -2147483648 (overflow).

These should probably agree to avoid subtle bugs when interacting with the server.

@dinosaure
Copy link
Member

Your computer is in 32-bits architecture?

@aherrmann
Copy link
Contributor Author

aherrmann commented Jul 23, 2018

Your computer is in 32-bits architecture?

No, 64 bit. Could it be due to the build in the Docker container?

Sorry, replied too quickly. The protobufs encoding specifies to use int32 for Int values. The mirage server has 64-bit wide int values, so when encoding int64 to int32 there's potential for overflow.

@dinosaure
Copy link
Member

Hmmhmm, I don't know what we can do about that when the problem seems to come from protobuf. Do you want a specific behavior from the unikernel about that? Note than in OCaml (in 64 bits architecture), the integer has 63 bits available - so if you want a 64 bits integer, it's better to use int64 (however, this value is boxed at the runtime).

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