Skip to content

Deadlock in python3.13 inspect.py #54

Description

@nierob

Seems that it is possible to deadlock blockbuster (nice tool btw.),

The test that triggers it already is wrapped with:

        for op in (
            "os.stat",
            "io.TextIOWrapper.read",
            "os.getcwd",
            "os.access",
            "os.scandir",
            "socket.socket.connect",
            "socket.socket.sendall",
            "socket.socket.recv",
            "io.BufferedWriter.write",
            "socket.socket.send",
            "io.BufferedReader.read",
        ):
            bb.functions[op].can_block_in(
                "file_name.py", {"function_name"}
            )

Traceback:

  (...)
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/alembic/runtime/migration.py:535: in get_current_heads
      if not self._has_version_table():
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/alembic/runtime/migration.py:555: in _has_version_table
      return sqla_compat._connectable_has_table(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/alembic/util/sqla_compat.py:229: in _connectable_has_table
      return connectable.dialect.has_table(connectable, tablename, schemaname)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  <string>:2: in has_table
      ???
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/reflection.py:89: in cache
      return fn(self, con, *args, **kw)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/dialects/postgresql/base.py:3494: in has_table
      return bool(connection.scalar(query, {"table_name": table_name}))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:1308: in scalar
      return meth(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/sql/elements.py:544: in _execute_on_scalar
      return self._execute_on_connection(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/sql/elements.py:526: in _execute_on_connection
      return connection._execute_clauseelement(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:1641: in _execute_clauseelement
      ret = self._execute_context(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:1846: in _execute_context
      return self._exec_single_context(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:1986: in _exec_single_context
      self._handle_dbapi_exception(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:2358: in _handle_dbapi_exception
      raise exc_info[1].with_traceback(exc_info[2])
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/base.py:1967: in _exec_single_context
      self.dialect.do_execute(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/sqlalchemy/engine/default.py:951: in do_execute
      cursor.execute(statement, parameters)
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/pg8000/legacy.py:254: in execute
      self._context = self._c.execute_unnamed(
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/pg8000/core.py:693: in execute_unnamed
      self.send_PARSE(NULL_BYTE, statement, oids)
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/pg8000/core.py:672: in send_PARSE
      _write(self._sock, FLUSH_MSG)
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/pg8000/core.py:167: in _write
      sock.write(d)
  ../../../.cache/pypoetry/virtualenvs/abc-py3.13/lib/python3.13/site-packages/blockbuster/blockbuster.py:88: in wrapper
      frame_info = inspect.getframeinfo(frame)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  /opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/inspect.py:1691: in getframeinfo
      lines, lnum = findsource(frame)
                    ^^^^^^^^^^^^^^^^^
  /opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/inspect.py:1072: in findsource
      module = getmodule(object, file)
               ^^^^^^^^^^^^^^^^^^^^^^^
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  object = <frame at 0x7f4ab14da020, file '<string>', line 2, code has_table>
  _filename = '<string>'
  
      def getmodule(object, _filename=None):
          """Return the module an object was defined in, or None if not found."""
          if ismodule(object):
              return object
          if hasattr(object, '__module__'):
              return sys.modules.get(object.__module__)
      
          # Try the filename to modulename cache
          if _filename is not None and _filename in modulesbyfile:
              return sys.modules.get(modulesbyfile[_filename])
          # Try the cache again with the absolute file name
          try:
              file = getabsfile(object, _filename)
          except (TypeError, FileNotFoundError):
              return None
          if file in modulesbyfile:
              return sys.modules.get(modulesbyfile[file])
          # Update the filename to module name cache and check yet again
          # Copy sys.modules in order to cope with changes while iterating
          for modname, module in sys.modules.copy().items():
  >           if ismodule(module) and hasattr(module, '__file__'):
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  E           Failed: Timeout (>30.0s) from pytest-timeout.
  
  /opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/inspect.py:1020: Failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions