After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528953 - glChess and Sudoku crash on startup when the python version is not the same as that of build time
glChess and Sudoku crash on startup when the python version is not the same a...
Status: RESOLVED FIXED
Product: gnome-games-superseded
Classification: Deprecated
Component: general
2.22.x
Other Linux
: Normal major
: ---
Assigned To: gnome-games-general-maint
GNOME Games maintainers
: 528234 528471 528561 528569 528739 531793 531829 531891 531991 532024 532107 532245 532257 532372 532449 532494 532503 532514 532548 532590 532684 532833 532881 532890 532997 533067 533228 533958 534755 538277 541655 542497 552057 552058 555922 (view as bug list)
Depends on:
Blocks: 524665
 
 
Reported: 2008-04-19 20:40 UTC by Josselin Mouette
Modified: 2008-10-11 18:06 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
fix sys.path (1.81 KB, patch)
2008-04-21 19:44 UTC, Jason Clinton
committed Details | Review

Description Josselin Mouette 2008-04-19 20:40:27 UTC
The following code is completely useless, and makes glchess crash on startup when the python version at runtime is different from the python version at build time.

      if "#pyexecdir#" not in sys.path:
          sys.path.insert(0, "#pyexecdir#")

See http://bugs.debian.org/476877 for an example of what happens when you do such horrible things.
Comment 1 Jason Clinton 2008-04-21 19:44:35 UTC
Created attachment 109645 [details] [review]
fix sys.path

from Debian by Joss
Comment 2 Andreas Røsdal 2008-04-22 17:57:29 UTC
For background info, see bug #382057.
Comment 3 Josselin Mouette 2008-04-23 08:54:38 UTC
This is a good thing to have when the python modules are installed in a private directory (e.g. /usr/share/games/glchess). But when they are installed in the public modules directory, like the current makefiles do, it can only make things turn wrong.
Comment 4 Robert Ancell 2008-04-24 00:26:05 UTC
I still can't see why this should be causing a problem:
- If Gnome Games is compiled to install a directory that is in your sys.path then sys.path is not modified
- If the .py files are not in the directory Gnome Games was compiled with Python will first in the compiled directory and then look in the system configured paths (we only prepend this path, not remove any of the system paths).

Comment 5 Josselin Mouette 2008-04-24 09:02:43 UTC
This is causing a crash when the python version at runtime is different from the python version at build time.

In the case of the reported crashes, gnome-games was built with python 2.4, and hardcoded /usr/lib/python2.4/site-packages in the script. After the python upgrade, the python version was 2.5, and adding /usr/lib/python2.4/site-packages to the sys.path immediately causes crashes because some random modules built for 2.4 are loaded by python2.5.
Comment 6 Andreas Røsdal 2008-04-24 16:32:27 UTC
I think the patch in comment #1 will have problems, 
when glChess is installed in a different prefix than default. 

Also, GNOME Sudoku will have to be modified in the same way
as glChess, because these two games have the same initialization code.

Generally, I agree with comment #4...
Comment 7 Josselin Mouette 2008-04-24 16:53:43 UTC
What exactly isn't clear in "this is causing a crash" ?

