Ticket #174 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

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.

Attachments

pysqlite-2.3.2-symbol-clash.patch (1.5 kB) - added by gh 2 years ago.

Change History

Changed 2 years ago by gh

Changed 2 years ago by gh

  • status changed from new to assigned

Changed 2 years ago by gh

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in revision 296.

I will later try to make more things static. Because pysqlite needs to work with older gcc releases and on other platforms with other weird problems, I bit the bullet and applied a pysqlite_ prefix almost everywhere.

Now the weird problems with pysqlite and Apache should be fixed. I'm glad you found the root of the problem.

Note: See TracTickets for help on using tickets.