Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

slp_kill_tasks_with_stacks is broken #81

Closed
@ghost

Description

Originally reported by: Anselm Kruis (Bitbucket: akruis, GitHub: akruis)


Problem

Since commit 2b9cd7d84dfd6e2 slp_kill_tasks_with_stacks pretends to send a kill message to tasklets on other threads. But the second loop is dead code, because it can't be reached.

Since commit 49d9f07ce726 slp_kill_tasks_with_stacks ignores its argument and operates on the current thread only.

During shutdown Py_Finalize() indirectly invokes slp_kill_tasks_with_stacks at least two times:

  1. with a NULL argument via PyStackless_kill_tasks_with_stacks(1). At this time, the interpreter is still fully functional.
  2. Once for each thread-state via PyInterpreterState_Clear(interp) and PyThreadState_Clear(). During these calls the import mechanism is no longer functional.

Because slp_kill_tasks_with_stacks ignores its argument, only the first call has any effect. Stackless dosn't kill any tasklets on other (daemon) threads.

Test Case

It's fairly hard to write a test case for problems, occurring late during interpreter shutdown. AFAIK the only option is to use a del-method of an object, that gets cleared sufficiently late. The codec search path, which is stored in the interpreter state, is such an object. PyInterpreterState_Clear clears it immediately after the threads.
My plan is to add a test-case, that ensures, that stackless kills all tasklets. Then I'll fix slp_kill_tasks_with_stacks.


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions