Compare commits

...
Author SHA1 Message Date
Rodrigo Kumpera 40f92d5cb6 [System] Fix process creation when UseShellExecute is set to false.
This fixes the behavior of process spawning when UseShellExecute is
set to true.

The right behavior is to return no process only when we used the system
launcher. So, spawning /bin/cat should behave in the same way independent
of how UseShellExecute is set.
2014-02-06 15:56:14 -05:00
Rodrigo Kumpera 0895a37089 Revert "[runtime] Don't pass SEE_MASK_NOCLOSEPROCESS to ShellExecuteEx as we don't care for the launched process. Part 1/3 of Bug #16119."
This reverts commit 6c06d10995.
2014-02-06 15:56:01 -05:00
Zoltan Varga 5b8ba7e3ca [runtime] Put back ensure_synch_cs_set () which was removed in a157ac79e8 to work around some shutdown crashes. 2014-02-06 20:09:05 +01:00
Alan McGovern 0c35cf5ef0 [Microsoft.Build.Utilities] Properly escape/unescape ItemSpec
With tests.
2014-01-28 16:28:22 -05:00
Alan McGovern d2a1623a18 [Microsoft.Build.Utilities] Fix the escaping/unescaping of ItemSpec
This should hopefully fix compilation of projects using files with
names like '[email protected]' in various places like embedded resources
or content items which must be copied to the output directory.

With tests.
2014-01-28 16:28:16 -05:00
Alan McGovern cb725ff9de [Microsoft.Build.Engine] Fix the escaping/unescaping of FullPath metadata
It is incorrect to escape the FullPath metadata for a build item when
we invoke GetEvaluatedMetadata. If we do this we end up completely breaking
every file with a special character in it as things like this would always
fail as we'd pass an escaped path to the filesystem:
	File.Exists (item.GetEvaluatedMetadata ("FullPath"))

The iOS designer encountered this issue when we added retina images
called "[email protected]" to our solution.

With tests.
2014-01-28 16:28:11 -05:00
Rodrigo Kumpera 50f293135f Properly compare assembly versions when performing binding. Fixes #17368.
The right way to compare assembly versions is by translating the major/minor
pair into a single number and compare that.

Since each element can only be one byte long, we multiply major by 256
before adding to minor.

This solves the problem where version 100.0.0.0 was not after 3.5.0.0.
2014-01-27 16:39:38 -05:00
Aaron Bockover 11e1a399ac driver.c: Revert "Update message"
This reverts commit 85841d0bbd.

Some scripts unfortunately depend on the verbage "Mono JIT compiler"
in the "mono --version" message. While this was never a blessed
or supported way of getting the version (use pkg-config) of Mono,
nonetheless this breaks some important stuff. We can use the better
message in the (somewhat distant) future.
2014-01-16 18:05:25 -05:00
Zoltan Varga 61740f8417 [jit] Use the jit lock instead of the loader lock in mono_tramp_info_register (). 2014-01-15 18:51:58 +01:00
13 changed files with 165 additions and 29 deletions

No files matched your search

