[Theora-dev] linking, exported symbols
msmith at fluendo.com
Wed Aug 3 05:14:22 PDT 2005
I've got an application here (flumotion) which uses libtheora (via
gstreamer, though I think that's irrelevant here) and many other bits of
code, one of which is PIL (Python Imaging Library), which also has
chunks implemented in native code.
When I run this, I get a crash in libtheora, the top of the stacktrace
#0 0xb6a71bbf in quantize ()
#1 0xb6906fcd in TransformQuantizeBlock () from /usr/lib/libtheora.so.0
#2 0xb69073ab in TransformQuantizeBlock () from /usr/lib/libtheora.so.0
#3 0xb6907830 in EncodeData () from /usr/lib/libtheora.so.0
#4 0xb6909cef in WriteFrameHeader () from /usr/lib/libtheora.so.0
#5 0xb690aaf1 in theora_encode_YUVin () from /usr/lib/libtheora.so.0
#6 0xb6922b8a in theora_enc_chain (pad=0x83c34f8, data=0x81b3db0) at
#7 0xb79c80d5 in gst_pad_call_chain_function (pad=0x83c34f8,
data=0x81b3db0) at gstpad.c:4539
Here, we see that either I'm terribly confused, or gdb is, or libtheora
is calling quantize() in PIL's _imaging.so.
So, my guess at to what's going on is as follows: quantize() (in
quant.c) is called from TransformQuantizeBlock, which is normally fine.
However, because it's an exported symbol (because... well, everything
is), in this application that ends up getting resolved to a different
quantize() which has already been loaded.
So, I guess the problem (or at least one of them) is that we really
should only be exporting the API functions (theora_*), but because ELF
symbols are exported by default, we get all the internal symbols as
well. It's apparently possible to add a linker command line option to
make it only export symbols matching some particular regexp (which is
obviously much simpler than having to mess around with linker maps,
etc.), but I'd really like some feedback from someone with some actual
knowledge (rather than just random guessing) of ELF visibility, linking,
Is this analysis even vaguely plausible? If it isn't, any other
suggestions as to what might be going on?
More information about the Theora-dev