Issue 1332869: Fatal Python error: Interpreter not initialized (original) (raw)

Created on 2005-10-20 05:22 by ajmitch, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (11)

msg26643 - (view)

Author: Andrew Mitchell (ajmitch)

Date: 2005-10-20 05:22

When running 'bzr status' on Ubuntu 5.10 with python 2.4.2, I came across the error: Fatal Python error: Interpreter not initialized (version mismatch?) Aborted

The bzr code in question has a del method which when invoked (eventually) imports socket (which imports _socket), causing everything to fall over in a heap.

A backtrace is available at http://pastebin.com/399461

msg26644 - (view)

Author: Neal Norwitz (nnorwitz) * (Python committer)

Date: 2005-10-20 05:37

Logged In: YES user_id=33168

Are there any other extension modules in the system that are not provided with python? When you went into gdb did it print a long list of dynamic modules loaded? Can you provide that info too?

I'm guessing this is a memory overwrite which can happen with poorly behaved C extension modules. You could try running python under valgrind and see what it reports.

msg26645 - (view)

Author: Neal Norwitz (nnorwitz) * (Python committer)

Date: 2005-10-20 05:39

Logged In: YES user_id=33168

Also, where is the bzr code and what version are you running?

msg26646 - (view)

Author: Andrew Mitchell (ajmitch)

Date: 2005-10-20 08:04

Logged In: YES user_id=19159

Feedback in #bzr indicated that I was triggering this code: http://pastebin.com/399491 and also something similar to http://mail.python.org/pipermail/python-dev/2003-September/038151.html Another example that triggers it is http://mail.python.org/pipermail/python-dev/2003-November/040188.html It's all a stock breezy system, no external modules, and bzr is retrieved from running: rsync -av bazaar-ng.org::bazaar-ng/bzr/bzr.dev . I was using the latest revision at the time this happened.

msg26647 - (view)

Author: Andrew Mitchell (ajmitch)

Date: 2005-10-20 08:51

Logged In: YES user_id=19159

Also, gdb did not report other modules loaded

msg26648 - (view)

Author: Michael Hudson (mwh) (Python committer)

Date: 2005-10-20 10:09

Logged In: YES user_id=6656

Are you using daemon threads?

Why is a del method importing things?

msg26649 - (view)

Author: Neal Norwitz (nnorwitz) * (Python committer)

Date: 2005-10-21 05:55

Logged In: YES user_id=33168

Hey Tim, I'm hoping you can take some time to long at this patch (you too Michael and anyone else listening).

Attached is a patch which seems to fix this problem. At least it fixes it from Tim's example in the mail from Nov (I think). It moves initialized down after the GC collect.

Is this patch a good or bad thing?

Andrew, it would be interesting if you could test this patch (you will need to rebuild python) for bzr. I couldn't trigger the problem from my version.

msg26650 - (view)

Author: Neal Norwitz (nnorwitz) * (Python committer)

Date: 2005-10-21 06:15

Logged In: YES user_id=33168

Well, what I really hope is that Tim can make some time to look at this patch. Feel free to long over it if you wish. :-)

msg26651 - (view)

Author: Tim Peters (tim.peters) * (Python committer)

Date: 2006-03-31 17:46

Logged In: YES user_id=31435

Sorry for the delay! I didn't realize this was assigned to me. Note that the possiblity for problems here was already noted in Py_Finalize():

/* Collect garbage.  This may call finalizers; it's nice to

call these * before all modules are destroyed. * XXX If a del or weakref callback is triggered here, and tries to * XXX import a module, bad things can happen, because Python no * XXX longer believes it's initialized. * XXX Fatal Python error: Interpreter not initialized (version mismatch?) * XXX is easy to provoke that way. I've also seen, e.g., * XXX Exception exceptions.ImportError: 'No module named sha' * XXX in <function callback at 0x008F5718> ignored * XXX but I'm unclear on exactly how that one happens. In any case, * XXX I haven't seen a real-life report of either of these. */ PyGC_Collect();

I don't think it would do much harm to move "initialized = 0" down, although it's impossible to get truly concerned about code doing imports in del when the interpreter is tearing itself down. Note that sys exit funcs have already been called, and signals have been disabled, by this time, so there would still be ways for dubious del code to fail.

Anyway, if you want to do this, the XXX comments reproduced above should be changed too (e.g., deleted).

Assigning to Neal, so that he can get practice following his new "no changes without a test case" guideline :-)

msg114629 - (view)

Author: Mark Lawrence (BreamoreBoy) *

Date: 2010-08-22 01:11

Is this still valid?

msg368887 - (view)

Author: STINNER Victor (vstinner) * (Python committer)

Date: 2020-05-15 00:49

No activity since 2006, I close the issue as out of date.

History

Date

User

Action

Args

2022-04-11 14:56:13

admin

set

github: 42505

2020-05-15 00:49:42

vstinner

set

status: open -> closed

nosy: + vstinner
messages: +

resolution: out of date
stage: test needed -> resolved

2019-12-20 23:07:40

eric.snow

set

nosy: + eric.snow

2014-02-03 19:47:44

BreamoreBoy

set

nosy: - BreamoreBoy

2010-08-22 01:11:25

BreamoreBoy

set

nosy: + BreamoreBoy
messages: +

2009-03-20 22:59:04

ajaksu2

set

title: Fatal Python error: Interpreter not initialized -> Fatal Python error: Interpreter not initialized
stage: test needed
type: behavior
versions: + Python 2.6, - Python 2.4

2005-10-20 05:22:34

ajmitch

create