Skip to content

Strange deadlock with pybind11 + Flask w/ app debug mode #1308

@skystrife

Description

@skystrife

Issue description

The exact setup for this to happen seems really bizarre to me, but here it goes: I get a deadlock when using Flask with its default debug app reloader with my pybind11 module. I've reduced the example down to the smallest thing I can think of that still replicates.

The ingredients:

  1. #include <pybind11/functional.h>
  2. A pybind11-bound function that takes a std::function
  3. A class defined in the module
  4. A Flask app running with app.run(debug=True)
  5. A route in that Flask app that calls the function from 2.

What really confuses me is that if I remove the class in step 3, the deadlock goes away. Similarly, if the function in step 2 doesn't take something complicated (like just an int), the deadlock goes away. If the call to run the app is instead just app.run(), the deadlock goes away (similarly if use_reloader=False is passed). Something in the combination of all three of these things causes the deadlock when the passed-in function is invoked. Using a default std::function parameter doesn't seem to change anything.

Versions:

$ python --version
Python 3.6.4

$ gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pybind11 stable branch (see submodule in reproduction repo)

Reproducible example code

https://github.com/skystrife/pybind11-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions