[xsd-users] dlclose and xsd cxx-tree

Skunk Worx skunkworx at verizon.net
Fri Jul 13 01:32:38 EDT 2012


Hello,

I seem to be having a problem with xsd cxx-tree and dlclose(). I am 
trying xsd cxx-tree on an EPEL 6, x86_64 machine.

I've downloaded and installed the xsd-3.3.0-1.x86_64 RPM.

Suppose I have a schema Foo.xsd :

<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:mdl="FOO"
  xmlns="FOO"
  targetNamespace="FOO"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">

   <xsd:element name="Hello" type="xsd:string"/>

</xsd:schema>

...and I process it into .cxx, ,hxx files :

$ xsd cxx-tree Foo.xsd

...and compile it into a shared library :

$ g++ -fPIC -g -shared -o libFoo.so Foo.cxx -lxerces-c

...and create a simple main.cpp to dlopen / dlclose this library :

#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

int
main()
{
   static const char *lib="./libFoo.so";
   char cmd[1024];
   void *h;

   if((h=dlopen(lib,RTLD_NOW))==0) {
     printf("dlerror : %s\n",dlerror());
     exit(1);
   }

   if(dlclose(h)) {
     printf("dlerror : %s\n",dlerror());
     exit(1);
   }

   sprintf(cmd,"fuser %s",lib);
   system(cmd);

   exit(0);
}

...and compile the main program :

$ g++ -fPIC -g -o main main.cpp -ldl

...and run it :

$ ./main
./libFoo.so:          3326m

...why, after a successful dlclose(), is the .so still referenced in the 
application memory?

It is my understanding that this will result in an invalid .so 
initialization if the .so is subsequently reopened by the same 
application instance.

I suspect it is something in the "namespace xml_schema {}" area of the 
generated Foo.hxx file but I am not sure.

Thanks in advance for any insight!

---
John



More information about the xsd-users mailing list