This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: test_threading.test_finalize_with_trace() fails on FreeBSD buildbot
Type: Stage:
Components: Versions: Python 3.4
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: koobs, ncoghlan, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2013-08-15 10:14 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
finalize_clear_trace.patch vstinner, 2013-08-15 10:17 review
Messages (4)
msg195244 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-08-15 10:14
The following test fails on FreeBSD buildbot:

    def test_finalize_with_trace(self):
        # Issue1733757
        # Avoid a deadlock when sys.settrace steps into threading._shutdown
        assert_python_ok("-c", """if 1:
            import sys, threading

            # A deadlock-killer, to prevent the
            # testsuite to hang forever
            def killer():
                import os, time
                print('program blocked; aborting')
            t = threading.Thread(target=killer)
            t.daemon = True

            # This is the trace function
            def func(frame, event, arg):
                return func


I ran it manually on my FreeBSD 9.1 VM, I get the following error. I don't know if it's the same error than the buildbot.
# clear builtins._
# restore sys.stderr
# cleanup __main__
# cleanup[1] _sysconfigdata
# cleanup[1] threading
Exception ignored in: <function WeakSet.__init__.<locals>._remove at 0x801b11058>
Traceback (most recent call last):
  File "/usr/home/haypo/prog/python/default/Lib/", line 38, in _remove
  File "", line 17, in func
AttributeError: 'NoneType' object has no attribute 'current_thread'
# cleanup[1] _weakrefset
# cleanup[3] _codecs
PyThreadState_Clear: warning: thread still has a frame

The weakref is probably threading._dangling.

IMO Py_Finalize() should first clear the trace function. Tracing Python exception while Python is dying (exiting) is insane. I'm surprised that it works :-)
msg195492 - (view) Author: Kubilay Kocak (koobs) (Python triager) Date: 2013-08-17 16:25
I'm not sure if this issue is/was related, but it seems the commit addressing #18178 has taken care of the test_finalize_runnning_thread failure.

I note that your description specifies test_finalize_"with_trace", perhaps suggesting your reproduction case may be something slightly different?

FWIW, I don't think I've seen the 'with_trace' test fail on my buildbots (but correct me if I'm wrong)

After the commit mentioned above, the FreeBSD 10 buildbot is now green on all branches.
msg196096 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-08-24 19:40
It may be related to #18408 (changeset 5bd9db528aed) and #18664.
msg206011 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-12-13 01:54
I don't see this issue anymore on FreeBSD buildbots. It was probably fixed. The issue #19466 changed also the Python shutdown procedure.
Date User Action Args
2022-04-11 14:57:49adminsetgithub: 62946
2013-12-13 01:54:54vstinnersetstatus: open -> closed
resolution: out of date
messages: + msg206011
2013-08-24 19:40:09vstinnersetmessages: + msg196096
2013-08-17 16:25:02koobssetmessages: + msg195492
2013-08-15 10:17:34vstinnersetfiles: + finalize_clear_trace.patch
keywords: + patch
2013-08-15 10:14:24vstinnersetnosy: + koobs
2013-08-15 10:14:20vstinnercreate