Ticket #174 (closed defect: fixed)
crash under mod_python (duplicate symbols)
| Reported by: | gh | Owned by: | gh |
|---|---|---|---|
| Priority: | medium | Milestone: | |
| Component: | implementation | Version: | pysqlite-2.3.2 |
| Severity: | serious | Keywords: | |
| Cc: | geert@… |
Description
I ran into a problem when running pysqlite version 2.3.2 under mod_python in Apache. Basically an application that was using pysqlite (Trac) segfaulted at the first web request.
After a bit of investigation, it turned out there is a symbol clash. pysqlite defines a global function called cache_init(), which is also defined by Apache's mod_cache module. It turned out that when a pysqlite "Cache" object was constructed, the mod_cache cache_init() function was called. Needless to say this did not work very well.
In general I think that any shared library should try to export only those symbols that form part of the public API, such as to prevent naming clashes. Newer versions of gcc appear to have a -fvisibility=hidden switch that can achieve this, but I don't know whether that is available everywhere. For now I've fixed the problem by declaring cache_init() as "static" in pysqlite. The patch below does that, and also declares 3 more symbols in the same file as static. It also removes an erroneous "extern" keyword from a function definition.
I believe it is a good idea to apply this patch, but I also think it would be useful to go through the entire pysqlite source and see if more functions can be made static. An even more useful thing would be to investigate the use of -fvisibility=hidden.
