Bug 83498

Summary: IGT's igt_reset_connectors is not signal safe
Product: DRI Reporter: Paulo Zanoni <przanoni>
Component: DRM/IntelAssignee: Thomas Wood <thomas.wood>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: medium CC: intel-gfx-bugs, przanoni, thomas.wood
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Paulo Zanoni 2014-09-04 13:42:09 UTC
IGT's igt_reset_connectors() is called inside a signal handler, and eventually it calls malloc() or free() (through its libdrm calls and through the other IGT functions), and this can lead to nice deadlocks. For more details, just do a web search for "malloc signal handlers".

When this bug happens, the IGT application just freezes. If you attach GDB to the process and do a backtrace, you can clearly see it is stuck inside malloc() (or maybe free()).

So the solution would be to avoid the malloc()/free() calls inside igt_reset_connectors() and any other possible IGT function that gets called while in a signal handler. 

One possible solution is to modify our code to do all its allocations _before_ the signal handler happens, and then just do the necessary during the handler, and free the associated memory later.

References:

commit a16ebccaee426ef96b0894e3af733360d88ce4d7
    igt_core: zero exit_handler_count before forking

http://lists.freedesktop.org/archives/intel-gfx/2014-September/051762.html
https://bugs.freedesktop.org/show_bug.cgi?id=81367
Comment 1 Chris Wilson 2014-09-06 12:10:39 UTC
commit f675f6771b1a3eaca6981ad78d2f1521f379347a
Author: Thomas Wood <thomas.wood@intel.com>
Date:   Thu Sep 4 11:35:01 2014 +0100

    lib: keep a list of modified connectors to reset
    
    Avoid calling functions in igt_reset_connectors that are not safe to use
    in signal handlers by keeping a list of connectors that have been
    modified, instead of enumerating all connectors.
    
    v2: add space for a sentinel NULL value on forced_connectors and print a
        warning when the connector limit is reached (Chris Wilson)
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83498
    Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
    Signed-off-by: Thomas Wood <thomas.wood@intel.com>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.