Bug 11635 - Null check within finally block evaluates incorrectly (Xamarin 4.0.3)
Summary: Null check within finally block evaluates incorrectly (Xamarin 4.0.3)
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 6.4 (async)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-04-07 05:30 UTC by Rhys
Modified: 2013-07-09 03:42 UTC (History)
5 users (show)

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

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 Developer Community or GitHub 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:
Status:
RESOLVED NORESPONSE

Description Rhys 2013-04-07 05:30:39 UTC
For some reason, if I check the value of an object within a finally block against null, it evaluates to true, taking it out of the finally block fixes the issue.

Below is sample code I've used to reproduce this:

FileStream str = File.OpenRead(path);
myobj data = null;

try {
	data = (myobj)xs.Deserialize(str);
} catch (Exception ex) {
	str.Close();
	str = null; //Note we set this to null - in the watch window at this point it definitely is null
	File.Delete(path);
} finally {
	if (str != null) { //Evaluates to true??
		str.Close(); //Crash
	}
}

If you take the null check out of the finally, placing it just below, it works perfectly. What's more, if you try and evaluate str != null whilst paused in the finally block, the Xamarin IDE states 'Expression not supported'.
Comment 1 Zoltan Varga 2013-04-07 08:31:55 UTC
Do you have LLVM enabled ?
Comment 2 Rhys 2013-04-07 08:32:43 UTC
No, LLVM is disabled
Comment 3 Zoltan Varga 2013-04-08 07:42:41 UTC
I cannot reproduce this. Could you attach a complete test project?
Comment 4 Sebastien Pouliot 2013-04-08 09:56:59 UTC
It is really 6.3.x (the alpha version) of Xamarin.iOS ? or the stable one (6.2.x).

4.0.3 is the version of Xamarin.Studio (which may be used with different versions of Xamarin.iOS).

The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 6 PJ 2013-07-09 03:42:22 UTC
Marking this one as RESOLVED, NO RESPONSE for now. Please feel free to re-open
if you still have an issue. If you do, please add full version info and, if
possible, some steps to reproduce or a test project.