Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#18090 closed defect (fixed)

python25 broken after [37817]

Reported by: rasmus@… Owned by: mww@…
Priority: Normal Milestone:
Component: ports Version: 1.7.0
Keywords: python dlopen environ patch portfile Cc: skymoo (Adam Mercer), blb@…, MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), mf2k (Frank Schima)
Port: python25 python26

Description

The merge [37817] broke python25 in the way that the patchfile patch-Misc-setuid-prog.c.diff was no longer used. This patch is critical since it provides the notorious environ-fix. This patch essentially defines environ, which is not present on OS X.

Without this patch, machine-native extensions referring to environ will not load. I.e. you will get this:

import _nativemodule
Traceback...
...
ImportError: dlopen(/opt/local...): Symbol not found: _environ

The required patch is here: trunk/dports/lang/python25/files/patch-Misc-setuid-prog.c.diff@45618

Attachments (1)

patch-posixmodule.c.diff (405 bytes) - added by skymoo (Adam Mercer) 15 years ago.
patch to Modules/posicmodule.c

Download all attachments as: .zip

Change History (16)

comment:1 Changed 15 years ago by rasmus@…

I have also tested this with latest python26 – same problem here.

The machine I've tested this and the problem mentioned in the ticket itself:
Darwin hostname 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386

comment:2 Changed 15 years ago by rasmus@…

Cc: rasmus@… added

Cc Me!

comment:3 Changed 15 years ago by skymoo (Adam Mercer)

Cc: ram@… added; rasmus@… removed
Owner: changed from macports-tickets@… to mww@…

Assigning to maintainer, reporter is automatically CC'd

comment:4 Changed 15 years ago by blb@…

Cc: blb@… added
Keywords: python25 python2.5 removed
Port: python25 python26 added

Where is this _nativemodule supposed to come from? I don't see any reference to it at all in the python 2.5.4 source tree.

comment:5 Changed 15 years ago by rasmus@…

It's a fictive scenario. The real case is that I try to import smisk (http://trac.hunch.se/smisk) which is linked against libfcgi. libfcgi uses environ, but Python 2.5.4 (current in macports) does not provide environ (because of the missing patch), thus I receive the error in the aforementioned fictive scenario. I have tested different modules using environ and having 2:nd level libraries using environ and have deduced the error as the missing patch through trail and error. Loading these libraries works with the Python 2.5.2 from ports (built with the environ-patch).

comment:6 Changed 15 years ago by rasmus@…

Clarification: The libfci triggering the error is a clean macport (port: www/fcgi)

comment:7 Changed 15 years ago by blb@…

Cc: mcalhoun@… added

Did you try it with that patch reinstated? I still get the same failure with it (not to mention it appears that Misc/setuid-prog.c isn't actually used by python).

However, in Modules/posicmodule.c, environ is declared static, but when I remove the static portion, smisk appears to work fine.

comment:8 Changed 15 years ago by rasmus@…

I did not try to apply the patch manually. Only to build the previous port (trunk/dports/lang/python25/@45618) Sounds weird that environ was declared static in Modules/posixmodule.c – what Python does here is creating a temporary solution for that object file. Now the question is: Should Python provide the environ symbol or should any library needing it do as python-2.5.4/Modules/posixmodule.c and provide their own solution?

I guess the latter would be the prettiest, but dunno how many ports will need to be patched. (www/fcgi will definitely be one of them) Will investigate further later today.

comment:9 Changed 15 years ago by rasmus@…

BTW, seems like someone called afb@ (is this Anders F. Björklund?!) have been working with the Portfile. Maybe he/she could be CCed as well?

comment:10 in reply to:  7 ; Changed 15 years ago by skymoo (Adam Mercer)

Replying to blb@…:

However, in Modules/posicmodule.c, environ is declared static, but when I remove the static portion, smisk appears to work fine.

I can also confirm that the attached patch enables me to import native modules, in this case the python bindings to the globus toolkit. Without this patch I get errors regarding the _environ symbol missing, with the patch applied they import without error.

Looks like this is a solution, whether it is the correct solution is a different matter....

Changed 15 years ago by skymoo (Adam Mercer)

Attachment: patch-posixmodule.c.diff added

patch to Modules/posicmodule.c

comment:11 Changed 15 years ago by skymoo (Adam Mercer)

It appears that there is another patch in the files directory patch-Modules-posixmodile.c.diff that also patches Modules/posixmodule.c, however it is not applied to the python source, this is a different patch and applying this has no effect for this issue, i.e. the errors are still received regarding the missing _environ symbol. In fact there are several patches in the files directory that are not applied.

comment:12 in reply to:  10 Changed 15 years ago by rasmus@…

Replying to ram@…:

Replying to blb@…:

However, in Modules/posicmodule.c, environ is declared static, but when I remove the static portion, smisk appears to work fine.

I can also confirm that the attached patch enables me to import native modules, in this case the python bindings to the globus toolkit. Without this patch I get errors regarding the _environ symbol missing, with the patch applied they import without error.

Looks like this is a solution, whether it is the correct solution is a different matter....

I think the patching should be done in the binary which uses environ rather than Python exposing it like a normal libc would. I.e. patching lang/python is not the way, but rather patching libfcgi which is in my case the binary using environ. (python itself has it's own solution to accessing environ on Mac OS X). I have by email submitted patches to the libfcgi port, effectively solving the problem.

I now realize that this issue/change (environ no longer exported by python) probably breaks alot of native python modules. A simple grep for environ in all .c-files in all python-modules would shed some light on the situation.

comment:13 Changed 15 years ago by mf2k (Frank Schima)

Cc: macsforever2000@… added

Cc Me!

comment:14 Changed 15 years ago by rasmus@…

Resolution: fixed
Status: newclosed

Fixed by [46147]

comment:15 Changed 15 years ago by (none)

Milestone: Port Bugs

Milestone Port Bugs deleted

Note: See TracTickets for help on using tickets.