You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1234 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
Ocaml: CVS version
camlidl: CVS version
OS: Windows 2000
The problem is that DllMain() in runtime/cfactory.cpp sets argv[0]
(executable name) to NULL:
CAMLexport value copy_string(char const *s)
{
int len;
value res;
len = strlen(s); //********** s == NULL here, so the function fails **********
res = alloc_string(len);
memmove(String_val(res), s, len);
return res;
}
Original bug ID: 1234
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues
Bug description
Ocaml: CVS version
camlidl: CVS version
OS: Windows 2000
The problem is that DllMain() in runtime/cfactory.cpp sets argv[0]
(executable name) to NULL:
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, void *reserved)
{
char * argv[1];
switch(reason) {
case DLL_PROCESS_ATTACH:
argv[0] = NULL; //********** executable name **********
camlidl_module_handle = (HMODULE) module;
#if 0
int fd = open("/tmp/camllog", O_RDWR|O_TRUNC|O_CREAT, _S_IWRITE|_S_IREAD);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
#endif
caml_startup(argv);
break;
/* TODO: free all memory when DLL detached */
}
return TRUE;
}
but this NULL is not acceptable by Sys module startup code:
CAMLprim value sys_get_argv(value unit)
{
CAMLparam0 (); /* unit is unused /
CAMLlocal3 (exe_name, argv, res);
exe_name = copy_string(caml_exe_name); //********* caml_exe_names == NULL **********
argv = copy_string_array((char const **) caml_main_argv);
res = alloc_small(2, 0);
Field(res, 0) = exe_name;
Field(res, 1) = argv;
CAMLreturn(res);
}
CAMLexport value copy_string(char const *s)
{
int len;
value res;
len = strlen(s); //********** s == NULL here, so the function fails **********
res = alloc_string(len);
memmove(String_val(res), s, len);
return res;
}
Here is the fix:
Index: cfactory.cpp
RCS file: /caml/bazar-ocaml/camlidl/runtime/cfactory.cpp,v
retrieving revision 1.8
diff -u -r1.8 cfactory.cpp
--- cfactory.cpp 2001/07/30 14:05:17 1.8
+++ cfactory.cpp 2002/07/13 16:06:59
@@ -26,6 +26,11 @@
#include "comstuff.h"
#include "registry.h"
+#ifdef CYGWIN32
+#include <sys/param.h>
+#define _MAX_PATH MAXPATHLEN
+#endif
+
/* Count of server locks */
static long camlidl_num_server_locks = 0;
@@ -173,13 +178,17 @@
/* DLL entry point */
+extern "C"
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, void *reserved)
{
char * argv[2];
char dll_path[_MAX_PATH];
switch(reason) {
case DLL_PROCESS_ATTACH:
camlidl_module_handle = (HMODULE) module;
#if 0
int fd = open("/tmp/camllog", O_RDWR|O_TRUNC|O_CREAT, _S_IWRITE|_S_IREAD);
Strange enough that the error only appears in the native code DLLs and that
I did not observed it before.
Hope to hear from you soon,
Dmitry
The text was updated successfully, but these errors were encountered: