Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Segfault when using Multiprocessing #8795

Copy link
Copy link
Closed
@miakramer

Description

@miakramer
Issue body actions

Bug report

Bug summary

Matplotlib segfaults when creating a figure when used in combination with the standard multiprocessing library.

Code for reproduction

import multiprocessing as mp
import matplotlib.pyplot as plt


def plot():
    fig = plt.figure()


def main(nprocs=2):
    worker = mp.Process(target=plot)

    worker.start()

    worker.join()
    if worker.exitcode < 0:
        print("Error: %s exited with error code %i." % (worker.__str__(), worker.exitcode))


if __name__ == "__main__":
    main()

Actual outcome

All processes exit with code -11, SYSSEGV

Expected outcome

I've figured out that creating a figure like this isn't expected to work with the GUI backend on. Putting:

import matplotlib
matplotlib.use('agg')

before the other imports fixes the issue. It's understandable that you can't create multiple instances of the GUI on different processes, however it seems to me an exception should be thrown rather than a segfault.

Matplotlib version

  • Operating System: macOS 10.12.5
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7.13, 3.6.1
  • Other Libraries: multiprocessing

Matplotlib was installed from Conda, on the conda-forge stream.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.