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

Trying to write a NULL struct #27

Open
Vaelatern opened this issue Sep 12, 2018 · 1 comment
Open

Trying to write a NULL struct #27

Vaelatern opened this issue Sep 12, 2018 · 1 comment

Comments

@Vaelatern
Copy link

I somehow can't leave it uninitialized, or I get,

*** ERROR DECODING PREVIOUS MESSAGE ***
The following error occurred while decoding the message above.
This probably means the input data is invalid/corrupted.
Exception description: expected boundsCheck(segment, ptr, ref->structRef.wordSize()); Message contained out-of-bounds struct pointer.
Code location: capnp/layout.c++:2159
*** END ERROR ***

From the capnp FAQ:

Pointer fields are a bit different. They start out “null”, and you can check for nullness using the hasFoo() accessor. You could use a null pointer to mean “not present”. Note, though, that calling getFoo() on a null pointer returns the default value, which is indistinguishable from a legitimate value, so checking hasFoo() is in fact the only way to detect nullness.

What do I need to do to not set a pointer?
Specifically, I sometimes do not set the worker field here: https://gitlab.com/dxpb/dxpb/blob/1b8775bd089ca3c2df1c53030ddb5adec7fa4313/src/log.capnp#L45-48

@Vaelatern
Copy link
Author

Vaelatern commented Sep 12, 2018

The responsible code for seeding an error is as follows:
https://gitlab.com/dxpb/dxpb/blob/1b8775bd089ca3c2df1c53030ddb5adec7fa4313/src/blog.c#L439-457

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

1 participant