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

Printf module and DLL creation #3409

Closed
vicuna opened this issue Dec 31, 2004 · 1 comment
Closed

Printf module and DLL creation #3409

vicuna opened this issue Dec 31, 2004 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Dec 31, 2004

Original bug ID: 3409
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Matthieu Dubuget
Version: ocaml-3.08.2-win-msvc.exe
OS: Windows XP Pro
Submission from: dyn-83-156-145-233.ppp.tiscali.fr (83.156.145.233)

#!/bin/bash

This bug (?) report is also a shell script

Please, run inside a void directory, since it

creates some files.

I used it on Windows XP pro with cygwin shell.

I experienced the very same problem with Windows 98.

I'm not sure wether this is a bug or a bad using of

compilation tools?

The problem is that if i use a function from Printf

module inside a ocaml dll, the final program using this

DLL crashes (on caml_startup call).

Even if the funtion is nether called, which is the case

here.

If I replace the second line of the dac.ml file

with print_int dac, for example, it does not crash.

----------DAC.ML-------------

cat > dac.ml <<EOF
let affiche dac =
Printf.printf "%d\n" dac
EOF

----------MS_DAC.H-------------

cat > ms_dac.h <<EOF
void ms_dac_init ();
int ms_dac_init_ok (void);
EOF

----------MS_DAC2.C-------------

cat > ms_dac2.c <<EOF
#include "ms_dac.h"
#include <caml/callback.h>

static int ms_dac_init_done = 0;

void ms_dac_init (){
char *vide = 0l;
if (!ms_dac_init_done){
caml_startup (&vide);
ms_dac_init_done = 1;
}
}
int ms_dac_init_ok (void){
return ms_dac_init_done;
}
EOF

----------MS_DAC.DEF-------------

cat > ms_dac.def <<EOF
EXPORTS
ms_dac_init
ms_dac_init_ok
EOF

----------T.C-------------

cat > t.c <<EOF
#include <stdio.h>
#include "ms_dac.h"

int main (){
int ok;
ok = ms_dac_init_ok();
printf ("%d\n",ok);
fflush(stdout);
ms_dac_init();
ok = ms_dac_init_ok();
printf ("%d\n",ok);
fflush(stdout);
return 0;
}
EOF

Here are the commands I use to produce

my test program.

ocamlopt -output-obj -o dacl.obj dac.ml
ocamlopt -c ms_dac2.c
link -nologo -dll -out:ms_dac.dll -def:ms_dac.def dacl.obj ms_dac2.obj
-libpath:"c:\ocaml\lib" libasmrun.lib
cl -o t.exe -nologo -Ox -MT ms_dac.lib t.c
rm dac* ms* t.c t.obj

Just run the t.exe program to reproduce the bug.

Thanks for the wonderfull ocaml.

I hope this report is not noise, and won't let you loose your time

Salutations

@vicuna
Copy link
Author

vicuna commented Jan 27, 2005

Comment author: administrator

see also #3444
fixed DD 2005-01-27

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

No branches or pull requests

1 participant