Edgewall Software
Modify

Opened 7 years ago

Last modified 4 years ago

#7014 reopened defect

Trap "ZipImportError: bad local file header.. " and suggest server restart

Reported by: admin Owned by: jonas
Priority: high Milestone: next-major-releases
Component: general Version: 0.11b1
Severity: normal Keywords: setuptools
Cc: thijstriemstra
Release Notes:
API Changes:

Description

How to Reproduce

While doing a GET operation on /admin/general/plugin, Trac issued an internal error.

(please provide additional details here)

Request parameters:

{'cat_id': u'general', 'panel_id': u'plugin', 'path_info': None}

System Information

Trac 0.11b1
Python 2.5.1 (r251:54863, Mar 13 2008, 12:52:19)
[GCC 3.4.6 [FreeBSD] 20060305]
setuptools 0.6c8
SQLite 3.3.17
pysqlite 2.3.5
Genshi 0.4.4
Pygments 0.9
Subversion 1.4.6 (r28521)

Python Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/main.py", line 398, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/web/main.py", line 195, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/admin/web_ui.py", line 108, in process_request
    path_info)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/admin/web_ui.py", line 389, in render_admin_panel
    return self._render_view(req)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/admin/web_ui.py", line 503, in _render_view
    info = get_pkginfo(dist)
  File "/usr/local/lib/python2.5/site-packages/Trac-0.11b1-py2.5.egg/trac/util/__init__.py", line 228, in get_pkginfo
    pkginfo = email.message_from_string(dist.get_metadata('PKG-INFO'))
  File "/usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1137, in get_metadata
    return self._get(self._fn(self.egg_info,name))
  File "/usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1195, in _get
    return self.loader.get_data(path)
ZipImportError: bad local file header in /usr/local/lib/python2.5/site-packages/TracAccountManager-0.2dev_r3111-py2.5.egg

Attachments (0)

Change History (5)

comment:1 Changed 7 years ago by jhampton

  • Resolution set to fixed
  • Status changed from new to closed

Please restart your webserver.

This generally happens when a process has the egg cached and the physical egg behind it changes.

Please reopen the ticket if this does not fix your problem.

comment:2 Changed 4 years ago by cboos

  • Keywords setuptools added
  • Milestone set to next-major-0.1X
  • Priority changed from normal to high
  • Resolution fixed deleted
  • Status changed from closed to reopened

The ZipImportError exception is raised by pkg_resource in a new process which loads a newly installed .egg while there are still other processes running with the older version of the .egg.

This usually happens after an install, if it is not followed by a server restart, as new processes get spawned. A server restarts always fix the problem without a need to reinstall anything, so the .egg is not actually corrupted.

It would be nice to find a fix or a workaround or at least a more precise explanation of the problem.

comment:3 Changed 4 years ago by thijstriemstra

  • Cc thijstriemstra added

comment:4 Changed 4 years ago by cboos

This actually happens if those new processes get forked from processes already having loaded the modules from the previous zip file.

In Re: py2exe + svn - the final drama, when discussing the reasons for a "bad local file header" exception, David Bollen wrote:

Apparently there are two levels of caching that you've got to defeat if you change the underlying zip:

  1. A global file set of file directory cache information for any opened zip file (for all files in the zip). This is held in the zipimport module global _zip_directory_cache.
  2. Individual file cached information within the zipimporter instance that is kept in the path importer cache (sys.path_importer_cache). Technically these are just references to the same individual entries being held in the dictionary from (1).

pkg_resources does the same as (2) and stores those "toc entries" dicts in zipinfo property of ZipImporter and EggMetadata.

This is for the explanation of the issue, which is now clear.

Now, for finding a solution, that's far less evident. We could try to modify pkg_resource so that it detects the change and resets the information, but we would then end up doing a kind of reload, which I'm sure would introduce its own set of issues.

Perhaps it's better to simply trap the error and translate it to a simple TracError stating that a full server restart is needed.

comment:5 Changed 4 years ago by cboos

  • Summary changed from ZipImportError: bad local file header in /usr/local/lib/python2.5/site-packages/TracAccountManager-0.2dev_r3111-py2.5.egg to Trap "ZipImportError: bad local file header.. " and suggest server restart

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The owner will remain jonas.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from jonas to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.