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

Marshal.Closures vs native OCaml DLL #7839

Open
vicuna opened this issue Aug 17, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link

commented Aug 17, 2018

Original bug ID: 7839
Reporter: db
Status: new
Resolution: open
Priority: normal
Severity: minor
Platform: x86
OS: Windows
Version: 4.07.0
Category: runtime system and C interface
Monitored by: @nojb @gasche

Bug description

I thought it should always be possible to marshal/unmarshal closures from/to the same OCaml program (with Marshal.Closures flag). Unfortunately, if OCaml system is placed into a DLL that is loaded into a main exe written in another language, this becomes problematic. Non-PIC OCaml code contains relocations that will be resolved to different addresses depending on the DLL base address (assigned by OS DLL loader). Then code fragment digests will also be different and Marshal.from_* functions will fail.

I realize this is quite rare case (most people nowadays use x64 PIC code that is not affected) but IMHO it should be at least documented (if not fixed).

@vicuna

This comment has been minimized.

Copy link
Author

commented Aug 22, 2018

Comment author: @stedolan

Are you describing a situation where code written in OCaml is compiled as non-PIC, but the runtime system is placed in a DLL? If so, I'm surprised that's even possible.

@vicuna

This comment has been minimized.

Copy link
Author

commented Aug 22, 2018

Comment author: db

Why not? Under Windows (my case) you don't have PIC at all, under Linux/x86 PIC is not required for DLLs, just recommended. Only Linux/x64 prohibits to link non-PIC code into a DLL.

@vicuna vicuna added the stdlib label Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.