Bug 7942 - Test UnixUserTest.NonReentrantSyscalls fails
Summary: Test UnixUserTest.NonReentrantSyscalls fails
Alias: None
Product: Class Libraries
Classification: Mono
Component: Mono.POSIX ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-10-23 06:50 UTC by Martin Baulig
Modified: 2016-11-11 09:37 UTC (History)
2 users (show)

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 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 Martin Baulig 2012-10-23 06:50:14 UTC
master commit 544176c35ebc4e7ec814b803660bf1a6db08404a:

ok=:; /usr/bin/make run-test-recursive || ok=false; /usr/bin/make run-test-local || ok=false; $ok
MCS     [net_4_5] Mono.Posix_test_net_4_5.dll
ok=:; \
	PATH="/private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/runtime/_tmpinst/bin:/usr/local/Cellar/ccache/3.1.7/libexec:/usr/local/bin/:/Users/builder/data/lanes/mono-mac-master/544176c3/install/bin:/usr/bin:/bin" MONO_REGISTRY_PATH="/Users/builder/.mono/registry" MONO_TESTS_IN_PROGRESS="yes" MONO_PATH="./../../class/lib/net_4_5::$MONO_PATH" /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/runtime/mono-wrapper --debug  ./../../class/lib/net_4_5/nunit-console.exe  Mono.Posix_test_net_4_5.dll -noshadow -labels  -exclude=NotOnMac,NotWorking,ValueAdd,CAS,InetAccess -output=TestResult-net_4_5.log -xml=TestResult-net_4_5.xml  || ok=false; \
	(echo ''; cat TestResult-net_4_5.log) | sed '1,/^Tests run: /d'; xsltproc ./../../build/nunit-summary.xsl TestResult-net_4_5.xml >> TestResult-net_4_5.log ; $ok
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment - 
   OS Version: Unix
  CLR Version: 4.0.30319.17020 ( 3.0.1 (master/544176c Tue Oct 23 02:02:24 EDT 2012) )

Excluded categories: NotOnMac,NotWorking,ValueAdd,CAS,InetAccess

Tests run: 144, Failures: 1, Not run: 0, Time: 16.555 seconds

Test Case Failures:
1) MonoTests.Mono.Unix.UnixUserTest.NonReentrantSyscalls : #TNRS: Exception constructing UnixUserInfo (string): NUnit.Framework.AssertionException:   #TNRS: construct by name
  Expected: <root:********:0:0:System Administrator:/private/var/root:/bin/tcsh>
  But was:  <root:********:0:0:System Administrator:/var/root:/bin/sh>

  at NUnit.Framework.Assert.That (System.Object actual, NUnit.Framework.Constraints.Constraint constraint, System.String message, System.Object[] args) [0x00020] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/nunit24/NUnitFramework/framework/Assert.cs:2205 
  at NUnit.Framework.Assert.AreEqual (System.Object expected, System.Object actual, System.String message, System.Object[] args) [0x00000] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/nunit24/NUnitFramework/framework/Assert.cs:886 
  at NUnit.Framework.Assert.AreEqual (System.Object expected, System.Object actual, System.String message) [0x00000] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/nunit24/NUnitFramework/framework/Assert.cs:900 
  at MonoTests.Mono.Unix.UnixUserTest.NonReentrantSyscalls () [0x00047] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/class/Mono.Posix/Test/Mono.Unix/UnixUserTest.cs:92 
at MonoTests.Mono.Unix.UnixUserTest.NonReentrantSyscalls () [0x00083] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/class/Mono.Posix/Test/Mono.Unix/UnixUserTest.cs:98
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /private/tmp/source/bockbuild/profiles/mono-mac-release/build-root/mono-2.11/_build/mono-2.11.git/mcs/class/corlib/System.Reflection/MonoMethod.cs:221

make[2]: *** [run-test-lib] Error 1
make[1]: *** [do-run-test] Error 1
Comment 1 Jonathan Pryor 2012-10-24 14:06:28 UTC
I'm unable to reproduce this on my Mountain Lion machine, even within `csharp -r:Mono.Posix.dll`:

> csharp> using Mono.Unix;
> csharp> var r = UnixUserInfo.GetLocalUsers().First(u => u.UserName == "root");
> csharp> r;
> root:*:0:0:System Administrator:/var/root:/bin/sh
> csharp> var u = new UnixUserInfo("root");
> csharp>  u;
> root:*:0:0:System Administrator:/var/root:/bin/sh
> csharp> u.RealName == r.RealName;
> true

What's really odd is the expected value:

>  Expected: <root:********:0:0:System

UnixUserInfo.ToString() is Passwed.ToString():

	public override string ToString ()
		return string.Format ("{0}:{1}:{2}:{3}:{4}:{5}:{6}",
			pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell);

Where'd all the extra ':'s go?

My best guess is that pw_gecos contains a newline after "System" instead of a space (how would that happen), and NUnit isn't showing the full expected string, but only up to the first newline (unverified hope/assumption, otherwise I'm going with "mono's crashing!").

Further sanity check (in addition to above `csharp` invocation), if you have time: write a C program which uses getpwent(3) to see if struct passwd::pw_gecos contains a newline/etc. You may also want to double-check the contents of /etc/passwd.
Comment 2 Martin Baulig 2012-10-24 23:22:04 UTC
Does your UnixUserInfo.GetLocalUsers() return 1 or 2 entries for root ?

Mine returns two, one is
root:********:0:0:System Administrator:/var/root:/bin/sh
the other one
root:*:0:0:System Administrator:/var/root:/bin/sh

There is only one entry for root in my /etc/passwd.  Checking getpwent() now.
Comment 3 Martin Baulig 2012-10-24 23:48:53 UTC
Ok, the duplicate entry for root actually comes from getpwent():
Comment 4 Jonathan Pryor 2012-10-25 10:13:22 UTC
> Does your UnixUserInfo.GetLocalUsers() return 1 or 2 entries for root ?

Mine returns (2):

> csharp> using Mono.Unix;
> csharp> UnixUserInfo.GetLocalUsers().Where(u => u.UserName == "root").Count(); 
> 2

However, they both return the same data:

> csharp> UnixUserInfo.GetLocalUsers().Where(u => u.UserName == "root").Select(u => u.ToPasswd().ToString());
> { "root:*:0:0:System Administrator:/var/root:/bin/sh", "root:*:0:0:System Administrator:/var/root:/bin/sh" }

Note that the look the same, visually, and that the password field is identical for me, whereas they're not the same for you ("********" vs. "*").


> csharp> var roots = UnixUserInfo.GetLocalUsers().Where(u => u.UserName == "root");                          
> csharp> roots.ElementAt(0).Equals(roots.ElementAt(1));
> true

So they are in fact the same on my machine. :-/

It doesn't surprise me that getpwent() would return duplicates, as getgrent() does as well (with even odder behavior):


Perhaps the UnixUserInfo test needs to do the same: check for duplicate entries and only deal with the first one returned?
Comment 5 Martin Baulig 2016-11-11 09:37:45 UTC
Closing ancient bugs, please reopen if you're still having this problem.