I have library x. x uses functions from library y. Library x is used in program z.
y is linked to x at compile time, and likewise with program z and x.
z uses x through the dl interface.
Yet, when z uses x (leading to x calling y.), z crashes claiming: "free(): invalid next size (fast)".
Do I have to do something other than link x to y and x to z? Any knowledge as to why it's broken?
Thanks.
(I'm using Gentoo Linux, GCC 4.1.1, and LD 2.16.1)
Using Libraries within Libraries
Using Libraries within Libraries
C8H10N4O2 | #446691 | Trust the nodes.
The error message you get sounds like there's a bug somewhere. I guess it's from glibc malloc, but I can't seem to find that error message from the version I happen to have sources for, and don't feel like digging for the specific version so I'm just going to claim, based on the structure of the malloc used (derivative of dlmalloc) that there's a buffer overflow somewhere, and it detected a heap corruption.
You don't need to do anything special. If you just link a library, it'll drag all of it's own libraries with it. If you dlopen it, the same should happen, as per dlopen manpage:
But I could be wrong. Since you have Gentoo, you'll probably find all the relevant sources in /usr/portage/distfiles, so you could just unpack those somewhere, and grep for "invalid next size" or something like that to find where you got the error from...
You don't need to do anything special. If you just link a library, it'll drag all of it's own libraries with it. If you dlopen it, the same should happen, as per dlopen manpage:
As for the error message, there are sizes of blocks recorded before each block in dlmalloc. So when you free a block, it looks backward to see the size of the free'd block. It can also then the free'd block based on that size, and land just after that block, where it should find the size and status of the next block. It sounds like it found something that failed a sanity check..If the library has dependencies on other shared libraries, then these are also automatically loaded by the dynamic linker using the same rules. (This process may occur recursively, if those libraries in turn have dependencies, and so on.)
But I could be wrong. Since you have Gentoo, you'll probably find all the relevant sources in /usr/portage/distfiles, so you could just unpack those somewhere, and grep for "invalid next size" or something like that to find where you got the error from...
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.