Bug 919 - [PATCH] Form.ShowDialog(null) can crash with "Forms cannot own themselves or their owners."
Summary: [PATCH] Form.ShowDialog(null) can crash with "Forms cannot own themselves or ...
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-19 18:04 UTC by Stephen McConnel
Modified: 2011-10-17 06:52 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

proposed patch (1.06 KB, patch)
2011-09-19 18:07 UTC, Stephen McConnel
proposed patch (1.07 KB, patch)
2011-09-19 19:27 UTC, Stephen McConnel

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Stephen McConnel 2011-09-19 18:04:30 UTC
If Form.ShowDialog() is passed a null, it tries to figure out a plausible owner.  In rare circumstances (which I haven't been able to isolate, or even reproduce recently), the owner it comes up with is the form itself.  This throws an exception with the message "Forms cannot own themselves or their owners."
Comment 1 Stephen McConnel 2011-09-19 18:07:45 UTC
Created attachment 438 [details]
proposed patch

This patch recovers from finding the form itself as the proposed owner when Form.ShowDialog() is passed a null argument.
Comment 2 Stephen McConnel 2011-09-19 19:27:00 UTC
Created attachment 439 [details]
proposed patch
Comment 3 Tom Hindle 2011-10-17 06:52:02 UTC
commit f4da7d5c1bb79aa8874b629bdc091613cf8fe450