@@ -167,9 +167,7 @@ namespace Microsoft.Build.BuildEngine {
{
if (ReservedNameUtils.IsReservedMetadataName (metadataName)) {
string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, evaluatedMetadata);
return string.Equals (metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
? MSBuildUtils.Escape (metadata)
: metadata;
return MSBuildUtils.Unescape (metadata);
}
if (evaluatedMetadata.Contains (metadataName))
@@ -181,10 +179,7 @@ namespace Microsoft.Build.BuildEngine {
public string GetMetadata (string metadataName)
{
if (ReservedNameUtils.IsReservedMetadataName (metadataName)) {
string metadata = ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, unevaluatedMetadata);
return string.Equals (metadataName, "fullpath", StringComparison.OrdinalIgnoreCase)
? MSBuildUtils.Escape (metadata)
: metadata;
return ReservedNameUtils.GetReservedMetadata (FinalItemSpec, metadataName, unevaluatedMetadata);
} else if (unevaluatedMetadata.Contains (metadataName))
return (string) unevaluatedMetadata [metadataName];
else
@@ -284,6 +284,40 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
Assert.AreEqual (String.Empty, item.GetMetadata ("AccessedTime"), "A13");
}
[Test]
public void GetMetadata_UnescapedItemSpec ()
{
string itemInclude = "a;b;c";
string escapedItemInclude = Utilities.Escape (itemInclude);
item = new BuildItem ("name", itemInclude);
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (escapedItemInclude), "#1a");
Assert.IsTrue (item.GetEvaluatedMetadata ("FullPath").EndsWith (itemInclude), "#1b");
Assert.AreEqual (itemInclude, item.GetMetadata ("FileName"), "#2b");
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("FileName"), "#2b");
Assert.AreEqual (itemInclude, item.GetMetadata ("Identity"), "#3a");
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("Identity"), "#3b");
}
[Test]
public void GetMetadata_EscapedItemSpec ()
{
string itemInclude = "a;b;c";
string escapedItemInclude = Utilities.Escape (itemInclude);
item = new BuildItem ("name", escapedItemInclude);
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (escapedItemInclude), "#1a");
Assert.IsTrue (item.GetEvaluatedMetadata ("FullPath").EndsWith (itemInclude), "#1b");
Assert.AreEqual (escapedItemInclude, item.GetMetadata ("FileName"), "#2b");
Assert.AreEqual (itemInclude, item.GetEvaluatedMetadata ("FileName"), "#2b");
Assert.AreEqual (escapedItemInclude, item.GetMetadata ("Identity"), "#3a");
Assert.AreEqual ("a;b;c", item.GetEvaluatedMetadata ("Identity"), "#3b");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void TestGetMetadata2 ()
+1 -1
View File
@@ -13,7 +13,7 @@ LIB_MCS_FLAGS = \
/r:System.dll \
/r:$(XBUILD_FRAMEWORK)
TEST_MCS_FLAGS = /r:$(XBUILD_FRAMEWORK) -r:System.dll -r:System.Core.dll
TEST_MCS_FLAGS = /r:$(XBUILD_ENGINE) /r:$(XBUILD_FRAMEWORK) -r:System.dll -r:System.Core.dll
include $(XBUILD_DIR)/xbuild_test.make
include ../../build/library.make
@@ -64,7 +64,6 @@ namespace Microsoft.Build.Utilities
if (itemSpec == null)
throw new ArgumentNullException ("itemSpec");
this.itemSpec = itemSpec;
this.metadata = CollectionsUtil.CreateCaseInsensitiveHashtable ();
// FIXME: hack
@@ -108,9 +107,9 @@ namespace Microsoft.Build.Utilities
public string GetMetadata (string metadataName)
{
if (ReservedNameUtils.IsReservedMetadataName (metadataName))
return ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName, metadata);
return MSBuildUtils.Unescape (ReservedNameUtils.GetReservedMetadata (ItemSpec, metadataName, metadata));
else if (metadata.Contains (metadataName))
return (string) metadata [metadataName];
return MSBuildUtils.Unescape ((string)metadata [metadataName]);
else
return String.Empty;
}
@@ -153,7 +152,7 @@ namespace Microsoft.Build.Utilities
}
public string ItemSpec {
get { return itemSpec; }
get { return MSBuildUtils.Unescape (itemSpec); }
set { itemSpec = value; }
}
@@ -77,7 +77,8 @@ namespace Mono.XBuild.Utilities {
switch (metadataName.ToLowerInvariant ()) {
case "fullpath":
return Path.GetFullPath (itemSpec);
var unescapedItemSpec = MSBuildUtils.Unescape (itemSpec);
return MSBuildUtils.Escape (Path.GetFullPath (unescapedItemSpec));
case "rootdir":
if (Path.IsPathRooted (itemSpec))
return Path.GetPathRoot (itemSpec);
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
@@ -115,6 +116,50 @@ namespace MonoTests.Microsoft.Build.Utilities {
new TaskItem ("itemspec", null);
}
[Test]
public void TestCtor_EscapedSpecialChar ()
{
// If we instantiate with the *escaped* metadata, it's unescaped automatically
var metadata = "[email protected]";
var escapedMetadata = global::Microsoft.Build.BuildEngine.Utilities.Escape ("[email protected]");
var item = new TaskItem (escapedMetadata);
item.SetMetadata ("mine", escapedMetadata);
Assert.AreEqual (metadata, item.ItemSpec, "#1");
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
Assert.AreEqual (metadata, item.GetMetadata ("mine"), "#5");
}
[Test]
public void TestCtor_EscapedSpecialChar_BrokenEscaping ()
{
// This is badly escaped, but MSBuild does not care.
var metadata = "foo%[email protected]";
var item = new TaskItem (metadata);
Assert.AreEqual (metadata, item.ItemSpec, "#1");
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
}
[Test]
public void TestCtor_UnescapedSpecialChar ()
{
// If we instantiate with unescaped metadata, we get the same value back
var metadata = "[email protected]";
var item = new TaskItem (metadata);
item.SetMetadata ("mine", metadata);
Assert.AreEqual (metadata, item.ItemSpec, "#1");
Assert.AreEqual (metadata, item.GetMetadata ("Identity"), "#2");
Assert.AreEqual (Path.GetFileNameWithoutExtension (metadata), item.GetMetadata ("FileName"), "#3");
Assert.IsTrue (item.GetMetadata ("FullPath").EndsWith (metadata), "#4");
Assert.AreEqual (metadata, item.GetMetadata ("mine"), "#5");
}
[Test]
public void TestCopyConstructor ()
{
@@ -240,5 +285,19 @@ namespace MonoTests.Microsoft.Build.Utilities {
item = new TaskItem ("lalala");
item.SetMetadata ("Identity", "some value");
}
[Test]
public void TestSetItemSpec ()
{
var itemSpec = "[email protected]";
var escapedItemSpec = global::Microsoft.Build.BuildEngine.Utilities.Escape (itemSpec);
var item = new TaskItem ("foo");
item.ItemSpec = itemSpec;
Assert.AreEqual (itemSpec, item.ItemSpec, "#1");
item.ItemSpec = escapedItemSpec;
Assert.AreEqual (itemSpec, item.ItemSpec, "#2");
}
}
}
@@ -918,7 +918,7 @@ namespace System.Diagnostics {
IntPtr stderr,
ref ProcInfo proc_info);
private static bool Start_shell (ProcessStartInfo startInfo)
private static bool Start_shell (ProcessStartInfo startInfo, Process process)
{
ProcInfo proc_info=new ProcInfo();
bool ret;
@@ -945,6 +945,9 @@ namespace System.Diagnostics {
throw new Win32Exception (-proc_info.pid);
}
process.process_handle = proc_info.process_handle;
process.pid = proc_info.pid;
process.StartExitCallbackIfNeeded ();
return(ret);
}
@@ -1156,7 +1159,7 @@ namespace System.Diagnostics {
if (startInfo.UseShellExecute) {
if (!String.IsNullOrEmpty (startInfo.UserName))
throw new InvalidOperationException ("UserShellExecute must be false if an explicit UserName is specified when starting a process");
return (Start_shell (startInfo));
return (Start_shell (startInfo, process));
} else {
return (Start_noshell (startInfo, process));
}
@@ -1176,12 +1179,9 @@ namespace System.Diagnostics {
if (startInfo == null)
throw new ArgumentNullException ("startInfo");
Process process = null;
if (!startInfo.UseShellExecute) {
process = new Process();
process.StartInfo = startInfo;
}
if (Start_common(startInfo, process))
Process process = new Process();
process.StartInfo = startInfo;
if (Start_common(startInfo, process) && process.process_handle != IntPtr.Zero)
return process;
return null;
}
+3
View File
@@ -380,6 +380,9 @@ gboolean ShellExecuteEx (WapiShellExecuteInfo *sei)
SetLastError (ERROR_INVALID_DATA);
return FALSE;
}
/* Shell exec should not return a process handle when it spawned a GUI thing, like a browser. */
CloseHandle (process_info.hProcess);
process_info.hProcess = NULL;
}
if (sei->fMask & SEE_MASK_NOCLOSEPROCESS) {
+9 -2
View File
@@ -2562,16 +2562,23 @@ assembly_binding_info_parsed (MonoAssemblyBindingInfo *info, void *user_data)
domain->assembly_bindings = g_slist_append_mempool (domain->mp, domain->assembly_bindings, info_copy);
}
static int
get_version_number (int major, int minor)
{
return major * 256 + minor;
}
static inline gboolean
info_major_minor_in_range (MonoAssemblyBindingInfo *info, MonoAssemblyName *aname)
{
int aname_version_number = get_version_number (aname->major, aname->minor);
if (!info->has_old_version_bottom)
return FALSE;
if (info->old_version_bottom.major > aname->major || info->old_version_bottom.minor > aname->minor)
if (get_version_number (info->old_version_bottom.major, info->old_version_bottom.minor) > aname_version_number)
return FALSE;
if (info->has_old_version_top && (info->old_version_top.major < aname->major || info->old_version_top.minor < aname->minor))
if (info->has_old_version_top && get_version_number (info->old_version_top.major, info->old_version_top.minor) < aname_version_number)
return FALSE;
/* This is not the nicest way to do it, but it's a by-product of the way parsing is done */
+17 -1
View File
@@ -604,7 +604,7 @@ MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoPr
gboolean ret;
shellex.cbSize = sizeof(SHELLEXECUTEINFO);
shellex.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_UNICODE;
shellex.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE;
shellex.nShow = proc_start_info->window_style;
shellex.nShow = (shellex.nShow == 0) ? 1 : (shellex.nShow == 1 ? 0 : shellex.nShow);
@@ -634,6 +634,22 @@ MonoBoolean ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoPr
}
ret = ShellExecuteEx (&shellex);
if (ret == FALSE) {
process_info->pid = -GetLastError ();
} else {
process_info->process_handle = shellex.hProcess;
process_info->thread_handle = NULL;
/* It appears that there's no way to get the pid from a
* process handle before windows xp. Really.
*/
#if defined(HAVE_GETPROCESSID) && !defined(MONO_CROSS_COMPILE)
process_info->pid = GetProcessId (shellex.hProcess);
#else
process_info->pid = 0;
#endif
process_info->tid = 0;
}
return (ret);
}
+22
View File
@@ -323,9 +323,31 @@ static gboolean handle_remove(MonoInternalThread *thread)
return ret;
}
static void ensure_synch_cs_set (MonoInternalThread *thread)
{
CRITICAL_SECTION *synch_cs;
if (thread->synch_cs != NULL) {
return;
}
synch_cs = g_new0 (CRITICAL_SECTION, 1);
InitializeCriticalSection (synch_cs);
if (InterlockedCompareExchangePointer ((gpointer *)&thread->synch_cs,
synch_cs, NULL) != NULL) {
/* Another thread must have installed this CS */
DeleteCriticalSection (synch_cs);
g_free (synch_cs);
}
}
static inline void
lock_thread (MonoInternalThread *thread)
{
if (!thread->synch_cs)
ensure_synch_cs_set (thread);
g_assert (thread->synch_cs);
EnterCriticalSection (thread->synch_cs);
}
+1 -1
View File
@@ -1542,7 +1542,7 @@ mono_main (int argc, char* argv[])
char *build = mono_get_runtime_build_info ();
char *gc_descr;
g_print ("Mono Runtime Engine version %s\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
g_print ("Mono JIT compiler version %s\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
g_free (build);
g_print (info);
gc_descr = mono_gc_get_description ();
+4 -4
View File
@@ -670,9 +670,9 @@ mono_tramp_info_register (MonoTrampInfo *info)
copy->code_size = info->code_size;
copy->name = g_strdup (info->name);
mono_loader_lock_if_inited ();
mono_jit_lock ();
tramp_infos = g_slist_prepend (tramp_infos, copy);
mono_loader_unlock_if_inited ();
mono_jit_unlock ();
mono_save_trampoline_xdebug_info (info);
@@ -7104,6 +7104,8 @@ mini_init (const char *filename, const char *runtime_version)
}
#endif
InitializeCriticalSection (&jit_mutex);
/* Happens when using the embedding interface */
if (!default_opt_set)
default_opt = mono_parse_default_optimizations (NULL);
@@ -7113,8 +7115,6 @@ mini_init (const char *filename, const char *runtime_version)
mono_set_generic_sharing_vt_supported (TRUE);
#endif
InitializeCriticalSection (&jit_mutex);
#ifdef MONO_HAVE_FAST_TLS
MONO_FAST_TLS_INIT (mono_jit_tls);
MONO_FAST_TLS_INIT (mono_lmf_addr);