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

CAMLprim returning void #5947

Closed
vicuna opened this issue Mar 12, 2013 · 3 comments
Closed

CAMLprim returning void #5947

vicuna opened this issue Mar 12, 2013 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Mar 12, 2013

Original bug ID: 5947
Reporter: bvaugon
Assigned to: @damiendoligez
Status: resolved (set by @damiendoligez on 2014-07-30T11:49:36Z)
Resolution: suspended
Priority: normal
Severity: minor
Version: 4.00.1
Category: otherlibs
Monitored by: @gasche

Bug description

Some C primitives of the OCaml otherlibs runtime returns void instead of ().
Some of them are declared "external" in some .ml files.
Obviously, it could cause a "Segmentation fault" if they are called from OCaml.

Steps to reproduce

To search these invalid functions, run:

$ grep -RIni 'CAMLprim void' otherlibs
otherlibs/labltk/support/cltkImg.c:78:CAMLprim void
otherlibs/labltk/support/cltkImg.c:112:CAMLprim void camltk_setimgdata_bytecode(argv,argn)
otherlibs/labltk/support/cltkCaml.c:66:CAMLprim void tk_error(char *errmsg)

Additional information

I think that "tk_error" is not an OCaml primitive, so you may just have to remove the CAMLprim attribute.

Functions camltk_setimgdata_bytecode and camltk_setimg_native are exported, so you just have to change signature and to return Val_unit.

@vicuna
Copy link
Author

vicuna commented Mar 18, 2013

Comment author: @garrigue

IIRC, the CAMLprim attribute on tk_error is to overcome restrictions on dependencies between DLLs on windows.
Namely other libraries, such as LablGL, need to access some utility functions from LablTk, and if they are not correctly flagged they are not avilable outside of the DLL.
(The maybe a better name that CAMLprim to do that, but I didn't check; actually CAMLprim is only used to register primitives in the byterun directory)

@vicuna
Copy link
Author

vicuna commented Jul 17, 2013

Comment author: @damiendoligez

About tk_error, as far as I know you are supposed to use CAMLexport rather than CAMLprim in that case. This will need to be tested.
About the others, we need to decide if they are like tk_error or if they are really primitives, in which case they must return "value" rather than "void".

@vicuna
Copy link
Author

vicuna commented Jul 30, 2014

Comment author: @damiendoligez

Labltk is now a separate package, so I've copied this PR to the labltk BTS on ocamlcore:
https://forge.ocamlcore.org/tracker/index.php?group_id=343&atid=1351

Closing the report here, please continue the discussion on ocamlcore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants