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

dlerror n'est pas tres bavard sur OS X #8441

Closed
vicuna opened this issue Jan 7, 2004 · 5 comments
Closed

dlerror n'est pas tres bavard sur OS X #8441

vicuna opened this issue Jan 7, 2004 · 5 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 7, 2004

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

Bug description

Full_Name: Paul Guyot
Version: 3.07pl2
OS: MacOS X
Submission from: fremicourt.kallisys.net (82.66.90.159)

caml_dlerror ne dit pas quelle est la bibliothèque (enfin, le bundle MacOS X)
qui échoue.

Voici une rustine pour corriger le problème:

----<
Index: unix.c

RCS file: /caml/ocaml/byterun/unix.c,v
retrieving revision 1.21
diff -u -r1.21 unix.c
--- unix.c 2004/01/03 20:55:41 1.21
+++ unix.c 2004/01/07 23:40:30
@@ -168,34 +168,52 @@
#ifdef HAS_NSLINKMODULE
/* Use MacOSX bundles */

-static char *dlerror_string = "No error";
+static char *dlerror_string = NULL;

void * caml_dlopen(char * libname)
{
NSObjectFileImage image;

  • char* theMessage = NULL;
    NSObjectFileImageReturnCode retCode =
    NSCreateObjectFileImageFromFile(libname, &image);
  • if (dlerror_string != NULL)
  • {
  • free( dlerror_string );
  • dlerror_string = NULL;
  • }
    switch (retCode) {
    case NSObjectFileImageSuccess:
    dlerror_string = NULL;
    return (void*)NSLinkModule(image, libname, NSLINKMODULE_OPTION_BINDNOW
    | NSLINKMODULE_OPTION_RETURN_ON_ERROR);
    case NSObjectFileImageAccess:
  • dlerror_string = "cannot access this bundle"; break;
  • theMessage = "cannot access this bundle"; break;
    case NSObjectFileImageArch:
  • dlerror_string = "this bundle has wrong CPU architecture"; break;
  • theMessage = "this bundle has wrong CPU architecture"; break;
    case NSObjectFileImageFormat:
    case NSObjectFileImageInappropriateFile:
  • dlerror_string = "this file is not a proper bundle"; break;
  • theMessage = "this file is not a proper bundle"; break;
    default:
  • dlerror_string = "could not read object file"; break;
  • theMessage = "could not read object file"; break;
    }
  • if (theMessage != NULL)
  • {
  • size_t theLength;
  • theLength = strlen( theMessage ) + strlen( libname ) + 4;
  •     /* space, (, ), terminator */
    
  • dlerror_string = malloc(theLength);
  • (void) sprintf( dlerror_string, "%s (%s)", theMessage, libname );
  • }
    return NULL;
    }

void caml_dlclose(void * handle)
{

  • dlerror_string = NULL;
  • if (dlerror_string != NULL)
  • {
  • free( dlerror_string );
  • dlerror_string = NULL;
  • }
    NSUnLinkModule((NSModule)handle, NSUNLINKMODULE_OPTION_NONE);
    }

@@ -204,7 +222,11 @@
NSSymbol sym;
char name[1000] = "";
strncat (_name, name, 998);

  • dlerror_string = NULL;
  • if (dlerror_string != NULL)
  • {
  • free( dlerror_string );
  • dlerror_string = NULL;
  • }
    sym = NSLookupSymbolInModule((NSModule)handle, _name);
    if (sym != NULL) return NSAddressOfSymbol(sym);
    else return NULL;
    ----<

Paul

@vicuna
Copy link
Author

vicuna commented Jun 22, 2004

Comment author: administrator

caml_dlerror ne dit pas quelle est la bibliothèque (enfin, le bundle MacOS X)
qui échoue.

Il m'a l'air suffisemment bavard (au moins dans la version CVS); par exemple
Fatal error: cannot load shared library dlllabltk
Reason: dyld: ocamlrun can't open library: /opt/local/lib/libtk8.4.dylib (No
such file or directory, errno = 2)

Il est possible qu'il y ait eu des changements depuis 3.07, mais je ne les vois
pas.

Jacques

@vicuna
Copy link
Author

