[Vm-dev] RE: Linux vm

Schwab,Wilhelm K bschwab at anest.ufl.edu
Sun Aug 22 02:39:22 UTC 2010

It has been a long day, and it might not have needed to be so.  Within 15 minutes of seeing "undefined symbol: libusb_close" from dlerror(), I had the problem not only diagnosed but fixed; seeing the error in something related to USB support was enough to suggest I needed to link that library into the .so I was trying to load.  I was still guessing, but it was an educated guess based on a concrete lead.

Is there a way to get such diagnostic information without hacking the vm source?  If not, please consider the following as a proposed patch.  I have tried to strike a balance between seeing enough to make sense of errant plugin paths and giving detailed information about failures when given an absolute path.  Behavior changes (I intend/think) only if something won't load (it says what it was trying to do) and if the library is specified by absolute path, in which case it gives diagnostic output on any failure to load.


( Squeak-...-src/unix/vm/sqUnixExternalPrims.c )
static void *tryLoadModule(char *in, char *name)
  char path[PATH_MAX], *out= path;
  void *handle= 0;
  int c;
  while ((c= *in++) && ':' != c) {	/* copy next plugin path to path[] */
    switch (c) {
    case '%':
      if ('n' == *in || 'N' == *in) {	/* replace %n with name of plugin */
	strcpy(out, name);
	out += strlen(name);
      if ('%' == *in) {
	*out++= '%';
      /* fall through... */
      *out++= c;
  sprintf(out, "/" MODULE_PREFIX "%s" MODULE_SUFFIX, name);
  handle= dlopen(path, RTLD_NOW | RTLD_GLOBAL);
  fdebugf((stderr, "tryLoading(%s) = %p\n", path, handle));

 	// 8-10 wks - no silent failures
	if( !handle ){
		// 8-10 - if a load fails, tell the user what we tried to load:
		fprintf(stdout, "Load failed for: %s\n", path);

		// 8-10 - is the given path absolute?  If so, try again with it
		// as given and report diagnostic information if it fails.
		if( (int)(name[0])==47 ) {
			handle=dlopen(name, RTLD_NOW | RTLD_GLOBAL);
			fprintf(stdout, "Load-by-name(%s) = %p\n", name, handle);
				fprintf(stdout,"Error loading library: %s\n",dlerror());

  if (!handle) {
    struct stat buf;
    if ((0 == stat(path, &buf)) && ! S_ISDIR(buf.st_mode))
      fprintf(stderr, "%s\n", dlerror());

  return handle;

From: pharo-project-bounces at lists.gforge.inria.fr [pharo-project-bounces at lists.gforge.inria.fr] On Behalf Of Schwab,Wilhelm K [bschwab at anest.ufl.edu]
Sent: Saturday, August 21, 2010 8:19 PM
To: Pharo-project at lists.gforge.inria.fr; vm-dev at lists.squeakfoundation.org
Subject: [Pharo-project] Linux vm

Hello all,

Is there a way to get the pre-compiled linux vm to describe what the full path is to a library it is trying to load?    I can hack the source to do so, but then I start wondering what I might have disturbed in the process.  Out of the box, all I get is an external library with a nil handle and no clue what did or did not happen.

At various points in my struggle today, I saw what looked like a tendency to load plugins from the vmpath//so.pluginName (two slashes rather than one).  It raises the question of whether the code is adding an extra slash when it is not given an explicit plugins path??  The separate concern is that I need information about what is happening when one of my libraries fails to load.

One possibility is that a particular .so can't load.  How would I find out whether that this is case?  Is there a way to test load it or to get the vm to tell me the cause of a failure to load it?


Pharo-project mailing list
Pharo-project at lists.gforge.inria.fr

More information about the Vm-dev mailing list