-
Notifications
You must be signed in to change notification settings - Fork 10
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
serialization: provide deserialize-info from toplevel modules #59
Conversation
This change makes it so that the following program runs successfully after being converted to an executable using `raco exe`: #lang racket/base (require gregor racket/serialize) (deserialize (serialize (current-time))) (deserialize (serialize (today))) (deserialize (serialize (now/moment))) As it stands, the deserialization process fails to look up the `deserialization-info` submodules in an exe. On failure, that process then has a fallback that looks at the toplevel module where the struct is declared to get the info. So, this change fixes the issue by providing the info directly from the toplevel modules in addition to the `deserialization-info` submodules. See racket/racket#4967 for more details.
I don't actually know how all this works but if I'm reading the linked issue correctly, is the problem simply that there is no depenency from the gregor top-level module to the submodule that has the provide of the deserialize information and thus raco exe doesn't add the submodule? If that's the case, would it work to make a |
I think moving the struct into a (module-path-index-resolve
(module-path-index-join
'(submod "." deserialize-info)
(module-path-index-join
'(lib "gregor/private/datetime.rkt") #f))) which, in a regular module resolves to
and can be
which is different from the embedded path above, so the |
Okay! Thank you! |
IIUC, the same problem will affect lots of other serializable structures, I think including those using |
Uses of |
Digging a little deeper into the embedding code, I think this section of code in the embedded exe module resolver is what makes the |
I know very little about the implementation of serialization in Racket, so maybe I'm off-base here, but this really sounds like a problem with the serialization code. Is that not the case? |
I don't think the serialization code can do much better than it currently does here. The issue is that, fundamentally, to deserialize a piece of serialized data, a module has to be looked up at runtime to discover the deserialization info. In an exe, the submodule by which the deserialize info is looked up is not going to be resolvable unless there is a dependency on it as recorded by something like I think this approach is in line with how other dependencies get recorded for runtime and for executable distribution (i.e. |
Ah, okay. I don't really understand why locating deserialization info should require looking up a module at runtime. When I wrote the serialization code, I was following examples (though I'm no longer sure which examples, since the ones I see now in the reference look different and don't use a submodule). But given that it does need to look up a module at runtime, I agree with you. Thanks for the patch! |
Along those lines, |
This change makes it so that the following program runs successfully after being converted to an executable using
raco exe
:As it stands, the deserialization process fails to look up the
deserialization-info
submodules in an exe. On failure, that process then has a fallback that looks at the toplevel module where the struct is declared to get the info. So, this change fixes the issue by providing the info directly from the toplevel modules in addition to thedeserialization-info
submodules.See racket/racket#4967 for more details.