(BTW, thanks for the gnome-sudoku hint, I'll patch it as well.)
Comment 8 Andreas Røsdal 2008-04-24 20:15:06 UTC
It seems to me that we need an improved fix which handles both:

- Installation to a different prefix than the default.
- Doesn't crash when upgrading Python.

Unforunately very few projects use automake/autoconf for distributing Python code,
but it would be interesting to see how other projects in the same situation solve this.  

Why does Python "immediately crash because some random modules built for 2.4 are loaded by python2.5"? Eg. why are "some random" modules loaded in the first place?
Comment 9 Josselin Mouette 2008-04-24 20:49:45 UTC
(In reply to comment #8)
> Unforunately very few projects use automake/autoconf for distributing Python
> code, but it would be interesting to see how other projects in the same 
> situation solve this.  

Most projects I know - regardless of the build system - choose between one of the following:
 * Install modules in the default python path and let the system deal with them and make them available.
 * Install modules in a fixed, private directory and unconditionally add this directory to sys.path.
These two approaches have radically different philosophies - the former makes modules available to other programs, the latter is less prone to namespace conflicts - and trying to support both is going to be unnecessarily complex, with a benefit that I don't grasp.

> Why does Python "immediately crash because some random modules built for 2.4
> are loaded by python2.5"? Eg. why are "some random" modules loaded in the first
> place?

Because when later, the game imports a module, like gtk or cairo, it is found in the python2.4 directory which has been added to sys.path.
Comment 10 Andreas Røsdal 2008-04-26 15:54:46 UTC
> Install modules in the default python path and let the system deal with them and make them available.

Let's say we took this approach. glChess would then be installed in /usr/lib/python2.4/site-packages. When upgrading from Python 2.4 to 2.5, Python would look and not find glChess in the new python library path /usr/lib/python2.5/site-packages. So you would still have problem with this approach, when upgrading Python. 

If glChess would be installed in the default python path, changes to the makefiles are required, which are not implemented in the patch in comment #1. So if glChess would be installed in a non-default prefix, it wouldn't work because the libraries wouldn't be found by Python without adding it to sys.path.
Comment 11 Josselin Mouette 2008-04-26 16:06:24 UTC
(In reply to comment #10)
> Let's say we took this approach. glChess would then be installed in
> /usr/lib/python2.4/site-packages. When upgrading from Python 2.4 to 2.5, Python
> would look and not find glChess in the new python library path
> /usr/lib/python2.5/site-packages. So you would still have problem with this
> approach, when upgrading Python. 

No, because we make these modules available automatically for all supported python versions. Therefore, they already appear in /var/lib/python-support/python2.5, even when they were built against python2.4.

> If glChess would be installed in the default python path, changes to the
> makefiles are required, which are not implemented in the patch in comment #1.
> So if glChess would be installed in a non-default prefix, it wouldn't work
> because the libraries wouldn't be found by Python without adding it to
> sys.path.

Installing public python modules in a non-default prefix will not work without fiddling with PYTHONPATH or modifying site.py, anyway. That is expected. Just like installing binaries in a non-default prefix will not work without fiddling with PATH.
Comment 12 Andreas Røsdal 2008-04-26 16:40:31 UTC
> No, because we make these modules available automatically for all supported
> python versions. Therefore, they already appear in
> /var/lib/python-support/python2.5, even when they were built against python2.4.

How?
Comment 13 Robert Ancell 2008-05-04 14:17:30 UTC
*** Bug 528234 has been marked as a duplicate of this bug. ***
Comment 14 Robert Ancell 2008-05-04 14:23:12 UTC
Bug 528234 and all the duplicates are showing these symptons, i.e:
Running glChess using Python 2.5 but opening the cairo object file from the Python 2.4 directory.

Due to the number of problems I recommend applying the patch as given for 2.22.2 and solve the non-standard installation path at another time.

Perhaps we need a new configure flag to include the path only if requested.
Comment 15 Robert Ancell 2008-05-04 14:28:02 UTC
*** Bug 528471 has been marked as a duplicate of this bug. ***
Comment 16 Robert Ancell 2008-05-04 14:28:12 UTC
*** Bug 528561 has been marked as a duplicate of this bug. ***
Comment 17 Robert Ancell 2008-05-04 14:28:28 UTC
*** Bug 528569 has been marked as a duplicate of this bug. ***
Comment 18 Robert Ancell 2008-05-04 14:28:35 UTC
*** Bug 528739 has been marked as a duplicate of this bug. ***
Comment 19 Gianluca Borello 2008-05-07 12:24:19 UTC
*** Bug 531793 has been marked as a duplicate of this bug. ***
Comment 20 Gianluca Borello 2008-05-07 12:24:27 UTC
*** Bug 531829 has been marked as a duplicate of this bug. ***
Comment 21 Gianluca Borello 2008-05-07 12:24:33 UTC
*** Bug 531891 has been marked as a duplicate of this bug. ***
Comment 22 Gianluca Borello 2008-05-08 10:45:57 UTC
*** Bug 531991 has been marked as a duplicate of this bug. ***
Comment 23 Gianluca Borello 2008-05-08 10:46:05 UTC
*** Bug 532024 has been marked as a duplicate of this bug. ***
Comment 24 Gianluca Borello 2008-05-08 10:46:11 UTC
*** Bug 532107 has been marked as a duplicate of this bug. ***
Comment 25 Gianluca Borello 2008-05-09 10:39:24 UTC
*** Bug 532257 has been marked as a duplicate of this bug. ***
Comment 26 Gianluca Borello 2008-05-09 10:40:12 UTC
*** Bug 532245 has been marked as a duplicate of this bug. ***
Comment 27 Gianluca Borello 2008-05-09 18:29:43 UTC
*** Bug 532372 has been marked as a duplicate of this bug. ***
Comment 28 Gianluca Borello 2008-05-10 08:10:13 UTC
*** Bug 532449 has been marked as a duplicate of this bug. ***
Comment 29 Gianluca Borello 2008-05-10 17:32:02 UTC
*** Bug 532494 has been marked as a duplicate of this bug. ***
Comment 30 Gianluca Borello 2008-05-11 09:09:10 UTC
*** Bug 532503 has been marked as a duplicate of this bug. ***
Comment 31 Gianluca Borello 2008-05-11 09:09:17 UTC
*** Bug 532514 has been marked as a duplicate of this bug. ***
Comment 32 Gianluca Borello 2008-05-11 09:09:23 UTC
*** Bug 532548 has been marked as a duplicate of this bug. ***
Comment 33 Gianluca Borello 2008-05-11 09:09:30 UTC
*** Bug 532590 has been marked as a duplicate of this bug. ***
Comment 34 Gianluca Borello 2008-05-12 10:20:03 UTC
*** Bug 532684 has been marked as a duplicate of this bug. ***
Comment 35 Andreas Røsdal 2008-05-12 12:14:07 UTC
As a reply to comment #14: yes, it seems that the patch can be applied for now, since there are quite a few duplicates of this bug.
Comment 36 Gianluca Borello 2008-05-13 11:52:20 UTC
*** Bug 532833 has been marked as a duplicate of this bug. ***
Comment 37 Gianluca Borello 2008-05-13 11:52:27 UTC
*** Bug 532890 has been marked as a duplicate of this bug. ***
Comment 38 Gianluca Borello 2008-05-13 11:52:33 UTC
*** Bug 532881 has been marked as a duplicate of this bug. ***
Comment 39 Robert Ancell 2008-05-14 08:27:54 UTC
Clarifying the case in which this happens:

Gnome Games is compiled to install .py files into /usr/lib/python2.4/site-packages. This causes '/usr/lib/python2.4/site-packages' to be prepended (if it is not present) into the path when glChess is run.

When glchess is executed on a Python 2.4 system the path is set to ['/usr/lib/python2.4/site-packages']. The path is not modified and the glchess libraries are correctly loaded from '/usr/lib/python2.4/site-packages' when /usr/bin/games/glchess shell script is executed.

The user upgrades to Python 2.5 and executes glChess again. The default Python path for the new Python interpreter is ['/usr/lib/python2.5/site-packages'] so '/usr/lib/python2.4/site-packages' is prepended. The python files are loaded from the 2.4 directory and executed using the 2.5 interpreter. Any 2.4 .so packages that are not binary compatible with Python 2.5 throw exceptions.

If our top level file had specified the same version of Python as the sys.path then this problem would not have occurred (i.e. the /usr/games/glchess script started with !#/usr/bin/python2.4) but we would have only worked in one version of Python.
Comment 40 Robert Ancell 2008-05-14 08:29:46 UTC
Re-assigning to general as it affects both glChess and Sudoku
Comment 41 Robert Ancell 2008-05-14 08:31:22 UTC
*** Bug 532997 has been marked as a duplicate of this bug. ***
Comment 42 Gianluca Borello 2008-05-14 11:23:00 UTC
*** Bug 533067 has been marked as a duplicate of this bug. ***
Comment 44 vamp898 2008-05-14 19:32:51 UTC
Using Debian testing and made upgrade today, and with the new version the bug is fixed. THX, love GNOME =)
Comment 45 Gianluca Borello 2008-05-15 10:27:29 UTC
*** Bug 533228 has been marked as a duplicate of this bug. ***
Comment 46 Gianluca Borello 2008-05-26 10:26:33 UTC
*** Bug 534755 has been marked as a duplicate of this bug. ***
Comment 47 Gianluca Borello 2008-05-26 10:26:37 UTC
*** Bug 533958 has been marked as a duplicate of this bug. ***
Comment 48 Gianluca Borello 2008-06-14 17:17:39 UTC
*** Bug 538277 has been marked as a duplicate of this bug. ***
Comment 49 Gianluca Borello 2008-07-05 19:53:10 UTC
*** Bug 541655 has been marked as a duplicate of this bug. ***
Comment 50 Gianluca Borello 2008-07-12 08:25:11 UTC
*** Bug 542497 has been marked as a duplicate of this bug. ***
Comment 51 Gianluca Borello 2008-09-13 10:01:49 UTC
*** Bug 552058 has been marked as a duplicate of this bug. ***
Comment 52 Gianluca Borello 2008-09-13 10:01:55 UTC
*** Bug 552057 has been marked as a duplicate of this bug. ***
Comment 53 Gianluca Borello 2008-10-11 18:06:58 UTC
*** Bug 555922 has been marked as a duplicate of this bug. ***