vicuna commented Jun 22, 2004

Comment author: administrator

Message seems already sufficient... JG

@vicuna
Copy link
Author

vicuna commented Jun 22, 2004

Comment author: administrator

Bonjour Jacques,

Aux environs du 22/06/04 à 16:35 +0200, sous le titre "Re: dlerror
n'est pas tres bavard sur OS X (#8441)", Jacques Garrigue prit sa
plus belle plume pour écrire les mots suivants:

caml_dlerror ne dit pas quelle est la bibliothèque (enfin, le
bundle MacOS X)
qui échoue.

Il m'a l'air suffisemment bavard (au moins dans la version CVS); par exemple
Fatal error: cannot load shared library dlllabltk
Reason: dyld: ocamlrun can't open library: /opt/local/lib/libtk8.4.dylib (No
such file or directory, errno = 2)

Il est possible qu'il y ait eu des changements depuis 3.07, mais je
ne les vois
pas.

Utilises-tu la version DarwinPorts de ocaml par hasard? (je demande à
cause du chemin en /opt/local/).

Je parlais du code exécuté par caml_dlopen qu'on trouve dans
byterun/unix.c, autour de la ligne 173 de la version CVS.

On a l'un des messages suivants:

cannot access this bundle
this bundle has wrong CPU architecture
this file is not a proper bundle
could not read object file

ce qui n'est pas très limpide.

Le message que tu as eu a été obtenu à partir d'un vrai appel à
dlopen et non pas d'un appel à NSLinkModule.

Paul

Philosophie de baignoire - consultations sur rendez-vous.

NPDS/NewtonOS: http://newton.kallisys.net:8080/
Apache/FreeBSD: http://www.kallisys.com/

@vicuna
Copy link
Author

vicuna commented Jun 23, 2004

Comment author: administrator

From: pguyot@kallisys.net

Il m'a l'air suffisemment bavard (au moins dans la version CVS); par exemple
Fatal error: cannot load shared library dlllabltk
Reason: dyld: ocamlrun can't open library: /opt/local/lib/libtk8.4.dylib (No
such file or directory, errno = 2)

Utilises-tu la version DarwinPorts de ocaml par hasard? (je demande à
cause du chemin en /opt/local/).

Non, je compile ocaml moi-meme. Seul Tcl/Tk est installe' par
darwinports.

Je parlais du code exécuté par caml_dlopen qu'on trouve dans
byterun/unix.c, autour de la ligne 173 de la version CVS.

On a l'un des messages suivants:

cannot access this bundle
this bundle has wrong CPU architecture
this file is not a proper bundle
could not read object file

ce qui n'est pas très limpide.

J'ai mal choisi mon message: il s'agit d'un cas ou le bundle lui-meme
marche, mais ses dependences echouent. Par consequent, le message est
celui obtenu par NSLinkEditError.

Mais meme si le bundle n'est pas la`, et qu'on echoue dans
caml_dlopen, on a le nom du bundle.

Fatal error: cannot load shared library dlllabltk
Reason: cannot access this bundle

Le message ne semble pas avoir ete' change' recemment.

Jacques

@vicuna
Copy link
Author

vicuna commented Jun 23, 2004

Comment author: administrator

From: Paul Guyot pguyot@kallisys.net

Mais ton message ne donne pas le chemin du fichier et si tu es en
toplevel et que tu fais:

#directory "+labltk";;

#load "labltk.cma";;

tu n'as rien, juste "cannot access this bundle".

Voila enfin le cas genant!
Comme il me semble anormal d'avoir un message d'erreur moins
informatif pour le toplevel que pour un programme custom,
j'ai modifie topdirs.ml pour donner un message similaire, dans la
branche release308.

#load"labltk.cma";;

Cannot load required shared library dlllabltk.
Reason: cannot access this bundle.

Une question a` Xavier en passant: dll.mli n'exporte que la fonction
open_dlls, et pas open_dll. Je me retrouve a l'appeler avec des listes
singletons. Ne pourrait-on pas se debarasser d'open_dlls?

Jacques

@vicuna vicuna closed this as completed Jun 25, 2004
@vicuna vicuna added the bug label Mar 19, 2019
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