Re: [xml] Questions about libxml as a DLL on win32.

Hello there.

Basically a DLL has a boundary layer around it that enforces memory
allocation and deallocations to happen on the same side of the boundary.
Memory can be shared and read and written across this boundary, but
if it is allocated on one side of the boundary, it must be freed on the
same side of the boundary.

Hm... perhaps in Win95/98/ME, which I neither use nor understand. NT-kernel based
systems, such as WinNT and Win2k have a linear address space. What you are saying
is totally new to me. I doubt this is true. Can you point me to the official
documentation which describes this?

The function pointer nature of xmlFree ends up violating this memory
boundary layer of the DLL.  What ends up happening is that the xmlFree
pointer is initialized inside the DLL and therefore points to the deallocation
routine that is valid for the DLL.  However, when my code calls xmlFree
to free up strings allocated by libxml (xmlGetProp mainly) I get seg
faults (the windows equivalent) because my code is not allowed to execute
the DLL's memory deallocation routines.
So basically libxml has exported a pointer to an operating system protected
set of code that is only allowed to be used by the libxml DLL itself.

The function pointer is a variable exported from the library and can be accessed
by the client application at will. Wether it contains a valid function address or
not, depends on what client app writes into this variable. The address of the
function pointer, means the address of the exported variable itself, is in the
space designated for libxml by the dynamic loader.

Please double check what have you done, for I can neither understand nor
reproduce the problem here. If you cannot find the clue, please post a snippet of
code which shows how do you set the value of the exported function pointer (if
you do this) and how do you call the function through that pointer.

I use NT 4.0, and Win2000.  I use the Borland 5.5 free compiler to do
all of my NT development.  Which also, btw, means that I've ported libxml
to the borland 5.5 compiler environment to build the DLL.  If anybody's
interested, I can send my diff's to the list.

Nostalgia... Many days have passed since I have had the pleasure to use Borland's
5.x compiler. Of course you can send the diffs. If they don't conflict with
something else, noone shall object on applying them.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]