Because the previous implementation of the Exited would not wait on
async_output and async_error to complete before calling the Exited event
that would lead to race condition (observable in the test-runner).
The previous implementation was using the
ThreadPool.RegisterWaitForSingleObject method which, in the case of
Mono, would simply enqueue a work item that would wait on this handle.
So instead of monopolizing a ThreadPool thread for that, we create a
dedicated one that simply call WaitForExit.
On Windows x64 (and possibly other x64 systems) the offset between code
and the called function can be larger than 32 bits, but amd64_call_code
is just a wrapper around x86_call_code.
Use a global condition variable as opposed to one per parked thread.
This remove any memory passed to the interrupt token, as this could be
an issue.
The problem comes from the fact that a destroy on a cond variable could
make a wait on this cond variable fail with EINVAL, and this would
trigger an assertion in the mono-mutex code.
These tests could fail randomly (timing issues) and this would lead to
unhandled exceptions. By using Task, instead of the ThreadPool directly,
we avoid these cases. We also ensure to wait for these tasks so we get
the test failing at the right moment and place.
There was a recursive lock because of the interaction between
worker_kill and work_wait_interrupt, but as a matter of fact it is not
needed. This is because we cannot have an interrupt token with
worker_wait_interrupt, and the current thread in active_threads at
the same time.
By installing interrupt token around the blocking syscalls, we make it possible to abort them with signals.
Previously, the only way to interrupt a blocking syscall, would have been to dispose of the SafeSocketHandle associated to the socket. But that make it impossible to abort the following case:
- thread T1 accept a socket S and launch T2 (as a background thread) to receive on S
- T2 block on receive
- T1 (the main thread) quit, and the shutdown code try to abort T2
T2 would never be aborted, because S would never return from its blocking syscall, and that's because T2:
- would still have a reference to S, making it impossible to call the finalizer on S
- will not call Dispose on S before returning from the blocking syscall
This fixes the hang observed on System.Net.HttpWebRequestTest.GetRequestStream with the cooperative GC.
The timeout before exiting a worker thread is random to limit the worst case scenario where, if the timeout is set to N seconds, the user would launch a lot of work item simultaneously, at an interval of N + 1 seconds. In this case, we would have to kill all the threads at once, and starts them all over again 1 second later. The randomization makes the creation and destruction more linear in time, and avoid burst.
mini-generic-sharing.c (get_shared_gparam): This function is used to produce placeholder types
to be used in the sharing instances that are actually JIT'd.
The problem comes from creating a MonoGenericParam whose image is corlib but it's allocated on
a different image.
This becomes an issue in metadata.c:mono_metadata_get_generic_inst when computing the image set
the generic instance should live in. By setting the generic param image to corlib we effectively
lie to the ImageSet code about what are the images.
So, say we have assembly A and we call get_shared_gparam on a type on this assembly. The returned type
will be allocated on A mempool but say it belongs to corlib.
The image set for such a generic instance will be [corlib].
Now we unload A.
Now we have a MonoGenericInstance in the [corlib] mempool that points to memory in the freed
mempool of A.
The fix is to set owner to the right image whenever possible. This would have changed the image
set to [A] (or more likely, [A, corlib]). Either mempool would be freed when A is unloaded.
Testing this behavior turned out to be incredibly more complicated than expected and even though
I managed to produce a test case which has the bad pointers, I could not trigger a crash even with
MONO_DEBUG_ASSEMBLY_UNLOAD=1.
By having the callbacks directly in Socket, we can remove the SocketAsyncWorker class. This also greatly simplify this part of the code, as the callbacks are at the same place as the Begin/End invokes.
This simplifies greatly the native code, as we do not need to worry anymore about all IAsyncResult related work (call the callback, set completed, etc.), and we only need to care about the handle we are watching, and the callback to call when something happens on this handle.
This is quite a big commit, but unfortunatly, it's very hard to break it down in smaller commits as everything is very interwind.
The race condition would manifest in the following code:
```
for (int i = 0, total = 100000; i < total; ++i) {
if (i % 50 == 0)
Console.WriteLine ("{0}/{1}", i, total);
var c1 = new CancellationTokenSource ();
var wh = c1.Token.WaitHandle;
c1.CancelAfter (1);
Thread.Sleep (1);
c1.Dispose ();
}
```
And we would observe the following exception:
```
Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Threading.ManualResetEvent'.
at System.Threading.WaitHandle.CheckDisposed () [0x00016] in /Users/builder/data/lanes/1196/33e00ac6/source/mono/mcs/class/corlib/System.Threading/WaitHandle.cs:426
at System.Threading.EventWaitHandle.Set () [0x0000c] in /Users/builder/data/lanes/1196/33e00ac6/source/mono/mcs/class/corlib/System.Threading/EventWaitHandle.cs:205
at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle:Set ()
at System.Threading.CancellationTokenSource.NotifyCancellation (Boolean throwOnFirstException) [0x00051] in /Users/builder/data/lanes/1196/33e00ac6/source/mono/external/referencesource/mscorlib/system/threading/CancellationTokenSource.cs:723
at System.Threading.CancellationTokenSource.Cancel (Boolean throwOnFirstException) [0x00006] in /Users/builder/data/lanes/1196/33e00ac6/source/mono/external/referencesource/mscorlib/system/threading/CancellationTokenSource.cs:409
at System.Threading.CancellationTokenSource.Cancel () <0x7d75ada8 + 0x00017> in <filename unknown>:0
at System.Threading.CancellationTokenSource.TimerCallbackLogic (System.Object obj) [0x00012] in /Users/builder/data/lanes/1196/33e00ac6/source/mono/external/referencesource/mscorlib/system/threading/CancellationTokenSource.cs:538
```
This would be a race condition between the TimerCallbackLogic call to Cancel and the call to Dispose on another thread. You could trigger it more reliably by putting a Thread.Sleep at CancellationTokenSource.cs:599.
Also fixes ConcurrentCancelLinkedTokenSourceWhileDisposing race condition between Cancel and Dispose, by applying the same pattern as CancellationTokenSource.TimerCallbackLogic.
Value returned from the reader function can be negative and ZStream's
avail_in should not be less than 0 as that value makes no sense and
other parts of code assume it to be equal or higher than 0.
In some more esoteric environments (say bash.exe spawned by
jenkins-slave.exe), the _MASM target's attempts to call ml.exe fail
due to ml.exe missing from $PATH (even when it appears to be fine).
The ClCompile target doesn't suffer this issue, since it uses the
full path to CL.exe rather than assuming CL.exe is in $PATH.
Bundle a lightly patched masm.props to duplicate the ClCompile
target behaviour.
This should have no impact on you unless for some reason you're
using a different MASM to the one provided with MSVC.
Use pthread_setname_np on attach to ensure every thread has a name that Apple's crash dump recognize.
The use pthread_getname_np when doing a thread dump to ensure we get the current thread name.
This cosmetic change will allow us to use Apple crash dumps when troubleshooting suspend issues.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=33558
Several of the Signal-related tests were disabled when running on OS X
because OS X doesn't provide reliable delivery: it will try to deliver
a signal, but if it's already been delivered it won't continue
delivering them. This results in failures such as:
1) MonoTests.Mono.Unix.UnixSignalTest.TestWaitAny : Expected: 23061
But was: 100000
(Note that "Expected" and "actual" are reversed. Oops.)
Thus, signals are delivered, just "not enough."
As It Happens™, Android is similar: running these tests on
Xamarin.Android results in test failures because not enough signals
are received. (It's not as bad as OS X -- only ~10% off -- but it's
not *all* of the signals either.)
Fix the tests so that they *don't* require that we receive as many
signals as we raise. Instead, assert that all of the UnixSignal
instances actually have a UnixSignal.Count value greater than 0, i.e.
that they've been signaled AT ALL.
Loosening up the tests in this manner allows the tests to pass on
OS X, and should allow things to work as expected on Android.
An error condition in an existing ecma xml doc set was brought to my attention
in which an exception was being raised during an `mdoc update`. The cause of this
error was due to the fact that the `GetTypeParameters` method was getting the
list of type parameters from the `MemberName` string.
This patch fixes the error condition by rewriting `MemberName` if it doesn't
match the value from the reflected member.
This add statistical collection of mlpd files. Right now it reports basic statics on number of events
and their overhead, plus general buffer overhead.
This should enable us better understand what a file is made of when figuring out ways to optimize it.
Here's a sample output:
```
Mlpd statistics
Buffer count 13499 overhead 647952 (48 bytes per header)
Event details:
TYPE_GC TYPE_GC_EVENT count 6313 min 4 max 8 bytes 35802
TYPE_GC TYPE_GC_MOVE count 17737 min 12 max 262 bytes 4138055
TYPE_GC TYPE_GC_HANDLE_CREATED count 29833 min 6 max 14 bytes 296379
TYPE_GC TYPE_GC_HANDLE_DESTROYED count 6620 min 5 max 10 bytes 42515
TYPE_METADATA TYPE_END_LOAD count 15926 min 12 max 271 bytes 1112068
TYPE_METHOD TYPE_JIT count 10246 min 26 max 1015 bytes 1043018
TYPE_EXCEPTION TYPE_CLAUSE count 2 min 6 max 6 bytes 12
TYPE_EXCEPTION TYPE_EXCEPTION_BT count 2 min 50 max 50 bytes 100
TYPE_HEAP TYPE_HEAP_START count 1 min 3 max 3 bytes 3
TYPE_HEAP TYPE_HEAP_END count 1 min 4 max 4 bytes 4
TYPE_HEAP TYPE_HEAP_OBJECT count 284536 min 5 max 654 bytes 4823852
TYPE_HEAP TYPE_HEAP_ROOT count 2508919 min 11 max 355 bytes 750970914
TYPE_SAMPLE TYPE_SAMPLE_COUNTERS_DESC count 3 min 256 max 2835 bytes 3712
TYPE_SAMPLE TYPE_SAMPLE_COUNTERS count 1089 min 3 max 402 bytes 66219
TYPE_RUNTIME TYPE_JITHELPER count 21191 min 6 max 29 bytes 252473
```
This is a temporary workaround until get correct fix is properly tested on device.
This makes us be able to compile the runtime with the latest Xcode SDK.
Suppression of negative Elapsed in Stopwatch, this is the comment from the Reference Source:
// When measuring small time periods the StopWatch.Elapsed*
// properties can return negative values. This is due to
// bugs in the basic input/output system (BIOS) or the hardware
// abstraction layer (HAL) on machines with variable-speed CPUs
// (e.g. Intel SpeedStep).
From Matthew Leibowitz (mattleibo)
This is the recommended function for garbage collected languages.
http://sqlite.org/c3ref/close.html
The sqlite3_close_v2() interface is intended for use with host
languages that are garbage collected, and where the order in which
destructors are called is arbitrary.
Falls back to old sqlite3_close if we are on an old system
Useful for ADO.NET where the connection os often closed, but the
commands are re-usable
Mostly visible on Windows operating systems
This snippet should fail with a System.IO.IOException using the
current build of Mono on Windows:
string filename = "test_" + Guid.NewGuid ().ToString ("N") + ".db";
SqliteConnection conn = new SqliteConnection ("Data Source=" + filename);
conn.Open ();
SqliteCommand cmd = conn.CreateCommand ();
cmd.CommandText = "PRAGMA legacy_file_format;";
cmd.ExecuteScalar ();
// close connection before the command
conn.Dispose ();
// then close the command
cmd.Dispose ();
// the locks should be released, and we should be able to delete the database
File.Delete (filename);
This was in response to a test failure noticed after this pull request was accepted: https://github.com/mono/mono/pull/2012#commitcomment-13325966
The solution was two-fold, the code removed was unecessary as this directory is created elsewhere right before the file is written (and with the correct name in the case of a unified type). Also a small change was made to the makefile to clean up some files which was causing some targets to be skipped, along with moving some targets to the `check-doc-tools` target.
A couple of tests for System.Reflection.MethodBody assumed the code generated
by the compiler will be the same as the one generated by Mono's MCS. However,
when the code is built by CSC in release mode (version that comes with VS2015
was tested) the optimizations remove locals required by the old version of the
tests. Also, CSC orders the locals differently to MCS and that breaks one of
the tests which relied on the declaration order.
Another difference is that CSC and MCS type a certain local variable differently.
The variable being a byte* in source code is output in IL as such by MCS, but CSC
outputs an int8& - a by-ref type.
The tests are built by VS but they are executed by Mono on Android and so the
differences come up as errors.
This commit fixes both issues by working around the differences.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=33370 when it is included in XA
automake 1.13 introduced the flag as default, in 5ad2890c I explicitly set it via AUTOMAKE_OPTIONS
to ensure Jenkins (which is on automake 1.11 on some builders) has the same behavior.
Turns out that the flag isn't recognized by automake versions below 1.11 and so the build fails there.
To fix the problem, remove AUTOMAKE_OPTIONS from the Makefile.am in unit-tests and introduce some clever
code in configure.ac instead to set the flag only on the automake versions that need it.
Adding a new block to the allocated_blocks array is racy with the removal of nulls when sweeping. We wait for sweep to finish to avoid that.
This also handles the problem of allocating degraded objects while sweeping.
This error was generated when iOS(or any other kind of project, that is referencing other project in solution via <ProjectReference>) wanted to get OutputPath of PCL(or any other referenced project) but it failed in case of IDE because wrong conditions(see .targets files changes). Reason this bug was never discovered before is because PCL project was already loaded before with correct configuration/platform so not having AssignProjectConfiguration target executed had no effect. Reason it appeared in this case(Bug 25480) was that .sln and .csproj<ProjectReference> had folder path defined as XamlSamples but actual file system had xamlsamples(notice different chars casing). So projects.TryGet(filePath, out project) failed, hence project had to be reloaded, and then bug from .targets files showed up...
A bit more details about fix: The AssignProjectConfiguration target assigns configurations to the various @(ProjectReference), and is used from targets like ResolveProjectReferences, which are enabled only while building solution files ( $(BuildingSolutionFile) ) or when invoked from the IDE ( $(BuildingInsideVisualStudio) ). But the AssignProjectConfiguration target ignores the IDE case, which breaks usage of ResolveProjectReferences from the same. Fix up to run for both the cases.
Overrides check-local to output an NUnit report of the test results.
It currently creates a single pass/fail test case as this is the easiest solution,
but the test log is included in the report which should be enough to diagnose errors.
Parallelism is disabled here since we need to ensure check-local happens after check
so we can parse test-suite.log. The tests are quite fast so it doesn't hurt much.
We need AUTOMAKE_OPTIONS=parallel-tests so the test-suite.log gets created on automake 1.11.
Threadpool uses poll(2) to watch the file descriptors for activity but
it can sometimes miss that an fd went into error. When that happens the
poll call is interrupted with EAGAIN since the erroneous fd's events have
already been read and there's nothing left in the queue for it. That, in turn,
causes mono to run the loop so quickly that it uses 100% of the CPU. It happens,
for instance, with Xamarin Studio which can utilize two CPU cores to the full while
idling on the opening screen.
This commit makes sure to remove the descriptors with errors from the poll set and
thus preventing the syscall from being interrupted and returning EAGAIN.
Currently only emits a single pass/fail testcase as capturing the individual errors
and test counts would be much more invasive.
The bulk of the logic is copied from mono/mini/emitnunit.pl.
This hang would manifest when running the System test suite, with a thread waiting on a `recv'. This syscall would never be interrupted because the socket it would listen on would never close, as there would still be references to its SafeSocketHandle, so that it would never release the native handle.
The issue came from the fact that, when closing the SocketResponder (via the Dispose and the using), the listening thread would never be aborted/stopped, and it would consequently never be collected, thus never releasing the current socket on which _requestHandler is called, thus never aborting the above `recv' syscall.
The issue would arise with the cooperative GC as well as the premptive one.
Multiple threads listening to the same address and port are not possible
before linux 3.9 kernel, where the socket option SO_REUSEPORT was
introduced.
This commit makes TcpDoubleBind sensible to this OS capability.
Use gsize instead of gssize when checking the encodings array for
codepage numbers. When a char* is pointing to the upper half of the
address space, it will be otherwise converted to a negative number.
ConvertTimeTests_LocalUtc runs ConvertTimeTests fixture with
TimeZoneInfo.Local set to TimeZoneInfo.Utc.
Removed redundant test ConvertFromToUtc_LocalAsUtc.
Fixes TimeZoneInfo.ConvertTimeFromUtc and related tests when
TimeZoneInfo.Local is equal to TimeZoneInfo.Utc.
In .NET if we set TimeZoneInfo.Local to TimeZoneInfo.Utc by using
reflection.
```
var cachedDataField = typeof (TimeZoneInfo).GetField ("s_cachedData",
BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic);
var localField = cachedDataField.FieldType.GetField ("m_localTimeZone",
BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic);
var localFieldObj = cachedDataField.GetValue (null);
localField.SetValue (localFieldObj, DateTimeKind.Utc);
```
We can observe that `TimeZoneInfo.ConvertTimeFromUtc (DateTime.UtcNow,
TimeZoneInfo.Local).Kind` is DateTimeKind.Utc.
By looking at reference source [code](http://referencesource.microsoft.com/#mscorlib/system/timezoneinfo.cs,211)
we can also confirm that while getting a time zone corresponding kind,
Utc is prioritized over Local.
This commit reverts changes introduced by
60d5b39e46 that were prioritizing Local
over Utc and changes tests to expect Utc kinds instead of Local when
TimeZoneInfo.Local is equal to TimeZoneInfo.Utc.
TimeZoneInfo.ConvertTimeFromUtc(utcDate, TimeZoneInfo.Local) now returns a date of kind
DateTimeKind.Local when TimeZoneInfo.Local is equal to TimeZoneInfo.Utc.
Fixes#33471.
The comparison was failing because we were still using the method field (instead of the Method property), which would then return, in the case of a delegate to a virtual function, the method on the base class, instead of the method on the derived class. Updated the test cases to check that too.
Unfortunately the projects in the Facades share the same names as our main class library assembly names which causes us to overwrite their inputs here.
The refresh timeout starts running before the actual DNS request is sent, which means on systems with a
slow DNS server the cached value has already timed out when the response is received, making the test fail.
Bumping the timeout to 2s should fix the test on Jenkins.
FRAMEWORK_VERSION_MAJOR is 2 for the mobile profiles, so filtering
on the profile name will do nothing at all.
This means listing the mobile profiles here is completely redundant,
so simplify to just building when FRAMEWORK_VERSION_MAJOR=4.
Instruments uses library interposing to record calls to mmap and munmap. It does take lock within the interposers
which means the async suspend could suspend a thread holding such lock while sgen tries to mmap more memory in,
causing a deadlock.
The workaround is to protect our uses of mmap and munmap in the hopes that they are enough to reduce the likelihood
of those hangs happening.
The previous 2ms timeout was way too short and the test failed frequently.
Also switch to Assert.AreSame/AreNotSame instead of AreEqual/AreNotEqual since
we want to ensure the same object is returned and not just an equal one.
The parallel build infrastructure we're trying to leverage for Facades depends on the profile name when populating the parallel lists - the default profile is now named "net_4_x", so variables with "net_4_5" in them are not considered - causing the whole Facades/ directory to be skipped
In supplement of the changes submitted in 09b97cba2e, there were
some additional edge cases that were not originally considered, and so this patch resolves these
additional issues. In particular, there was a bug in the `RemoveApiStyle` method that wasn't
checking the value of the `apistyle` attribute before removing it. This caused members to be
stripped of apistyle inadvertently.
There was an issue in the type removal code that caused
too many files to be removed. This patch adds additional checks to make sure that a file isn't
going to be removed if it contains members in the other style that shoulnd't be removed
Finally, there was an issue that arose after the aforementioned changes in the `OrderTypeAttributes`
method. It was somewhat counterintuitive, but it wasn't allowing the reordering of attributes
with the `.Remove` method (throwing an exception). Not entirely sure why this was happening,
but using the `.RemoveNamedItem` method worked around the issue.
This test is very fragile as it depends on appdomain global state.
In this case the current thread culture.
The problem with CurrentCulture is it's behavior that once set, it can't
be unset, IOW, revert to follow DefaultThreadCurrentCulture.
This meant that test ordering played a huge deal here and it took a few
tries to learn what was going on.
The way to fix this is to run the test itself from a thread that we
can ensure that won't have CurrentCulture set. This includes TP threads
or new threads.
I opted to use a TP thread as there probably is one available already
when the test runs.
In .NET an URI constructor from "/foo" and UriKind.RelativeOrAbsolute is
relative whereas in mono it is assumed as an absolute file path.
This adds another workaround that changes all Uri constructor calls to
behave like .NET when receiving UriKind.RelativeOrAbsolute.
The environment variable workaround consists in setting
MONO_URI_DOTNETRELATIVEORABSOLUTE=true before starting the application:
Reflection workaround:
```
if (Type.GetType ("Mono.Runtime") != null)
typeof (Uri).GetField ("useDotNetRelativeOrAbsolute",
BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic).
SetValue (null, true);
```
WARNING: The workarounds change the behavior of all Uri constructor calls.
Unexpected problems can occur if an used library relies on
UriKind.RelativeOrAbsolute to parse absolute file paths.
The GC handle counters were not being registered; probably got lost when
rebasing this code atop the independent SGen. This also avoids 64-bit
CAS on these counters, so that platforms without it still have stats.
Previously we had two places where GC handles were cleared:
`mono_gchandle_free_domain()`, which was called with the world running.
`mono_gc_clear_domain()`, which ran with the world stopped.
The first one doesn't do anything anymore now. The reason the callback is
still there is because that's where Boehm clears the GC handles.
The previous code was hard to make lock-free because it was trying to
coordinate three separate buffers: one of GC handles, one of a
free-bitmap, and one used to get the domain ID for an expired weak
reference. Now all of this information is stored in a single tagged
pointer per entry.
* Make the GC lock non-recursive again.
* Correctly null links for domain unloading.
* Ensure that non-weak handles are registered as roots using the
correct descriptors.
These hashes were inefficiently duplicating the information in the
common GC handle data tables.
* Make GC lock recursive. This must be reverted when the GC handles
table is made lock-free.
* Refactor handle allocation and handle data manipulation to avoid
duplication and magic numbers.
* Use GC handles in refqueue and monitors, because the dislink
machinery no longer exists.
We can avoid loading custom attributes by checking field->offset == -1. This
won't always be the case for a special static field at all stages during class
loading but it'll speed up the most frequent cases.
This is based on Windows 10 + .NET 4. I'm assuming until told otherwise that
the test was written based on an earlier .NET and the behavior has changed.
Linux code uses a netlink socket to be notified about network interface
changes. The code is a bit racy and for that reson it can happen that
the LinuxNetworkChange.OnDataAvailable handler is called after the
socket is destroyed (from a timer event) and socket stored in an
instance variable is already null. This is a race most probably
introduced by the new threadpool or TPL code as it started to happen in
several places (mostly BCL tests on Android, but it's *not* specific to
Android).
The workaround here serves as a quick band-aid to be able to move on,
but a more thorough review of the socket code will be required.
If SUBDIRS is not set, then no files which aren't explicit Makefile targets will get included - which in this case means the only file in Facades/ in tarballs is the Makefile itself.
When HttpWebRequest is used to download infinite (ContentLength is not set) response from web server, we must be sure that after reading 2 GB (Int32.MaxValue) of data our internal classes are still working correctly
This change is released under the MIT license.
corlib/System.MathTest.Pow would fail at test #45 because the native pow implementation would return NaN (instead of 1) for pow (-1, Double.MaxValue).
The previous implementation treated this case for exponents bigger than 9007199254740991.0 and smaller than -9007199254740991.0
Change is to fix following exception. Which suspect is cause by two threads both call remove at same time.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[System.ServiceModel.Channels.IDuplexSessionChannel].RemoveAt (Int32 index) [0x00000] in <filename unknown>:0
at System.Collections.Generic.SynchronizedCollection`1[System.ServiceModel.Channels.IDuplexSessionChannel].RemoveItem (Int32 index) [0x00000] in <filename unknown>:0
at System.Collections.Generic.SynchronizedCollection`1[System.ServiceModel.Channels.IDuplexSessionChannel].RemoveAt (Int32 index) [0x00000] in <filename unknown>:0
at System.Collections.Generic.SynchronizedCollection`1[System.ServiceModel.Channels.IDuplexSessionChannel].Remove (IDuplexSessionChannel item) [0x00000] in <filename unknown>:0
The problematic scenario is the following: [1]
thread A) [DO_BLOCKING] runnable -> blocking (0) -- i.e, do a pinvoke
thread B) [ASYNC_SUSPEND_REQUESTED] blocking -> blocking (+1) -- thread B tries to suspend thread A
thread A) [ABORT_BLOCKING] blocking -> async_suspend_requested (0) -- i.e, that pinvoke called into a reverse delegate and needs to go back to runnable state
thread A) [STATE_POLL] async_suspend_requested -> self_suspended (0) -- thread A self suspend due to the request from B
If polling witness async suspend, it must notify the initiator of a successful suspend.
If the initiator witness a thread in blocking, it bumps the suspend count, assumes it suspended and don't wait for a notification.
This means that thread A would post to the suspend semaphore but thread B (the suspend initiator) will not wait on it.
Given the initiator won't wait in this case, it makes no sense for abort blocking to put the thread in async_suspend_requested.
The solution is to put it on self_suspend_requested, which won't trigger state_poll to notify.
[1] Read it as: thread) [TRANSITION NAME] old state -> new state (suspend count delta) -- explanation
Add asserts to both mono_threads_begin_global_suspend and mono_threads_end_global_suspend to ensure
balanced usage of the suspend semaphore.
The suspend semaphore must end a suspend operation at zero, meaning there must an equal number of
post and wait calls.
This ensure the initiator can't jump the gun when waiting for pending suspends by consuming a
post from a previous suspend/resume op.
Joao reported that the facades build broke with 9022df4421
as it tried to compile monodroid assemblies and this attempt to compile System.IO.Pipes
which in turn needs a type not presented on Android: SafePipeHandle
This should fix that
Specifically, when updating classic and unified assemblies, members
that were completely removed from one or both assemblies were not
being removed from the XML. This patch updates mdoc's `DeleteMember`
method to properly handle deletion in all scenarios (normal, classic, unified).
Of course, deletion will still not happen if one of two things is true:
- `--delete` is *not* passed into the `mdoc update` call and the member node
contains existing documentation.
- `--preserve` *is* passed into the `mdoc update` invocation.
In both of those cases, the member will not be deleted, and a message stating
as such will be written as a warning to the output.
The sparse-array approach led to better insert/remove performance, by allowing a O(1) access, but led to memory consumption issue. The kernel would, for example, have to parse the whole array, even if it's mostly empty, and that can be an issue for large arrays.
StackTrace.ToString format was different from Exception.ToString.
StackTrace.ToString had an identation of 3 spaces instead of 2, outputed
"line " before the line number which Exception.ToString does not, and it
did not print offsets.
This change allows StackTrace.ToString output to be used by the mono-symbolicate tool.
In amd64 when possible 32bit instructions and registers are usedi
instead of 64bit ones.
Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus
maintaining the native code size between compilations.
In amd64 when i8const are use with values within the first 32 bits
instructions and registers used can be optimized to their 32 bit
versions.
Setting MONO_DEBUG=single-imm-size variable disables such optimizations
and guarantee that the the generated native code size is independent
of the i8const values.
The Android NDK decalres the `struct timeval` struct in <sys/time.h>.
Update sys-socket.c to #include <sys/time.h> to fix compilation
with the Android NDK.
A GC Safepoint require the thread to be in GC unsafe mode to run properly.
Both mono_threads_finish_blocking and mono_threads_reset_blocking_start are called
in GC Safe mode, which would cause them to assert in checked-build.
mono_threads_finish_blocking is called after a pinvoke finished, which means the thread will
still be in blocking mode.
mono_threads_reset_blocking_start is called by reverse pinvoke wrappers before calling managed
code, so it will be in blocking mode too.
This looks like something checked-build should catch by setting the polling variable more frequently.
We use the lowest bit in the LOS object size to denote whether the object is
marked/pinned, so we can't directly use the size. Use the getter function
instead.
When HttpWebRequest is used to download infinite (ContentLength not set) response from web server, we can see that after reading about 2 GB (Int32.MaxValue) of data, totalRead variable can be equal to contentLength (which is int32.MaxValue). Then WebConnectionStream thinks that all data is received (see soft condition totalRead >= contentLength), but this is not correct.
This change is released under the MIT license.
The main change is the fd will not be removed from the backend when there is no event to poll, but only when we close the socket. This also reduce the number of functions of the backend.
In amd64 when possible 32bit instructions and registers are usedi
instead of 64bit ones.
Using MONO_DEBUG=single-imm-size avoids 32bit optimizations thus
maintaining the native code size between compilations.
In amd64 when i8const are use with values within the first 32 bits
instructions and registers used can be optimized to their 32 bit
versions.
Setting MONO_DEBUG=single-imm-size variable disables such optimizations
and guarantee that the the generated native code size is independent
of the i8const values.
We used to construct exception stack traces as string at throw site (for dynamic methods) but
that does not work correctly because exception stack trace can be decomposed via
new StackTrace (exception) or merged via ExceptionDispatchInfo both of them need the exception
stack in raw form and not as a string.
Further the format used by local stack builder was not same as format used by
System.Diagnostics.StackTrace.
The orignal reason for the specialization was that dynamic method can be collected
before stack is rendered which leads to stack frame to be reported as
at <unknown method> instead of
at (wrapper dynamic-method)
That should be addressed by gc-link between dynamic method and exception or
stack-frame.
The problem is connected with "chunks" field in ChunkStream class. As you can see in "ReadFromChunks" method, the number of elements of this array continuously grows, because array's elements are not removed but just set to null. So, every subsequent call of this method will be slower than previous and will use additional memory more and more infinitely. Yes, we have "ResetBuffer" method than could clear "chunks" array, but nobody call it when the connection is infinite.
This change is released under the MIT license.
A private overload of the public GetSystemTimeZones() method was added in 4dc9a90d7f.
This broke code that tried to access that method via reflection and expected that there be only one.
Fixing this by renaming the private method to GetSystemTimeZonesCore (which is also more aligned with FindSystemTimeZoneByIdCore).
This was introduced by https://github.com/mono/mono/commit/5604e0b5940a1df7059d11158b36fbde9a3c056d.
For some reason we were getting duplicate assembly labels, this fixes it.
```[8:45:15] /var/folders/hv/lh9y7pps1vbfsc737h_nl4mh0000gp/T//cczYhnuB.s: Assembler messages:
[8:45:15] /var/folders/hv/lh9y7pps1vbfsc737h_nl4mh0000gp/T//cczYhnuB.s:9012: Error: symbol `L0' is already defined
[8:45:15] make[7]: *** [libmini_la-mini-exceptions.lo] Error 1
[8:45:15] make[7]: *** Waiting for unfinished jobs....```
We actually don't need the length check here. The only place where
the 'ref parameters' could possibly be replaced is at the end of the
private Request() method - to remove the 'IAsyncResult' argument from
and End*() method.
This fixes commit 0b1360c8e3 and bug #32886.
(cherry picked from commit 1d2c58215f)
The test causes the runtime to silently crash in fashion similar to what
real-time signals do to the runtime (a segfault without a single trace
of a crash, causing the process to just hang)
This is needed since the starting thread might block in the threads_lock
waiting for a GC to finish before posting to the completed semaphore.
This will cause the thread creating it to block indefinitely.
mono_thread_info_suspend_lock is, on first sight, a leaf lock. But since it can suspend a thread that is holding other locks,
it has the same global effect of one.
The original design was to pass a lock to the mono_conc_hashtable constructor and
then the write operations would do locking themselves.
That turned out to be a problem for two reasons:
First, it hidden the fact that locking was happening. Every other data structure in
the runtime rely on the caller to perform locking - thus that design ended up been
a lie.
Second, under coop, taking the lock became a problem as leak locks should be taken
in GC Safe mode and other locks should be taken under GC Unsafe mode. Taking a lock
in the wrong GC mode makes the suspend watchdog bark really loudly.
The runtime, funny enough has 2 usages of the conc hashtable, one with the image lock
and one with the domain lock - and each must be taken in a different GC mode. That
meant that either overcomplicating the design, or just removing locking from it.
This commit does that. It removes the mutex from mono_conc_hashtable and hoist locking
around the calls that used to do it.
We were calling mono_string_to_utf8 while in GC safe mode.
It's technically ok'ish to do it as it will probably be pinned by the called, but
we're better off by reducing the surface as much as we can.
Make it possible to suspend the main thread when starting the shutdown of the thread pool.
The problem is that cleanup can take an unbound amount of time.
This is a workaround until we figure out what to do with the embedding API.
We ensure we transition the executed managed code into unsafe mode.
Maybe the right call would be to assert if the caller is not already on it, but that's too soon of a decision to make.
To enable checked builds pass --with-checked-build=yes to autogen/configure.
The current set of checked build macros verify the GC state on function entry.
Android's libc (bionic) defines the _GNU_SOURCE macro but fails to adhere
to the GNU sematics in (at least) one case - the strerror_r function.
The function follows XSI semantics instead of the GNU one which caused our
code to segfault on Android. This patch special-cases Android to use the XSI
semantics for strerror_r. This un-breaks some POSX real-time singals tests.
It also makes provisions for detecting whether the real-time signals are safe
to use on the current platform. They are safe for all platforms desktop Mono
runs on, but they're not safe on most Android platforms.
This product has been discontinued by AMD and we don't even have support for
building this profiler module in the build system anyway; chances are pretty
good that bitrot has set in.
Neither is_socket_async_callback nor is_async_read_handler need to
actually successfully load the classes they're comparing against;
if the classes can't be loaded, then the input class is obviously
not of that class.
This occurs when mscorlib is linked, the classes to compare against
might be linked away.
https://bugzilla.xamarin.com/show_bug.cgi?id=32947
Process names were trimmed to 15 characters. proc_name was used to
retrieve the process name, by looking at its implementation we can see
that it returns a buffer which the size is MAXCOMLEN defined as 16.
When the proc_name result length is equal to 15 (MAXCOMLEN - 1) we now check if
proc_pidpath is able to return a longer process name.
Fixes#32539.
Suspend needs to work in the intermediate state where the mono-thread
is attached but not the managed thread. This happens in the startup
and cleanup paths and leads to crashes there.
The suspend initiator is now responsible to check if the thread is
attached or not. Which is easy, just check lmf/jit_tls.
This new function works differently that others in that it always succeed, but might
provide incomplete data in some cases - like when the thread is not attached.
MONO_OBJECT_SETREF would use mono_gc_wbarrier_set_field which would write over 8 bytes ( *(void**)field = value ), while we want to write over 1 byte here.
This patch improves the handling of vasprint checking.
It switches the unneeded have_vasprintf variable with the
AC_CHECK_FUNCS defined ac_cv_func_vasprintf one.
The test sometimes failed on Jenkins with the timeout assert. Running only this single test locally
with `make check TESTNAME=System.ServiceModel.Dispatcher.Bug652331Test.Bug652331_2` however reproduced
this almost every single time.
It seems that WCF takes a bit to initialize until it accepts connections, so putting a little sleep
fixed this for me locally and running it in a loop for half an hour didn't assert even once.
This patch initialize properly have_vasprintf in case vasprint function is found.
Solves multiple definition of `vasprintf' error in case vasprint is not properly detected.
This commit avoids allocation of new MonoThreadsSync structures for the typical cases of shallow nesting of uncontended locks. The necessary information (owner, nest and status bits) is embedded in the synchronisation field of a MonoObject. The lock is inflated when the nest overflows or when there is contention on the lock.
This greatly improves performance (over 10 times) for the case of locking a lock only a few times, due to the inflation avoidance. It also improves performance up to 25% for the case of locking a thin lock. A decrease in performance (up to 3 times slower) can happen for the case of repetitive nesting of a lock, due to the need of a CAS at each entry/exit.
Disable native fastpaths for now, until they are updated to the new implementation.
Merge notes from Rodrigo:
Remove the enter fast paths in monitor.c as the new code already has them.
The AuthenticateClientAndServer_ClientSendsNoData test sometimes failed on Jenkins,
but the 2s timeout is pretty short (it takes about 0.5s on my fast machine as well).
Increasing it to 5s should allow the test to work on the slower Jenkins machines as well.
Instead of catching the exception and rethrowin it right away, we do not catch it. This simplifies the code, and will give us more insight into the underlying exception.
Also merge mono_async_result_invoke into ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke as it is the only place we use it.
printfs don't always show up in the iOS device log, and exit(1) does
not create a crash report, making these conditions hard to debug
(all you get is "app X exited with code 1", and then you need to
attach a native debugger and break on 'exit' to figure out more).
g_error will end up producing output using NSLog (which always
shows up in the device log), and a crash report as well, making
debugging a lot easier.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=25086
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=31875
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=32171
Reverts and reworks commit bcfec743.
The problem is that when Xamarin.Android is running mkbundle, dos2unix
should NEVER be used, because the Android NDK NEVER wants Unix-like
paths, which is what dos2unix creates.
Commit bcfec743 attempted to fix this by removing dos2unix invocation
from the Xamarin.Android codepath.
The problem is that the logic was backwards: it removed dos2unix
invocation when XAMARIN_ANDROID was NOT defined, and PRESERVED
dos2unix invocation when XAMARIN_ANDROID WAS defined.
Meaning commit bcfec743 broke normal/default mkbundle.exe use on
Windows -- it would no longer probe for and use dos2unix if present --
and Xamarin.Android use of mkbundle continued to check for and use
dos2unix if it was present, continuing the buggy behavior.
Doh!
Thus, a reworking: Add a `mkbundle --dos2unix` parameter.
If `mkbundle --dos2unix=false` is specified, dos2unix will NOT be
probed for, and will NOT be used. If `mkbundle --dos2unix` or
`mkbundle --dos2unix=true` is used, then dos2unix WILL be used.
This allows the caller to consistently, ahead of time, control
mkbundle's behavior regarding dos2unix, which will e.g. allow
Xamarin.Android to *always* specify --dos2unix=false, allowing things
to build as desired there.
The TestFixtureSetUp would sometimes fail in CI, but none of the tests in this class are
actually run since they are all either [Category("NotWorking")] or [Ignore].
Moving the one test from Ignore to NotWorking category allows NUnit to recognize there
are no tests to run and skips the unnecessary TestFixtureSetUp completely.
Some trampolines cannot have typical unwind information because they don't get the return address from the stack. Others are called from native code that doesn't have a managed-to-native transition so unwind information would be pointless at this point. We don't include these in the jit info tables for now, not to confuse the runtime further more.
On amd64 MONO_SIZEOF_TYPE is 12 and sizeof(MonoType) is 16. This leads to memory corruption
if one uses sizeof instead of the specific size.
This is one of those oddball behaviors of the runtime that makes easy things very hard. :(
This removes a ton of duplicated code around the runtime. There are still a few cases that could not be
unified due to the hashtables been initialized differently, which requires further reviewing.
When the monop tests were added in 6c9ad41d85 the MONO_PATH
variable wasn't included. This means that the tests actually ran against the system-provided
Mono class libs instead of the in-tree versions (or failed in case of CI with only monolite).
Since we now only remove methods from caches in the image set it belong we no longer needs to do it since
they will be gone together with the method itself.
Changes by Rodrigo Kumpera:
Added missing freeing code.
Fixed insertion into runtime_invoke_direct_cache.
Fixed some of the cleanup in mono_marshal_free_inflated_wrappers.
We currently have a partial ordering of dependencies between ImageSets and images.
If you free an image that an ImageSet depends on, you must free the
ImageSet. The inverse is not true. Freeing the ImageSet does not free
any images.
We had some caches in each Image which used method signatures as keys.
When an image signature refers to a type stored in an ImageSet, and that
ImageSet has been unloaded, the signature will remain in the cache for
the Image.
When we have another object hash to the same slot as this signature, we
must check if the two signatures are actually equal, that is if they are
equal keys or a hash collision. In this check we will refer to the
MonoType in the freed ImageSet.
By moving the caches containing inflated type references into the ImageSets
holding these inflated types, we ensure that the cache items are always safe
to dereference.
Why not simply remove the signatures from all caches they contain on
freeing the signature? This is much more work. A signature with a dozen
type parameters in a dozen images may have been used as a key in any of these
images. We would have to check all caches in all images the signature
refers to. As these caches use open addressing, in the worst time this
can take
```
(# images in signature) x (# caches per image) x (# of slots traversed on average)
```
steps. By placing it on the ImageSet, this takes only the steps required
to free a hash table. It is also easier to reason about.
Changes by Rodrigo Kumpera:
Added locking comments to the new fields in MonoImageSet.
Fixed the selected cache in mono_marshal_get_delegate_begin_invoke, mono_marshal_get_delegate_end_invoke,
mono_marshal_get_delegate_invoke_internal and mono_marshal_get_synchronized_wrapper.
The original code was using the image set of the class instead of the IS of the inflated method. This would
pick the wrong image if the method belonged to a different IS.
When additional facades were added in 04114a5e9d, the Windows Cygwin build broke.
Turns out, when building the System.IO.Comporession facade assembly it wanted to use the SharpCompress sources
of the real assembly and couldn't find it (which made no sense since since the facade doesn't even list them in
its .sources file).
After inspecting library.make what happens is this: the response file is defined as $(PROFILE)_$(LIBRARY).response,
but this results in the same value for both the real assembly and the facade assembly.
This means that since the real assembly was compiled first, the response file contained the source list of the real
assembly - which was then used to compile the facade (make happily reused the response file since it already existed).
The fix is to put $(LIBRARY_SUBDIR) into the filename so the facade assembly gets a different response file.
Same for the makefrag.
There was a race so that sometimes ipEndPoint wasn't yet assigned when the method returned,
which resulted in the test failing like this:
MESSAGE: reuse1
Expected: <127.0.0.1:54370>
But was: null
To fix this the race, we now wait until ipEndPoint is assigned before returning.
The test was actually disabled on Android because of this (see 7cb4cc9c0e),
we can reenable it again as it should now work fine.
A call to TimeZoneInfo.GetSystemTimeZones() is not returning any of the timezones for Australia due to the "Australia" string being missing from the array of continents used to look up the zoneinfo data at /usr/share/zoneinfo. This patch adds the "Australia" value to the array.
NET_4_0 is always defined now, so the ifdefs are redundant.
I verified the libs are exactly the same after this change, so this is effectively a no-op.
In .NET an URI constructor from "/foo" and UriKind.RelativeOrAbsolute is
relative whereas in mono it is assumed as an absolute file path.
This provides supports for an easy workaround to make mono behave as
.NET.
The workaround consists in defining DotNetRelativeOrAbsolute and using
it instead of UriKind.RelativeOrAbsolute.
DotNetRelativeOrAbsolute should be defined as follows:
static UriKind DotNetRelativeOrAbsolute = (Type.GetType ("Mono.Runtime")
== null)? UriKind.RelativeOrAbsolute : (UriKind) 300;
On Android application runs with its CWD set to / and so the path
test modified in this commit expects to find a path of the //one form
which is not what the combine operation returns.
bionic doesn't have the following entries:
setgrent
getgrnam_r
setpwent
API 21 in the NDK conditionally declares some of those but they are absent
from either libc.so or libc.a.
mono_get_seq_points takes the domain lock then calls mini_get_shared_method.
mini_get_shared_method then calls into general metadata code that eventually take
the loader lock.
The loader lock has precedence over the domain lock.
Starting with 62c86e2243 mono/mini/Makefile now includes mcs/build/config.make.
Both files define RUNTIME, but with different values. The mini one requires the usage of MONO_PATH while the one in
mcs don't.
To fix that we rename the mini var to MINI_RUNTIME.
To achieve this, we need to wait for the update to be applied to the backend.
This is mainly for the epoll backend, as we do not need to remove the fd from the backend when using kqueue.
System.Runtime.Serialization.Json/JavaScriptReader.cs is needed by the System.Json assembly, but in
d44898a230 it was removed from net_2_0_System.ServiceModel.Web.dll.sources
which means it wasn't included in the tarball anymore and building it failed.
Fixing the tarball by including the file in EXTRA_DISTFILES.
[merged from monodroid by rodo]
part of
commit 0b9c100b60fc2502a0d6347d50cac444bb82b285
Author: Jonathan Pobst <[email protected]>
Date: Wed Sep 28 15:50:39 2011 -0500
Instead of preserving every method with a [Register] attribute on it in Mono.Android.dll, only save the things that the user actually uses. Reduces HelloWorld release apk by ~1.3MB.
[merged from monodroid by rodo]
- part of
commit 216f75038afee2105182fc6af329f1fc83c4298f
Author: Radek Doulik <[email protected]>
Date: Sun Nov 23 11:40:42 2014 +0100
[linker] mark methods (from Register attr) in base type when needed
- fixes#10268
- methods from these Register attributes were not marked:
https://github.com/xamarin/monodroid/blob/master/src/Mono.Android/src/Android.Widget/AdapterView.cs#L132-135
because the app used class derived from BaseAdapter class and the methods
existed only in the base class and were not marked
[merged from monodroid by rodo]
commit 840487dd904a5552f77dcc7388b27c37ca09169f
Author: Radek Doulik <[email protected]>
Date: Thu Oct 16 20:03:58 2014 +0200
- sometime the assemblies with action set to Copy still might
contain type references to forwarders and thus point to
Delete assemblies, which are removed during linking, resulting
in unresolvable type references
- fixes https://bugzilla.xamarin.com/show_bug.cgi?id=23617
XA forms template now builds and works OK
XA app template builds and works OK
[merged from monodroid by rodo]
commit f51f044e30b822f191777a395563ef9d46f8b69d
Author: Radek Doulik <[email protected]>
Date: Wed Mar 4 18:28:59 2015 +0100
- fixes#27620
- in this case we were trying to process Application.java
as linker an assembly XML linker description, which led
to uncaught XmlException
[merged from monodroid by rodo]
commit 2edecdc39ca55c65de4f57557e5e31b5d432eaa4
Author: Alex Rønne Petersen <[email protected]>
Date: Mon Jul 1 15:35:59 2013 +0200
The BlacklistStep pass will feed the ResolveFromXmlStep pass XML files
that may not necessarily *be* linker descriptor files. This can happen
if an embedded file happens to be named "Foo.Bar.xml" and an assembly
called Foo.Bar is referenced in a project. The chances of this happening
are probably very low, but better safe than sorry.
[merged from monodroid by rodo]
commit 3001f693c52be0da673446179daf498265024867
Author: Alex Rønne Petersen <[email protected]>
Date: Tue Jul 30 20:06:21 2013 +0200
1. Catch XmlExceptions in case of broken XML files.
2. Only process files that actually end in ".xml".
[merged from monodroid by rodo]
commit 3e19b22eb24ff9faeebe1ace7461d8f91f807041
Author: Alex Rønne Petersen <[email protected]>
Date: Mon Jul 1 15:34:26 2013 +0200
This is in addition to those files that are already embedded in the linker assembly
itself (such as mscorlib.xml). People can use this feature to tell the linker that
certain methods/fields/types must be kept if a particular assembly is being referenced
by embedding a descriptor file in it.
OS/X, like Android, uses a symlink for the $TMP directory. The tests used to assume
that the link points to the /private/tmp directory (which is the case) but earlier
changes introduced here for Android employed a more generic mechanism to determine the
actual temporary directory.
This commit removes the '/private' prefix assumption from OS/X
This test depends on server behavior. I changed the server to xamarin.com
earlier on, but it stopped behaving as required recently. The test should
not rely on random servers, so until we have a server we can rely on I'm
disabling it.
The Dispose call in FakeSafeHandle causes the Mono runtime to segfault
when passing the call up the chain. As a consequence of disabling the
base class call, the other tests disabled by this commit fail.
It's not possible to save the assembly in the current directory on Android and AssemblyBuilder.DefineDynamicModule will not
allow a full path to the assembly to be passed to it. Trying to change the current directory before saving will not work either as
FileStream will then prepend / to the file name (perhaps it's another bug) and write access to the filesystem root is, obviously, denied
On Android (possibly on other systems too) it is possible that no gateway address is available and its lack is NOT an error
Here is a sample of /proc/net/route from Nexus 9 running Android 5.1.1 (IPInterfaceProperties parses that file on Linux)
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
Gateway is set to any address and it is explicitly ignored by the route information parser
For comparison, here's route contents from an Android 4.4.4 device:
Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
wlan0 00000000 0101A8C0 0003 0 0 0 00000000 0 0 0
wlan0 00000000 0101A8C0 0003 0 0 203 00000000 0 0 0
wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
wlan0 0001A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
wlan0 0001A8C0 00000000 0001 0 0 203 00FFFFFF 0 0 0
wlan0 0101A8C0 00000000 0005 0 0 0 FFFFFFFF 0 0 0
Obviously, this test fails on the first device and succeeds on the second. For this reason the test is modified to succeed
in case of devices like the first one since it's not a real failure but a shortcoming of the .NET API
Android M (that's where I ran into it) makes the path returned by
Path.GetTempPath () a symlink to the real directory used for temporary
files. When the tests change the directory the symlink is followed and
subsequent reads of the current directory name will return the real dir
name which doesn't match what was constructed using the value returned by
GetTempPath ()
Assembly.Location will contain just the assembly file name without any path, which
is not what the test(s) expect. The reason is that the assemblies on Android live
in the APK, are embedded in the native code or don't exist at all (AOT)
While bionic reports it supports 64-bit offsets for locks and exposes the
necessary APIs, attempt to use offsets larger than 32 bits results in
an error.
Don't assume a specific charset in HTTP response from a server. Google
changes response charset based on the country of the client's
IP. There's no point in checking for the specific charset, it's enough
to check whether the response header has correct format.
Fix the test to compare the subtraction result to value more
conservative than Double.Epsilon, to account for differences in
different CPU floating point units on Android.
The test failures didn't really indicate which of the Fail statements
caused the test failure. Also, the 10k offset turned out to be not
enough for the XA test suite (it's much bigger than that)
Xamarin.Android stores assemblies inside apk (or bundled, or AOT-ed) and
so Assembly.Location will not point to a real path on the
filesystem. It merely contains assembly name.
The test case doesn't account for the situation when the tests are ran
at the root of the Unix filesystem. This is, admittedly, a rare case on
Desktop but it's precisely what CWD is for Android processes. The test
would fail because it would get a path of the //Form instead of the /Form
With the previous commit, it fixes a range of bug that happens only with epoll. This is because, contrary to poll and kqueue, epoll keeps an internal state that has to be kept in sync with the threadpool_io->states hash table.
This threadpool_io->states hash table is keeping a list of file descriptor to watch, with the corresponding SocketAsyncResult to callback in case of event on the fd. But epoll also keeps its internal state that needs to me modified with EPOLL_CTL_ADD, EPOLL_CTL_MOD and EPOLL_CTL_DEL.
Contrary to kqueue, EPOLLONESHOT does not force epoll to remove the socket from its internal state once an event have been triggered; but it will just not fire this event again, until this event is reset. Also, epoll will remove a fd from its internal state when this fd is closed.
This will lead to a bunch of out-of-sync states like the following :
- the user start reading asynchronously the STDOUT of a child process, the child process quit (closing the STDOUT fd), this fd is reused by the OS for something else (like a socket), the IO threadpool call epoll_ctl with EPOLL_CTL_MOD (because the fd is still in the states hashtable), but the OS returns an error because the underlying file is different, even if the fd is the same.
- the user opens a socket, does some asynchronous operation on it, and close it; removing it from the table but not from epoll (as it does not call epoll_ctl with EPOLL_CTL_DEL). For another reason, the fd has not been closed in the OS (and thus in epoll), because it might, for example, still be open by another process. After that, we receive an event for this fd (as it is still in epoll), and between the time of the epoll_wait and the epoll_ctl with EPOLL_CTL_DEL, the fd is actually closed in the OS, leading to a EBADF error.
The g_warning have also been replaced by g_error, so we do not silently discard this kind of error in testing.
Reading the various fields on the profiler structure from the shutdown
thread is very racy; for example, we have no guarantee that we will see
a consistent GPtrArray structure for sorted_sample_events. It's better
to just let the helper thread empty the stat buffers when it shuts down.
In many cases, we allocated less than we actually needed in the worst case. We
now spell out the size of each field in an event to make it less likely that
such mistakes are made in the future.
We now report:
* Start/stop events for threads, domains, and contexts.
* Friendly name changes for domains (as for threads).
* Assembly load/unload events (as for images).
* Unload events for images and classes.
Previously, it was impossible to determine which thread a sample came from
because the buffer header thread ID for all sample events is the same (that of
the profiler's helper thread).
This significantly improves overall compression of sample events as successive
sample events for the same thread are highly likely to contain similar method
pointers in managed backtraces.
Add support for OP_TLS operations. The code that implements this is comprised of getter and setter asm thunks, which is either inlined, or it uses external code. At runtime we check the implementation on the system, using the inlined thunks if we can.
Remote TLS reads is not a required feature for the runtime to work on
mach systems. We still want it available, but can leave the assertion
to happen when someone actually use it.
Usage won't happen today as part of regular code execution, so moving
the assert will make us more robust.
This enum, which can be found in Xamarin's iOS and Mac products use a custom encoding
scheme which resulted in invalid values being shown when processed with mdoc. This patch
adds a special case to watch for this particular enumeration value, and decodes the data
correctly.
Additionally, the code that formats the values for flags enumerations was refactored. Future extensibility of this feature can now be done by simply implementing a new `FlagsFormatter`, and applying the proper logic in the `MakeAttributesValueString` function.
For a future Xamarin.Android release, we'd like to include
Mono.Posix.dll for simple Unix interop support.
That said, since Mono.Posix has never been included with
Xamarin.Andorid before, this makes a perfect opportunity to remove
some [Obsolete] cruft within Mono.Posix.dll, namely the types within
the Mono.Posix namespace.
Unfortunately, simply not compiling the types within the Mono.Posix
directory doesn't result in compilable code, due to references to
types within the Mono.Posix namespace by other types, e.g.
Mono.Unix.PeerCred using Mono.Posix.PeerCredData.
Fix things so that the Mono.Posix sources can be omitted, allowing
compilation of an assembly with fewer [Obsolete] types.
This change shrinks the size of Mono.Posix.dll by ~10.5KB.
The runtime requires a MemberInfo from the fixups.
A metadata token needs to be translated into a MemberInfo.
Nontheless Module.ResolveMember only works with loaded assemblies.
Local unbuilded members also needed to be resolved so a new method
ResolveOrGetRegisteredToken was added to retrieve from the runtime the
cached XXXBuilder for a token.
ModuleBuilder.GetRegisteredToken returns a Builder previously registered
for a token.
This is required when the builded module has not been yet loaded into
memory but we still need to resolve the token into a builder.
Since UTF32Encoding returns 8 for GetMaxByteCount(1), PtrToString
expects 8 NUL bytes to stop scanning for the end of the string.
Since all the other UTF schemes are special-cased in
GetStringByteLength, do the same for UTF32Encoding.
The value isn't used for the managed crypto code and is still validfor CryptoAPI, but if it changes Mono can't find keypairs made with earlier versions. Fixes#31199
The check from [1] is fine when it's done once _or_ with an identical
target. However there's nothing to ensure (if done more than once) that
it's being used to represent the same thing every time.
That makes the code from [1] match methods like:
> System.IObservable`1<TResult> System.Reactive.Linq.IQueryLanguage::Repeat(TResult)
and
> System.IObservable`1<TSource> System.Reactive.Linq.QueryLanguage::Repeat(System.IObservable`1<TSource>)
where `TResult` is different in both checks.
This patch tracks what is used as the generic parameter (on first check)
and make sure it's identical if it's used again in the same signature.
Note: this is a very old bug (i.e. it's always been that way) but recent
changes to mono started to report such issues (a good thing) and, for AOT
compilation on XI, that resulted in MT3001 errors.
[1] https://github.com/mono/mono/blob/mono-3.10.0/mcs/tools/linker/Mono.Linker.Steps/TypeMapStep.cs#L250
xbuild was copying TargetFramework assemblies when the builded project
had dependencies in a TargetFramework.
Doing so is not the msbuild behaviour and was causing bugs while
resolving Types at load time.
Fixes#28592 and #31396
The socket would not be deleted with epoll_ctl (via epoll_reset_fd_at) when we would remove the state from threadpool_io.states. So when we would try to add it again, it would mark it as a new socket (as it wouldn't be present in threadpool_io.states), while it has not been deleted from epoll.
They are a very fragile part of the runtime, as they are not very well aken care of.
We simply disable it by default for now. If everything still works as expected, we will completely remove the code.
* It reduce memory allocations by avoiding the creation of empty
collections (only used to tell us there's a Count of 0);
* It also speed up execution, less object creation/GC time;
* Patch also remove some double-casts (is + as/cast)
The following race could occur and lead to a EBADF error with kevent and epoll :
1. mono_threadpool_ms_io_add is called with fd 1234
2. mono_threadpool_ms_io_remove_socket is called when closing fd 1234
3. selector_thread calls update_add with socket 1234, which will call kevent with this already closed socket
The solution is simply to remove all the SocketAsyncResult from states, as well as updates, for the given socket fd
We were failing MonoTests.DebuggerTests.Locals and
MonoTests.DebuggerTests.SingleStepping because we
stepped forward too far as a side effect of this missing
"padding" NOP.
We see a crash in LinuxNetworkChange.OnAvailabilityChanged when dereferencing the AvailabilityChanged delegate (NullReferenceException). There is a race here: the OnAvailabilityChanged is fired by deferring to the ThreadPool, which allows an unregister to come in between, removing the potential registration before we get called back.
Compiling VB projects was broken since a few releases but apparently went unnoticed.
The VbcToolExe path needs to be set to "vbnc.exe" because vbnc2 and vbnc shell scripts
don't work in this case and we only support building against the reference assemblies anyway
now for different targets.
We had a use-after-free bug in context freeing that creating and freeing AppDomains in parallel exposed.
We called g_hash_table_remove in a callback to g_hash_table_foreach,
which
resulted in freeing the Slot struct that the g_hash_table_foreach was
holding a local reference to.
When it tried to get the chained 'next' element in the table, if
other threads caused enough memory pressure to reuse that memory
between freeing and getting the 'next' pointer, then we try to
dereference a garbage value and get a SIGSEGV.
On mach, semaphore_timedwait returns KERN_ABORTED instead of setting the errno variable. The timeout argument is relative so it needs to be updated. We don't need to update the timeout argument on other platforms since it has an absolute value.
Me might be very unlucky and still have the object pinned in random stack memory. Allocate multiple objects so we are sure that at least one of them is finalized.
Fixes segmentation fault when mono_mmap_open_handle is called with a null mapName argument.
MemoryMappedFiles.CreateFromFile calls mono_mmap_open_handle, .NET implementation accepts a null mapName and CoreFX uses CreateFromFile with null mapName.
Fixes#30825 and #30741.
Changed MemoryMappedFile related code to use reference source
MemoryMappedViewAccessor and MemoryMappedViewStream.
This change was motivated by segmentations faults while dnmv code was
calling a CoreFX class that uses reflection to call MemoryMappedFile
code.
Now that we are using more code from reference sources there should be
no problem.
Fixes#30741 and #30825.
Few tests using networking seem to fail due to
"Address already in use"
error that may be caused by opening listening
port too fast - because of some tests running
in parallel or because 2MSL TIME_WAIT period.
Most modern Linux distributions limit the ptrace scope to allow
attaching only to the direct child processes for security reasons. The
user on such machine has to modify sysctl in order to allow non-root
processes to attach to arbitrary processes, which opens up a potential
security issue. The alternative is what's implemented here - when we
crash and ask gdb to dump the stack we can bless the gdb process and allow
it to attach to our process using prctl(2)
For platforms that have external libiconv
located in some non-default directory (e.g. /usr/local/lib)
it is very difficult to force libtool to pick
up a static libiconv.a when needed.
We currently build eglib as a static library,
and then we continue to link eglib (with -leglib)
to other binaries and libraries.
As -leglib is a static library, we should either
1) incorporate the contents of libiconv.a into
libeglib.a (therefore we would _require_
libiconv.a to be installed).
2) prepare stub libiconv.la file and provide it
to all libeglib.a consumers as a dependency.
We should not just detect HAVE_LOCALCHARSET_H,
add it to CPPFLAGS and then continue without
linking libiconv properly as a static library;
This manifests with the error message during
linking:
gunicode.c:223: undefined reference to `locale_charset'
This workaround makes us look for <langinfo.h>
first, which - if available - will be there in
the standard C library. This fixes the gunicode.c
problem for FreeBSD and similar platforms, that
may install GNU iconv as an add-on library.
When you write to archive files and entryNameEncoding is set to a value other than null, the specified entryNameEncoding is used to encode the entry names into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=30972.
I have added System.HttpApplication.RegisterModule(), the missing two properties of the System.Web.Routing.RouteCollection as well as the corresponding property in the HttpRuntimeSection to completely turn this off. Microsofts MIT-Licensed counterparts of the official System.Web assembly from github [0] were used as a reference. It is kind-of bolted on, but should be good enough until the whole open-sourced System.Web is incorporated. It should at least get the default MVC5 Template from Visual Studio 2013 up and running, once the async pipeline for the owin stuff is fixed.
[0]: http://github.com/Microsoft/referencesource/
Additionally, the MissingMethodException "get_InClientBuildManager" in System.Web.Hosting.HostingEnvironment was fixed.
In this commit, the following bugs were fixed:
https://bugzilla.xamarin.com/show_bug.cgi?id=21810https://bugzilla.xamarin.com/show_bug.cgi?id=16475
System.Diagnostics.Process.Modules now also returns managed assemblies.
With this change it is now possible to use Process.Modules to retrieve
the place in memory of any loaded assembly.
ProcessModules relative to a managed assembly have a FileName that
starts with "[In Memory]".
Any port that writes to Environment.SpecialFolder.Personal during build
or when running tests may end up with files outside of stage area that
aren't cleaned up by the ports framework. The issue lies with Mono
looking in /etc/passwd first and only if no entry found there in HOME.
Patch based on discussion in
https://github.com/mono/mono/pull/371
Obtained from: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193426
In order to resolve interdependencies between
static libraries we should create a temporary
throw-away ("convenience") library via libtool.
Should unbreak unit tests on Linux
The problem is that those two ops are required to be one after the other as there's an implicit register dependency between them.
OP_SAFEPOINT would clobber that register (RAX on amd64) and cause all sorts of issues.
The ResolveAssemblyReference task class keeps a reference to an
instance of AssemblyResolver, and AssemblyResolver keeps a cache
of assembly names, indexed by file name. The problem is that
the cache doesn't take into account that files can change between
builds.
For example, if a referenced assembly doesn't exist, the cache
will store that the file doesn't have an assembly name. If after
the build the file is created and a new build operation is started,
the cache will still return that the file doesn't have a name.
This is not a problem when running xbuild from the command line,
since every build starts a new process, but MonoDevelop uses
the MSBuild API to load and build projects, and doesn't start
a new process every time, so the cache is never cleared.
The solution is to keep the last write timestamp in the cache,
so that it can check if the file changed before returning the
cached name. It also needs to do a better handling of non existant
files.
This causes strange crashes on some Linux systems. We don't particularly need
the additional information to get useful backtraces (we can just fall back to
`dladdr`) so disable it for now.
If a file or directory are moved out of the watcher's path they are removed from the index, but they might still have events in the kevent() changelist. This would sometimes cause an exception.
We were observing dtest-006.exe test failing on armhf. This test
checks that a right shift with a negative shift amount and a
dynamic base is shifted by the right amount.
We were failing it because we were excluding the step that we
do in regular code generation, which is to do a binary and of the shift
amount so it behaves like we are shifting by the original shift
amount modulo 32. The C# spec defines left shift like so.
This commit adds that to the LambdaCompiler.
Implemented MonoAssembly.LoadWithPartialNameInternal.
Implementation is not 100% correct without handling stackMark properly.
Improving this would require the generous amount of work of adding
StackCrawlMark support to the runtime.
Fixes#27103.
XM 2.0 was the first version to ship the mobile (w/unified) and it used
the OS default codepage.
The previous, system mono, profile was already using the OS default
codepage so it make sense for XM to be consistent across profiles (
including the 4.5 subset)
SHA1 is deprecated and microsoft won't accept SHA1 into the certificate store after 2016. Defaulting to SHA512 is a good practice to prevent unaware folks from generating weak ssl certs.
AssemblyName.CultureName was returning "neutral" for invariant culture
info whereas .NET returns "".
This was causing problems in Roslyn while comparing assemblies with
an empty culture name against references that would have culture name
set to "neutral".
Fixes#30502.
605192528d used UTF8Unmarked for MONOTOUCH
and XAMMAC. However it's initialized differently (than the old UTF8) and
caused unit test regressions in System and System.Net.Http unit tests
This new logic moves the default encoding creation into the products
themselves.
These tests would tend to leave non disposed SafeHandle which would later be finalized, then throwing ObjectDisposedException. They would also crash on .NET.
Otherwise parallel invocations might end up stomping on eachother
(these two files are processed in parallel):
Processing /work/maccore/master/maccore/builds/install/mac/xammac/bcl/mscorlib.dll.mdb
Processing /work/maccore/master/maccore/builds/install/mac/net_4_5/bcl/mscorlib.dll.mdb
Unhandled Exception:
System.IO.FileNotFoundException: /var/folders/g9/k5kx4z211ld_lwlbfxv5rq040000gn/T/mscorlib.dll.mdb does not exist
File name: '/var/folders/g9/k5kx4z211ld_lwlbfxv5rq040000gn/T/mscorlib.dll.mdb'
at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00000] in <filename unknown>:0
at Mono.MdbRebase.MdbRebase.RewriteMdbFile (System.String inputFile) [0x00000] in <filename unknown>:0
at Mono.MdbRebase.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: /var/folders/g9/k5kx4z211ld_lwlbfxv5rq040000gn/T/mscorlib.dll.mdb does not exist
File name: '/var/folders/g9/k5kx4z211ld_lwlbfxv5rq040000gn/T/mscorlib.dll.mdb'
at System.IO.File.Move (System.String sourceFileName, System.String destFileName) [0x00000] in <filename unknown>:0
at Mono.MdbRebase.MdbRebase.RewriteMdbFile (System.String inputFile) [0x00000] in <filename unknown>:0
at Mono.MdbRebase.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
When running MONO_LOG_LEVEL=debug xbuild with previous versions, it showed
that Microsoft.Build.Tasks.v4.0.dll was loaded, while the expected one was
Microsoft.Build.Tasks.v12.0.dll (as current xbuild script loads the one
from xbuild_12 profile). It was because Microsoft.Build.Tasks*.dll was
not referenced by xbuild.exe and thus it was loaded differently.
This hack adds strong reference to some class in Microsoft.Build.Tasks*.dll
of the corresponding version for each profile to resolve that issue.
1. Preserve ChannelFactory so that it can retrieve its ServiceEndpoint's
Binding's Timeout values.
2. Use DefaultCommunicationTimeouts.SendTimeout instead of ReceiveTimeout.
It was either written when I don't understand the API well or might be
different in duplex channel (who cares? nothing supports it now and
we will be switching to referencesource).
It is going to be my final contribution to WCF old codebase. Bye bye forever.
Instead of importing the source from referencesource, the algorithm has been reimplemented in our version. This is because their implementation uses multiple internal calls that do not need to be.
Place an upper limit on files loaded in the coverage profiler to 128k. If the
system suppression file exceeds that (it is currently only 3k), then there's
some problem and the profiler will exit. For other user files passed on the
commandline, we print a warning message and ignore them.
What happens here is the following:
When using chunked encoding, the ChunkStream sometimes mixes async and sync requests
on the underlying stream. The async calls work great - just the sync ones create
problems.
In this particular bug, the server returns two ApplicationData records - one big one
and then a smaller one. The chunk parser requests a sync read of 1024 bytes which
then result in a series of sync reads on the underlying network stream. The first
two or three network reads don't return enough data to fill the huge ApplicationData
record - the last one then returns so much data that it fills both the remainder of
the first record and the entire second one.
If the caller issued a second sync read, then the implementation would catch this -
but the async code path does not.
Instead of importing the source from referencesource, the algorithm has been reimplemented in our version. This is because their implementation uses multiple internal calls that do not need to be, and they are simple enough to just be reimplemented in managed code.
Changed GetDaylightChanges to match .NET behaviour.
GetDaylightChanges now only returns DaylightTime.Start and
DaylightTime.End in the given year.
DaylightTime.Start and DaylightTime.End may not belong to the same DST
period.
In mcs/ the install of xbuild_12 and xbuild_14 will end-up installing
the same files:
${NETFRAMEWORK_DIR}/v2.0/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v3.0/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v3.5/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v4.0/Profile/Client/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v4.0/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v4.5.1/RedistList/FrameworkList.xml
${NETFRAMEWORK_DIR}/v4.5/RedistList/FrameworkList.xml
This is because there is no atomicity when installing each file, and
xbuild_12 and xbuild_14 may well run in parallel, each trying to install
each of those files; but the 'install' utility will first check if the
target file exists or not, and there is a race in doing so, thus leading
to build failures like so:
http://autobuild.buildroot.org/results/c32/c3288c5d1fb94474f14a4a889e76135878d403bc/build-end.loghttp://autobuild.buildroot.org/results/3cb/3cb99e5c5672cbaa2a86020129a05dfde47cdb8f/build-end.log
and many more:
http://autobuild.buildroot.net/?reason=host-mono-4.0.0http://autobuild.buildroot.net/?reason=host-mono-4.0.1
So, ensure ordering of the install of xbuild_12 and xbuild_14 (the
ordering is completely arbitrary, either way gives the same installed
files).
Signed-off-by: "Yann E. MORIN" <[email protected]>
Cc: Angelo Compagnucci <[email protected]>
On big endian systems, this code would break because we reinterpret the
structure as a `guint32` via memory. Fix this by reversing the order of
the fields on big endian systems.
This is needed because the fast paths in managed allocators (by design) don't
report allocations to the profiler. In regular JIT/AOT mode, managed allocators
are simply disabled to work around this when profiling. However, in FullAOT
mode, an image may have been compiled with managed allocators enabled which
results in the managed allocator actually being emitted into the AOT image.
So, when we want to profile a FullAOT image, we need to replace the regular
managed allocator with one that always goes through the slow path (i.e. calls
straight into the runtime). To that end, when we decode a MONO_WRAPPER_ALLOC
method ref, we redirect it to the appropriate slow path allocator if allocation
profiling is enabled.
By reporting allocations in the GC implementations, we significantly reduce the
odds of someone forgetting to add a mono_profiler_allocation () call. These
previously had to be placed at all call sites of mono_gc_alloc_* () which was
in some cases forgotten, resulting in the profiler seeing objects in GC events
which appeared to not have been allocated.
This was already done for SGen, but Boehm and the null GC still had a bunch of
code in object.c to allocate and prepare objects. This has now been moved into
mono_gc_alloc_* () functions so that all 3 GC backends have the same interface
for allocation.
setup_interface_offsets will be called multiple times. The code was originally
designed to avoid setting up this multiple times but a change to avoid making it assert
when used from SRE made it so that the check to avoid multiple initialization would
effectively make it be initialized multiple times.
See 628e025476 for the original change.
When using a TransparentProxy, we run into the problem that the cache is
shared between all marshalbyrefobjects. The fix here is to not update
the cache when using a TransparentProxy, so that the correct slow path
is used.
It seems the base utc offset can also have a sub-minute resolution
in Unix, which means we need to apply the whole-minute rounding to
the final result (dstDelta) instead of the intermediate ttype.Offset
value.
We need to try to fetch the exact timezone id to expose this bug,
since fetching all system timezones will just not return any
problematic timezones (and there is thus no way to distinguish
inexistent timezones from timezones that failed to load).
This could lead to hangs because threadpool->counter._.active would not be decremented. It means we cannot cleanup memory as the threads may still try to access the threadpool global variable.
For the helper and writer thread to actually work, we need Mono's threading
subsystem to be initialized (so we can use TLS and hazard pointers). We now
wait with starting these threads until Mono gives us the go-ahead.
This means that a bit more data will be buffered up in the thread-local log
buffers during startup, but it shouldn't really matter in practice.
Due to asynchronous abortion a crash is being seen on
posix systems where the abort signal handler is having a
data race and not exiting the suspend signal handler early.
When it tries to make a state transition because of this, it
cannot and it crashes.
This fixes it by making it synchronous.
The context-specific code now mirrors the thread-specific code and uses the
internal NamedDataSlot class. The runtime code now correctly frees context
static data allocated via this class.
This reverts commit 05ce4f6ee1.
It's giving some problems on Monodroid build:
/Users/builder/data/lanes/1196/012ff355/source/mono/mono/mini/cpu-arm.md
Invalid specifier len:4 at line 51 at /Users/builder/data/lanes/1196/012ff355/source/mono/mono/mini/genmdesc.pl line 153, <DESC> line 51.
I was induced in error because of the following comment in the machine read specs:
`# len:number describe the maximun length in bytes of the instruction
# number is a positive integer`
During thread shutdown, it gets to a point where the thread can no longer server suspend requests. To fix that
we ensure the thread gets one last suspend opportunity before going down.
Special static offsets now have a less magical format:
[0] 6-bit index into the array of chunks.
[6] 25-bit offset into the array.
[31] Bit indicating thread or context static.
Also wrapped accesses to these fields in macros and a bitfield struct.
Context static data is now scanned precisely in the same way as thread static
data. To facilitate this, the memory management of context static data has been
fixed to work similarly to thread static data. This further required that all
contexts be available for iteration, so contexts are now added to a global hash
table (by GC handle) when they are created.
Make sure we do not accidentally to encode an object by breaking out for
unknown TypeCode.Object instances (this is where the zero bytes used to
silently come from).
This commit adds the missing mapping from DateTimeOffset to its SqlDbType,
and makes sure they are converted to string 1. in a locale-insensitive
manner, and 2. with maximum precision.
Mono's implementation of DataTableMappingCollection used not to care,
but MS', merged from the .NET reference sources, throws an exception
if the source table name is empty.
Without this, variant output parameters are left unconsumed in the
input stream, and null is returned.
The new code skips the max length uint, and decodes a subset of the
variant types. What is not recognized is skipped, and we return null
as the previous code used to do.
(Ideally, the subset of GetColumnValue which decodes types which can
be embedded in a variant should be factored out to a different method,
and reused from GetVariantValue.)
On the wire, Variants are preceded by uint-encoded max length and
actual length (not bytes like smaller types). Without this patch,
SQL Server 2008 SP2 rejects our requests as truncated.
Without this, the TdsMetaParameter.TypeName ends up being null, which
crashes TdsMetaParameter.GetMetaType () when the variant value is
about to be serialized on the wire.
DateTime2 and DateTimeOffset are not directly supported by the TDS 7.1
wire protocol, which is the version implemented by Mono's current TDS
driver. (Tds80.cs does in fact advertise version 0x00000071.)
Bumping the protocol version to 0x03000a73 or 0x03000b73, for TDS
7.3.A/7.3.B, is not sufficient; the stream generated by the driver
causes SQL Server to kill the connection right after the login packet.
More investigation is needed on that front.
SQL Server is fine, however, with us sending timestamps in
literal (ISO 8601) format down the wire, packed within ASCII char(n)
strings. Which is what this patch does, which allows client code
perform inserts using, e.g.:
var param = new SqlParameter("@Value", SqlDbType.DateTime2);
param.Value = DateTime.Now;
command.Parameters.Add(param);
The cleanup code would wait for all worker threads to finish, but that could lead to some workload that would block. By disabling the cleanup code, we do not wait on anything to happen, we count on the OS to clean everything up.
Replace the reversed linked implementation by an array based implementation. This will improve Combine performance, as well as ease delegate to virtual function optimization.
Fixes IsDaylightSavingTime returning false when
SupportsDaylightSavingTime was set to false because TimeZoneInfo was
create with no AdjustmentRules.
Now if TimeZoneInfo uses transitions SupportsDaylightSavingTime will be
set to true regardless of AdjustmentRules.
The pointer the function would have to return would be to a chunk of managed
memory, for the object to be allocated. It can't do that because it is not in charge
of the managed heap. The best it could do would be to free some unmanaged
memory and tell the allocator try again.
This should always be inlined. We also need this there because we'll put the
profiler calls there.
This introduces fickle dependencies in the order of which things are declared
and inlined. It would be nice to have a cleaner solution.
We use client callbacks from the binary protocol functions. There are some DTrace probes
which we don't have binary protocol entries for. Since DTrace isn't properly supported
anyway (and doesn't even work as it should on OSX), we just remove those probes instead
of making new binary protocol entries.
StackStrace.ToString logic was duplicated in System.Exception and
System.Diagnostics.StackTrace.
Exception.StackTrace output was not changed.
StackTrace.ToString's method signature was changed, it is now the same
as Exception.StackTrace, which is more similar to the .NET one. This
affects generics and ref parameters representation.
Fixes random/strange hangs/crashes (many native API starts returning
out-of-memory errors when there is plenty of memory available, other
just hang inexplicably) when profiling.
When copying value types (like via Array.Copy) it was possible to
encounter a memory region going over the end of the card table array.
In that case we would overwrite data after the card table and fail
to mark cards at the start of the array.
It's hard to do a test case for this because we allocate the shadow card
table directly after the regular one, so the overwrite is benign. It would
also require allocating very large arrays (>2Gb) and run very slowly.
We're adding this new API call to replace the `g_assert (mono_error_ok (&error));` code pattern so that when there's an error we can print the error message from the MonoError.
The reference sources do not support sub-minute DST offsets as the exception below
shows, while Europe/Dublin has a DST offset of 34:39 in 1916.
There is no equivalent TimeZoneInfo for Europe/Dublin in .NET, so the problem
doesn't show up there.
System.ArgumentException: The TimeSpan parameter cannot be specified more precisely than whole minutes.
Parameter name: daylightDelta
at System.TimeZoneInfo/AdjustmentRule.ValidateAdjustmentRule (System.DateTime,System.DateTime,System.TimeSpan,System.TimeZoneInfo/TransitionTime,System.TimeZoneInfo/TransitionTime) [0x0012c] in /work/mono/master/external/referencesource/mscorlib/system/timezoneinfo.cs:3907
at System.TimeZoneInfo/AdjustmentRule.CreateAdjustmentRule (System.DateTime,System.DateTime,System.TimeSpan,System.TimeZoneInfo/TransitionTime,System.TimeZoneInfo/TransitionTime) [0x00000] in /work/mono/master/external/referencesource/mscorlib/system/timezoneinfo.cs:3836
at System.TimeZoneInfo.ParseTZBuffer (string,byte[],int) [0x002ca] in /work/mono/master/mcs/class/corlib/System/TimeZoneInfo.cs:1230
at System.TimeZoneInfo.BuildFromStream (string,System.IO.Stream) [0x00030] in /work/mono/master/mcs/class/corlib/System/TimeZoneInfo.cs:479
at System.TimeZoneInfo.FindSystemTimeZoneByFileName (string,string) [0x00018] in /work/mono/master/mcs/class/corlib/System/TimeZoneInfo.cs:463
at System.TimeZoneInfo.FindSystemTimeZoneById (string) [0x00075] in /work/mono/master/mcs/class/corlib/System/TimeZoneInfo.cs:450
at MonoTests.System.TimeZoneInfoTest/FindSystemTimeZoneByIdTests.Dublin () [0x00015] in /work/mono/master/mcs/class/corlib/Test/System/TimeZoneInfoTest.cs:812
The profiler API needs to evolve with the runtime. By versioning the API we can
at least to some degree let developers know when their modules are out of date
and how to update them.
Just like BinaryMessageFormatter needed to use another CreateBinaryWriter()
overload to NOT close the input stream, use CreateTextWriter() overload that
does not close the stream.
I wonder why, but when switched to referencesource, it turned out that
ResourceCollectionInfo calls SyndicationElementExtensionCollection.Add()
which targets a private overload, but (of course) failed and resolved to
another overload that takes object, and thus resulting in invalid code path.
With this fix the call to Add() resolves to the expected one and does not
regress with referencesource import.
Those tests were added without considering TimeZone difference. They cause
several kind of errors (SerializationException etc.) in JST (+09:00) or any
timezone that is earlier than UTC.
We likely had some "working" implementation, but was incompatible with .NET.
The namespace declarations existed when the entire Message is read but not
in the partial body contents. They caused regressions when we use
serialization stack from referencesource.
It is possible that more namespaces may be requied, but we will be importing
System.ServiceModel later on and then the issue will go away.
So far we don't want regression as long as they show up in our NUnit tests.
Unlike our own XsdDataContractExporter, referencesource one generates
an extra schema that targets xs:* (XmlSchema.Namespace).
That should not be generated as part of WSDL, so exclude it.
WriteStartDocument() can be used with document and document does not accept
more than one element, which basically contradicts MTOM writer usage.
For EOL changes, MTOM writer should not alter content EOL chars.
The removed code caused unexpected omission of xsi:type by giving "false"
Type information that is from the actual value (when the expected type is
different, xsi:type should be written).
The original code is complicated enough that I misinterpreted the logic...
The reulting code should look like this:
DateTime? expr_94 = timeSubmitted;
DateTime dateTime;
bool arg_B5_0;
if (XmlObjectSerializerWriteContext.GetHasValue<DateTime> (expr_94)) {
dateTime = XmlObjectSerializerWriteContext.GetNullableValue<DateTime> (expr_94);
arg_B5_0 = false;
}
else {
dateTime = XmlObjectSerializerWriteContext.GetDefaultValue<DateTime> ();
arg_B5_0 = true;
}
The fixed code should be like this now.
Basically the primary cause of the problem was that invoked primitive array
reader methods via reflection had 'out' parameter, which needed special care.
The new code is to implement reflection (non-emit) based serialization
so that it works on iOS.
Actually I _totally_ switched to this new implementation because dynamic
method based implementation also doesn't work fine, even on desktop
(due to invocation failure on internal methods, it seems that our dynamic
method needs some bugfixes).
The new methods with NotImplementedException in new classes need to be
implemented.
When we moved to Vista as the minimum build target, the mingw build broke.
The reason is that mingw's mswsock.h has the following code:
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
int WSAAPI WSAPoll(WSAPOLLFD, ULONG, INT);
#endif
Unfortunately, due to a bug mingw 4.0 doesn't define WSAPOLLFD and the compiler
raises an error. See http://sourceforge.net/p/mingw/bugs/1980 for more details.
As a workaround, inline the typedef for WSAPOLLFD from the mentioned bug report.
Also removed an unecessary check for _WIN32_WINNT < 0x0502 from the file.
Security declarations looks very similar to custom attributes - but
they are not (e.g. a different metadata table).
They need to be marked, just like other metadata, by the linker because
they can encode types that won't show up in the type (or assembly)
references.
Ignoring this can create an invalid binary (the kind that even Cecil
can't load back for further processing).
The exact name (e.g. version) might differ between the original
AssemblyNameReference and the one being used (e.g. PCL).
To make sure we remove unused references we need to resolve
the AssemblyNameReference into AssemblyDefinition and then
continue the sweep based on the _new_ AssemblyNameReference.
The new suspend code works on all major targets, so it's time to remove old suspend.
This change removes all relevant native code, managed code could see some cleanup.
This fixes a couple of small issues with the Visual Basic build support:
- The VBC task now respects the $(NoStdLib) MSBuild option.
- The field @(ReferencePath) should be used for References in the VBC
target as it is for the CSC target.
- The CreateVisualBasicManifestResourceNames task is compiled and used
in the same manner as CreateCSharpManifestResourceNames hence it should
be loaded via UsingTask in the same manner as well.
- Include the VisualBasic Portable targets files.
The VB language requires that code files have statements in the
following order:
- Option
- Import
- Assembly level attributes
- Namespaces / other declarations
The VBCodeGenerator type when given both import and assembly level
attribute statements was generating the attributes first. This lead to
compilation errors in the generated file.
This change fixes the generator to emit assembly level attributes in
the proper location in the file (and adds the corresponding unit tests
as well).
The new socket constructor that only takes a SocketType and a
ProtocolType defaults to InterNetworkV6 (this was done on a previous patch).
In addition, we explicitly set "DualMode" to true, so that on Windows,
this gets set explicitly (it does not matter on Unix).
We surface the DualMode property to allow servers that want to just
bind to the IPv6 address to do so by creating the socket and then
changing DualMode to false.
This is *not* the same setting that Windows has, but it is the
semantics that Mono applications depend on. So a test has been added
to ensure that we do not regress.
This also switches to use SocketOptionName from the ReferenceSources.
Every once in a while, we run into a NullReferenceException attempting to dispose a null timer. It's very rare and we can't reproduce. However, reading this code, it seems possible that two timer callbacks could pile up, and if they did, the first one might dispose the timer, and then the second one would attempt to dispose null.
This change enables managed polling to work with both NaCL and coop as they are exactly the same except for the variables used.
We cleanup how safepoints are injects to be done on a separate pass instead of having in spread around the JIT.
We now inject safepoints at EH handler entry as those did not previously have them.
The generated AOT code was greatly optimized by having the polling variable checked before doing the icall. This more
than doubles the performance of the generated code.
This change adds support for the following MSBuild properties which are specific to VB compilation:
- OptionInfer: controls the /optioninfer switch
- VBRuntime: controls the /vbruntime switch
Concurrent mark modified the card table directly, which had two
drawbacks.
First, it meant that nursery collections would also have to scan the
cards marked by the concurrent collector, which was unnecessary work.
Second, because the nursery collector also modified the cardtable, it
meant that the two could not run concurrently, i.e., we had to suspend
concurrent marking work whenever a nursery collection occurred.
The issue was discovered when using monodoc in an asp.net application; while the code was developed and worked successfully in the local Visual Studio web server, it failed when deployed and executed in IIS. The reason it seems is because of the use of `.GetCallingAssembly()`, which was returning an unexpected assembly reference. This resulted in the `.GetManifestResourceStream` returning null for resources that are definitely a part of monodoc.dll.
Once the code was changed to get the assembly using a type reference of a type that's definitely in monodoc.dll ... the code resumed working as expected.
This does not import System.CodeDom.Compiler because some of them depends
on Windows specific stuff.
CodeGenerator is imported because ours depends on our own internal
Visitor implementation and could not build without making changes a lot.
This allows a piece of code to handle the cases where it's called in running and blocker context
and must always be in blocking context.
This probably makes code more modular at the expense of an easy to follow and debug execution model.
Since we don't currently annotate all icalls with blocking sections we do it with locks but they can
nest and recurse which requires this support for try block.
The commit removed the AC_DEFINE for TARGET_WIN32 from configure.ac,
but many parts of the build rely on it so the build broke.
Fixed this by defining TARGET_WIN32 when we detect it is the target
and do the same for HOST_WIN32.
ArgumentOutOfRangeException expects the parameter name first, then the message. ArgumentException is precisely the opposite, and expects the message first, and then the parameter name. They were swapped here.
In .NET regardless the current time zone, TimeZone.CurrentTimeZone.GetUtcOffset returns TimeSpan.Zero when called with an UTC DateTime.
Similarly IsDaylightSaveTime returns false when called with an UTC DateTime.
Eventually we want to add a better fix for this, like for instance adding this behaviour to the LLVM-specific code path
but until we can research more under exactly what conditions we need to do this then implement this simple workaround.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=27055.
We fully control the $target values here as we don't use canonicalization for
them. So we have no reason or excuse to be using wildcards in them.
E.g. any Linux $target in this case would previously be assumed to be Android.
The overflow check is only performed when the result is big enough.
The overflow check is done by decomposing 64 bit operations into 32 bit operations.
Fixes#17817.
- Fix handling of lo64 on big endian systems (fixes 28672)
mono-endian.h:
- Add optimization for s390x read64/read32/read16 operations
exceptions-s390x.c:
- Add profiling support for exception handler
We had a failing arm test which exposed that our caching of the
number of processors was leading to some inconsistencies when
the number of processors increased. TODO: Use the actual number of
online processors when rebalancing threadpool.
Rename the net_4_0 profile which is already only used to trigger copying of reference assemblies
to binary_reference_assemblies and include the 2.0/3.5 files there. This should make it easier
to add more profiles in the future and doesn't clutter the build system as much as making separate
net_2_0 and net_3_5 profiles that do the same.
This fixes a bug where we did not completely mimic .NET's exception handling.
We previously held onto the stacktrace when an exception was thrown if it already had one. This differs from how .NET behaves, which is to always set the stacktrace to the place that it was last thrown.
Ex:
using System;
class C
{
static Exception e;
static void Throw ()
{
try {
int.Parse (null);
} catch (Exception ex) {
e = ex;
}
}
public static void Main ()
{
Throw ();
try {
throw e;
} catch (Exception ex) {
Console.WriteLine (ex.StackTrace);
}
}
}
Would previously output:
at System.Int32.Parse (System.String s) [0x00000] in <filename unknown>:0
at C.Throw () [0x00000] in <filename unknown>:0
when
at C.Main()
is what .NET output. After this commit we output the same stacktrace as .NET.
They build in both desktop and mobile profiles, but the sources are
mostly unchanged i.e. they contain Windows dependent code (DllImports).
The plan here is to import everything essential in WCF as buildable
sources, then remove Windows dependencies, then implement (or bring back)
mobile-ready code. But this commit can be used for different strategies
(like, we import sources from working parts, step by step).
ConcurrentOrderedList isn't referenced in corlib's .sources file or anywhere else anymore,
so it was missing during "make distcheck".
Mono.Parallel still needs it though (and it is the only place), so move the file there.
We cannot start threads during stop-the-world pauses (some thread APIs,
including pthreads, can deadlock), and we want to do marking and sweeping
with the same threads. This new thread pool facility will allow that.
We tag pointers to blocks that are currently being processed. Those
must not even be dereferenced by other threads because the sweep
thread might free them at any point.
The nursery collector requires that sweeping has finished, and instead
of waiting it will cooperate with the sweep thread to finish more
quickly. The sweep thread will traverse the block array from high
indexes to low ones while the nursery collector will go from low to
high. They will contend only very briefly when they meet somewhere in
the middle.
Both the concurrent sweep thread as well as the nursery collector will
need access to the block array. Until we've made that lock-free,
we're simply using a lock.
AdjustmentRule specifies a DST period that starts and ends within a year.
When we have a DST period longer than a year, the generated AdjustmentRule may not be usable.
Thus we fallback to the transitions.
Fixes#24086.
Addresses an oversight in PR 1257 that caused {V}Specified fields to not be set during XML deserialization in some circumstances.
Adds test for optional value serialization round trip
WebConnectionGroup.Close() calls WebConnection.Close(), which takes connection lock and then takes the service point lock. Calling WebConnectionGroup.Close() leads to taking the service point lock *before* the connection lock, which leads to a deadlock.
Coop requires the following set of rules:
-blocking code must be wrapped with MONO_PREPARE_BLOCKING / MONO_FINISH_BLOCKING
Must not read managed refs read/writes inside the block
Managed memory (i.e. inside a byte[]) must be previously pinned[1]
-state escaping transitions (lazy thunks and others sneaky n2m transitions) must be wrapped with MONO_PREPARE_RESET_BLOCKING / MONO_FINISH_RESET_BLOCKING
This lands the thread in runnable state, so be careful to keep it suspendable by following the target environment rules.
The set of rules for what runtime code can/can't are still in flux, but here's the tentative list:
== On Wrapping syscall/waits
- Wrap it on the callee. We can't necessarily know in which context the syscall will be called. This will reduce reentrancy issues as blocking is not reentrant.
- Don't go blocking while holding locks as this will certainly deadlock.
- Avoid allocating memory while holding locks.
- Annotate blocking restrictions in the comments in the same way we do it for locking.
== On aborting blocking
- Avoid it as much as possible as it might lead to unbound pauses.
- Make sure you can always restore back to blocking.
[1] Since we conservatively scan the native stack, acquiring the ref outside of the block is enough for now.
Make sure all logging include the thread tid to ease correlation.
Add counters to check for proper balance of post/wait on the suspend semaphore.
Massive improvement in the coop suspend wait timeout crasher. It will now print
a cue card on the internal states. This makes finding the offending threads much easier.
Method index will be set if the method metadata token is shared by multiple generic specializations.
For StackFrame.GetILOffsetFromFile to work with generics methods a method index is required.
When creating a Mono.Security.Uri with the string "file:///var/lib/jenkins/workspace/test-mono-mainline@2/..."
(happens sometimes in System.Security.Policy.Zone-related unit tests on Jenkins) the current implementation
strips everything up until the @ sign.
Zone thinks the file doesn't exist locally as the Uri.LocalPath doesn't refer to a valid file on disk
anymore and this results in an incorrect zone value, making the tests fail.
Fixing this by treating the @ char differently when it is in an absolute path (as is done for other chars).
This splits the native backend from core functionality it needs to provide. For example,on posix, we want to
use the pthread_create code regardless of the backend enabled.
Native code should not normally be in runnable state. That's reserved only for managed code. In theory.
In practice any code that can witness the managed heap must be in the runnable state.
This in practice means all runtime code (icalls) and embeders. Right now lets focus on the runtime side.
The solution for this is to wrap all calls that could lead to unbound suspension in code that coordinates
with the GC - most syscalls that can block. This is realized with a pair of additional thread states.
1)Blocking: This the state where the runtime is doing something that can potentially block. The suspend count
will be > 0 if the current thread is suspended. In practice it won't suspend, just wait on resume.
2)Blocking and suspended: When leaving the blocking state, if the thread has a pending suspend, we transition
to this state while waiting for resume.
This move allows us to save the thread state much earlier on. In addition to the move, we now produce thread contexts without
the JIT TLS set. This might end up been an issue in some corner cases, just like with domain, so we'll address those when
they show up.
Other places are already logging tid so this makes correlation possible.
TID is a better pick than the MonoThreadInfo pointer as it's easier to find the thread on gdb.
Basically Microsoft SqlClient implementation is full of Windows dependencies
that doesn't work elsewhere. Our implementation has been fully managed
TDS implementation, so we want to bring it back.
This only builds and is not known to "work" yet.
Android does not provide complex.h in the API levels that we compile against so bundle our own header (based on the one from FreeBSD).
Turns out GCC already provides built-in handling for the complex functions used by the code so there's no need to provide our own implementations.
As it turns out, `perf` support crashes/hangs on a lot of Linux
kernels in the wild, and produces no output on some Android devices.
So, given that using a signal + helper thread is more reliable, use
it by default and make `perf` support optional.
The configure flag is now `--enable-perf-events`.
mono_aot_get_method () will not necessarily put methods into the
MonoDomain::jit_code_hash table. But it does return an IP that we
can use to look up the JIT info with mono_jit_info_table_find ().
src: https://bugzilla.xamarin.com/show_bug.cgi?id=27864
As of iOS 8.2 Apple updated Sqlite and broke queries that used to work
pre iOS 8.2 like the select command in this test, The pruppose of this
test is to know when apple fixes this. Expected test behaivour is as follows.
* If iOS 8.2+ Test will pass as long as apple does not fix the bug
* If iOS < 8.2 Test will pass as it does work as expected
* If iOS 8.2+ and apple fixed bug 27864 test will fail and we will need to
remove the fail check on lines 105 and 106
Filled with Apple. From bug report:
The problem appears to be caused by a bug in mmap on the arm64 ios.
In this test, we request a page and mmap returns successfully, but when trying
to access the mapped memory, the program crashes after the 4097th byte, meaning
that it only maps us 4kb(???). It should be mentioned that on arm64 ios the
page size is 16kb.
The way we calculated slot sizes was very brittle when it came to
small slots. Reducing the size of the block header could trigger it
skipping an important small size class, which would lead to increased
memory usage and slower execution times.
Now we always produce all possible small slot sizes, up to four times
the minimum object size.
The code just worked because it never reset cementing. It needs to be
completely rewritten.
With cementing enabled, at the start of a major concurrent
collection, we cannot reset it. That's because if we have
cemented objects, some remsets to them will be missing, and the
major collector does not scan the whole heap immediately, like
the non-concurrent one does.
The proper way to do it seems to be to reset cementing before
finishing a concurrent collection. All major objects that point
to formerly cemented objects must either be marked in the
mod-union table or the current card table. When we scan the card
tables, we should be able to just evict objects.
Currently, the finishing collection pause still does some
scanning via the worker thread. This might be a problem.
These two are consistently failing due to port re-use. Other hard-coded
ports exist, but let's target the *known* issues primarily, and can
handle the others ad-hoc if they demonstrate that they're problematic.
CreateLocal could fail in an unexpected manner. The change re-enables fall back to environment variable "TZ" and allows TimeZoneInfoNotFoundExceptions to be thrown instead of NullReferenceException.
The use case here is when you are documenting a managed wrapper on top of a native platform API. This related link can be used to link to the original platform documentation for that member. This lets the reader look up the semantics of the native call without you having to duplicate the documentation in the managed reference docs; leaving you to focus your energies on documenting any unique considerations when calling this managed API.
Example:
```xml
<related type="PlatformDocAPI" href="https://msdn.microsoft.com/en-us/library/system.console.writeline">Microsoft documentation for <c>System.Console.WriteLine</c></related>
```
If you have a URL of the form ``T:System.Collections.Generic.Dictionary`2``, it parses correctly, but the `EcmaDesc` instance returned by the parser will throw an exception if you try to call the `.ToEcmaCref ()` method. This patch resolves this issue and returns a correctly formatted URL in this instance. Unit test included.
The existing update was not doing a good job of matching members that have both generic and non-generic members. So for example, if you had a method, `Foo<T>`, and added a non-generic version in a future update (`Foo`); you could end up with a situation where one of the members was being duplicated.
at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00014] in /Users/marek/git/mono/external/referencesource/mscorlib/system/throwhelper.cs:56
at System.Collections.Generic.List`1[System.Threading.Thread].get_Item (Int32 index) [0x0000e] in /Users/marek/git/mono/external/referencesource/mscorlib/system/collections/generic/list.cs:199
at System.Net.Sockets.SafeSocketHandle.ReleaseHandle () [0x00052] in /Users/marek/git/mono/mcs/class/System/System.Net.Sockets/SafeSocketHandle.cs:79
at System.Runtime.InteropServices.SafeHandle.RunRelease () [0x00091] in /Users/marek/git/mono/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:203
at System.Runtime.InteropServices.SafeHandle.Dispose (Boolean disposing) [0x00019] in /Users/marek/git/mono/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:171
at System.Runtime.InteropServices.SafeHandle.Dispose () [0x00003] in /Users/marek/git/mono/mcs/class/corlib/System.Runtime.InteropServices/SafeHandle.cs:150
at System.Net.Sockets.Socket.Dispose (Boolean disposing) [0x0004d] in /Users/marek/git/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1168
at System.Net.Sockets.Socket.Dispose () [0x00003] in /Users/marek/git/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1174
at System.Net.Sockets.Socket.Close () [0x00009] in /Users/marek/git/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1185
at System.Net.Sockets.TcpListener.Stop () [0x0000d] in /Users/marek/git/mono/mcs/class/System/System.Net.Sockets/TcpListener.cs:296
at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.StopListening (System.Object data) [0x00022] in /Users/marek/git/mono/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpServerChannel.cs:257
at System.Runtime.Remoting.Channels.Tcp.TcpChannel.StopListening (System.Object data) [0x00013] in /Users/marek/git/mono/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpChannel.cs:105
at System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel (IChannel chnl) [0x00057] in /Users/marek/git/mono/mcs/class/corlib/System.Runtime.Remoting.Channels/ChannelServices.cs:463
at MonoTests.Remoting.CallsDomainServer.Stop () [0x00012] in /Users/marek/git/mono/mcs/class/System.Runtime.Remoting/Test/BaseCalls.cs:445
at (wrapper remoting-invoke-with-check) MonoTests.Remoting.CallsDomainServer:Stop ()
at (wrapper xdomain-dispatch) MonoTests.Remoting.CallsDomainServer:Stop (object,byte[]&,byte[]&)
CloseConnectionGroup can concurrently call RemoveConnectionGroup and remove a group that has added to removeList.
We now check that the group still exists before removing it.
Fixes#19823.
This will let us have both the Mono and the Microsoft ThreadPool at the same time.
To switch to the Microsoft one, set the MONO_THREADPOOL environment variable to "microsoft". It will default to the Mono one.
Support by the runtime is also implemented.
The main goal of this change is to ensure that all methods have a `TYPE_JIT`
event emitted in the stream before they are referenced in other events. Before
this change, `TYPE_JIT` events could arrive out of order or not be emitted at
all because of generic sharing.
We now use a separate thread for writing log buffers to the output file.
Whenever a method is referenced in a TLS log buffer, we add it to a TLS list of
methods. When we ship the TLS log buffer off to the writer thread, we also send
the TLS list of methods. The writer thread first goes over all the methods and,
if some of them haven't had a `TYPE_JIT` event emitted yet, emits them to a
temporary buffer which is flushed just before flushing the main log buffer.
This approach ensures that `TYPE_JIT` events will *always* come before the
events that reference them.
Bookkeeping of which methods have been emitted to the output stream is done in
a global, concurrent hash table. Before a thread adds a method to its TLS list
of methods, it checks if the method is in the hash table. If it is, we know
that the method has already been emitted to the output stream, so it isn't
added to the list. The writer thread is the only thread that updates the hash
table (which happens when it flushes the temporary method buffer). So,
eventually, all TLS method lists will end up being empty because all methods
have been emitted to the output stream.
When ReleaseHandle was called by RegisterForBlockingSyscall's DangerousRelease the current thread would be in blocking_threads but there would be no blocking system call to interrupt.
For some reason accept can only be interrupted by thread_abort.
We do not want to use thread_abort by default because it may abort non-atomic operations at an arbitrary point.
The problem was fixed by calling thread_abort_safely, and make sure the target thread was interrupted by calling thread_abort afterwards.
In this change thread_abort is only called if thread_abort_safely returns KERN_SUCCESS, which *should* mean that the target thread has already left the kernel code by the time thread_abort is called.
The problem was caused with the introduction of the pushless backend. We have to compensate for the arguments being popped by native stdcall callees, to keep param_area from shrinking. Fixes#27597
For the case of non-concurrent collector we don't want to mark stores from the heap to the heap, since it would add sgen overhead. When aot compilling we don't know whether the GC will be concurrent or not, so we fallback to the write barrier method.
We emit two write barriers, for the case of the concurrent and non-concurrent collector in the mscorlib image. All calls to the write barrier are made through the plt, calls which are resolved according to the GC configuration at runtime.
Move the ResumeThread () calls out of the assert and check for 0 (which means that the thread was resumed) instead of using the Mach-specific KERN_SUCCESS on Windows.
Fixes the Windows/MSVC build.
Related to https://github.com/mono/mono/commit/296347f.
With the new function it is possible to retrieve other processes start, user and kernel times.
In mach start time is available without special privileges but user and kernel times still require privileges.
This fixes an issue when building dotnet/corefx and all the SR.cs files are modified
because Mono used a HashTable internally in ResXResourceReader and it returned the
elements in a different order than MS.NET.
Even though this isn't explicitly mentioned in the docs, the MS.NET implementation returns
the elements in the same order as they appear in the resx and we should do the same.
We need an extra set of quotes around the whole command to properly handle commands
with spaces since internally the command is called through "cmd /c.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=27899.
All primitive types have a short encoding format that avoid using
a typeref token.
It's possible to encode them in another, longer, form with ELEMENT_TYPE_VALUETYPE + a typeref token.
Up to now, this was never seen in the wild so we never supported it.
This patch allows long form encoding of primitives.
STW and managed suspend share a lock to ensure there is only one active suspend initiator.
This originally caused a problem in the managed suspend path as it could be async suspended while it was
in the middle of the suspend protocol (check if top of stack is managed, install abort handlers, etc).
This was worked around by putting that inside a suspend critical section. The resulting code was horrible
as suspend boundaries became unstructured (yeah, pretty stupid idea on my end). Not only that but it had
a race condition.
If a thread doing managed suspend raced with a STW and lost, it would block on the global suspend lock to
finish. That thread would be blocked inside a critical section - the single thing you must not do inside one.
This could be reproduced by stressing mono/tests/sgen-new-threads-dont-join-stw.
The solution is to execute the managed suspend sequence in the same fashion as of a STW. IOW, take locks,
suspend, do stuff, maybe resume and drop locks.
The critical part is the "do stuff" one, which is different for abort and suspend, but everything else
is the same. So we wrap that into a callback and put the common parts in mono-threads. This gives
us structured locking and suspend boundaries.
This won't cause a GC to take longer to init as the critical section would block the STW from progressing
anyways.
While running tests if a socket is closed while blocking system calls are pending an exception is thrown.
A socket should not be closed when a blocking system call is pending.
The purpose of the exception is to inform us when AbortRegisteredThreads is not working.
Having a single unwind state means writes to it must be synchronized between sync and async suspend. We can't
have the state be broken as it could lead to bad unwinding or GC marking.
The original solution was to have an additional state in the self suspend path that signals it's writing to the
thread state and thus any async suspend must give up and let it finish. This ended up been overly complicated
as this requires two additional states instead.
By having a pair of unwind states both can write concurrently without the fear of clashing. This makes fetching the state
a little bit trickier but worth the trouble.
The simplified design has a much smaller state space, which is easier to reason about.
When begin async suspend lands in STATE_SUSPEND_IN_PROGRESS, the initiator don't need to perform an async suspend, it just needs to wait.
If a self suspend is promoted to an async suspend, it must be added to the pending ops set. This ensure that it will be waited otherwise
the suspend initiator might witness an unfinished self suspend and assert when fetching the thread state.
The alternative would be to change finish async suspend to account for the possibility of witnessing STATE_SUSPEND_PROMOTED_TO_ASYNC.
Solving this way requires less async suspends and doesn't increase the valid state space.
The new suspend machinery is based around a single word state machine that is manipulated using CAS.
This solves the first set of problems with the current approach, the lack of atomicity and the impossibility of
doing race free manipulation of protected state. This is specially acute when doing a self suspend.
Suspend data must be atomically protected while we prepare to self suspend so a resume request won't race with the current
thread putting itself to sleep. This is a classical problem that calls for a mutex/conditional variable pair. Except that all
locks in the suspend path must be suspend safe. Wait, WHAT?
A Suspend Safe Lock is a primitive that is obstruction free in the face of the kernel suspending a thread either performing a
lock operation or waiting on a lock to become available. This, unfortunately, is not possible with pthread_mutex on OSX. The
only safe primitive are kernel semaphores, for which doesn't exist conditional variables for.
So back to locking and self-suspend. We need a lock because the existing thread state is not atomic but we can't use a
mutex/condvar pair so we're left with racy code. Yay! The fix is using CAS over a single variable.
Another change was the hardening of the suspend/resume code on posix targets. First we replace a semaphore wait with
sigsuspend for async suspend. This is needed since sem_wait is not async-signal safe (yet sem_post is). Second, we now
respect interruption requests by having a pair of suspend signals, one with SA_RESTART and one without.
Onto the design of the suspension system, a few concepts that are useful looking around.
* Self suspend: This is when the thread decides to suspend itself.
* Async suspend: This is when a thread decides to suspend another thread.
* Suspend Initiator: This the name of a thread that decided to suspend one or more other threads. This is important
since all suspending threads will notify it when they are suspended. There can be only one initiator in the system
at a given time.
* Suspension count: Number of resume calls before a thread is back to running state.
There are 7 states that can happen while a thread is runnable:
* Running: just running...
* (Async|Self) Suspended: Suspended, the difference comes into play when resuming.
* (Async|Self) Suspend Requested: Suspend requested, but not completed. See more below for the discussion on why the request state is needed.
* Suspend In Progress: Self suspend started saving its state thus async suspend should not modify it.
* Suspend Promoted to Async: Async tried to suspend a thread in the middle of a self suspend, it wants to be notified.
Now to the suspension protocol and how it happens on a high level view.
Suspension starts with a suspend request, which bumps the suspend count by one. This suspend request can be fulfilled either
by an async or self suspend action. This is confusing as there's only one initiator but any number of threads can be self suspending.
Async suspend then performs a platform specific action such as posix signals that forces a transition on the target. In the case
of self suspend, it depends on the thread polling its state and trigger the transition.
This works fine except that the suspend state is one huge struct with tons of fields. To control concurrent access to it we use a
single initiator in the case of async suspend and we put the thread in a transitional "saving my state" in the case of self suspend.
In the case of async suspend, the initiator must wait for all 1+ threads to notify back that they have suspended. Only after that
it's possible to know if the async suspend request actually worked or not (we might have hit a dying thread).
Together with this, there's an optional implementation of STW in sgen that can use this new machinery. To enable it set the
MONO_ENABLE_UNIFIED_SUSPEND env var for now while it gets more testing.
They're basically the same thing, but v120 has DX10+ capabilities and v120_xp
is DX9 only. Since we're not building against DirectX, the difference is
purely academic - but changing the value to v120_xp means MSVC binaries run
on XP+, not Vista+
This change was made so StackFrame dumps now show a native offset when the IL offset is unknown.
The native offset can be used by mono-symbolicate tool to retrieve an IL offset from a .msym file.
With AOT sequence points are stored in a .msym file.
As the sequence point data is not avaible at run time, AOT stack traces display a native offset.
mono-symbolicate tool is now able to retrieve an IL offset from a method name, native offset, and the data stored on the .msym file.
The IL offset can then be use to retrieve a filename and line from a .mdb file.
Abstract classes can still have subclasses with KnownType attributes, which are allowed in deserialization.
This used to work as the '__type' hint was always honored no matter the type, and broke with https://github.com/mono/mono/commit/71e152accc727089faffa6b4fd6bf58cb62636cf which removed that behavior.
It fails randomly on Jenkins and my own CI. To reproduce, just wrap the body of the test in while(true) and run for a few minutes.
I tested on MS.NET as well and it fails the same way there, so it's not Mono's implementation of Dataflow.
Filed https://bugzilla.xamarin.com/show_bug.cgi?id=27757 for tracking.
There was a memory leak caused by not having a lookup mechanism for
the RegistryKey. In addition, the entire code to dispose code was
never used (due to the leak), and it was wrong.
In addition, added locking to the "values" field, which currently was
racy.
No test cases, the repro is to run the above code for about 5 minutes.
This is a bit of an hack but it works for now... ideally we should be processing the Unicode command line flags passed by the CRT at startup instead of trying to convert the MBCS string to a wide string.
That was still useful in 2003/2004 but the technical and legal landscape
changed a lot since then. Removing the old, limited key size, cipher
suites also allow removed additional parts of the code that deals with
them.
We used to swallow the error, which is unhelpful.
The reason for that might be because we probe multiple names before giving up but
even then, it's ok log all attempts. It will make troubleshooting easy, even if we
have to go through a lot more log entries.
When using stements with parameters, the OdbcCommand would throw an exception
on ExecSQL when no row was returned. The commit adapts the change done in
5264613b6d for the case of unprepared statements
without parameters.
After MemoryCache was imported from referencesources, some tests started
failing occasionally. Cross-testing on MS.NET showed that you need to
access the cached item to make MemoryCache.GetCount() reliably return the
correct number after an item was expired from the cache.
Also removed __MonoTimerPeriod and __MonoEmulateOneCPU configuration variables,
they were used in Mono code before and don't make sense with the new code.
* Find the type map element that is the most-specific to the
object in question, not the first type it is an instance of
Change-Id: I1867e790bf9f377ce0ae02871f4561b760e27624
Given the test data in this patch the wrong element name
is used when serializing TestSerializeSecondType
Change-Id: I8aff732dfd22f4f654fb42f2d3b987d7ce58d600
The unstable image seemed to cause problems recently.
We should just use the default image and fetch Cygwin ourselves.
Also added caching of the Cygwin files and simplified the script a bit.
There was a memory leak caused by not having a lookup mechanism for
the RegistryKey. In addition, the entire code to dispose code was
never used (due to the leak), and it was wrong.
In addition, added locking to the "values" field, which currently was
racy.
No test cases, the repro is to run the above code for about 5 minutes.
It should be using RESOURCE_STRINGS, but mcs doesn't support its special
option for string resources for multiple files.
The resource .cs files are generated by genresstringcs.sh, but System.Xml.txt
contains some bogus characters that prevents source generation, so after
the tool has generated the sources, I manually fixed them.
It won't matter once mcs supports the option for multiple files anyways.
Removed Configuration dependencies and codegenerator parts in XmlSerializer
as well as switching CodeIdentifier implementation to old mono stuff
as referencesource totally depends on CodeDom (mono doesn't).
The order of those namespaces are insignificant, and the latest
combination of mono corlib (partly referencesource-d) and sys.xml
(referencesource except for XmlSerializer) caused this implementation
glitch.
MS referencesource changed XmlTextWriter behavior regarding EOL so that
now it preserves CRLF as is, instead of replacing them with
XmlWriterSettings.NewLineChars (mono implementation behavior).
There are some tests that depend on old behavior. The entire points of
those XmlDataDocument tests are not about checking EOLs, so just replace
the test XML file to not contain CRLF.
There is implementation mismatch in XmlDocument event order regarding
Load(). Take this code:
string xml = "<root><child>1</child></root>";
var doc = new XmlDocument ();
doc.NodeInserted += (o, e) =>
Console.WriteLine (e.Node.NodeType + e.Node.LocalName);
doc.LoadXml (xml);
This is mono output before referencesource:
Text#text
Elementchild
Elementroot
This is with referencesource:
Elementchild
Text#text
Elementroot
So, there are event order differences in our two implementations.
Now, XmlDataDocument depends on those XmlDocument events to fill DataRow
values. It worked fine with pre-referencesource System.Xml model, but
with referencesource it skipped to fill data row values.
This change makes sure to fill data row values from text node which are
added _after_ the parent node is added to the document.
It is not simply replacement because we have to workaround dynamic codegen
for Xamarin.iOS.
Also there were several tests failing with MS implementation (e.g. for
W3C DOM conformance), so we had to disable them.
There is one regression that rather needs to be fixed in Reflection.Emit.
Also, some WCF tests fail with this implementation. They need to be
investigated, reviewed and appropriately fixed.
In certain cases, hovering over a ToolStripMenuItem
that has a tool tip defined will result in the tool
tip appearing behind, and hidden by, the context
menu containing the item. The change is to cause
the tool tip to be pushed to the front when it is
displayed.
If a profiler has not installed a coverage filter, or the coverage filter has returned FALSE, then calls to mono_profiler_coverage_get trigger a assertion failed warning in g_hash_table_lookup.
If a profiler had requested MONO_PROFILE_COVERAGE events and not installed a
coverage filter, then the coverage info is NULL and a crash quickly followed
false when given a null argument instead of throwing an exception.
According to the msdn here:
https://msdn.microsoft.com/en-us/library/b4e35dwy%28v=vs.110%29.aspx
this method should never throw an exception. This was also confirmed
with the official Microsoft runtime.
This change is released under the MIT license.
/Users/builder/data/lanes/monodroid-mavericks-master/7de6731a/source/mono/support/serial.c:25:26: fatal error: linux/serial.h: No such file or directory
#include <linux/serial.h>
The header is only available on Android NDK API level >= 21.
This changes all bridges to use the _safe variant of sgen_obj_get_descriptor. Bridge processing happens in
the post-scan world, before objects get untagged.
We currently ship a horribly outdated version of EF. This is unnecessary since EF is on NuGet and has an active set of users using it on Unix.
Miguel gave his +1 on the mailing list already.
When a socket has been closed as part of the negotiation, the
SendAlert method would crash when trying to reuse the socket.
Add try/catch around this to prevent this.
Fixes#19334
The new suspend machinery is based around a single word state machine that is manipulated using CAS.
This solves the first set of problems with the current approach, the lack of atomicity and the impossibility of
doing race free manipulation of protected state. This is specially acute when doing a self suspend.
Suspend data must be atomically protected while we prepare to self suspend so a resume request won't race with the current
thread putting itself to sleep. This is a classical problem that calls for a mutex/conditional variable pair. Except that all
locks in the suspend path must be suspend safe. Wait, WHAT?
A Suspend Safe Lock is a primitive that is obstruction free in the face of the kernel suspending a thread either performing a
lock operation or waiting on a lock to become available. This, unfortunately, is not possible with pthread_mutex on OSX. The
only safe primitive are kernel semaphores, for which doesn't exist conditional variables for.
So back to locking and self-suspend. We need a lock because the existing thread state is not atomic but we can't use a
mutex/condvar pair so we're left with racy code. Yay! The fix is using CAS over a single variable.
Another change was the hardening of the suspend/resume code on posix targets. First we replace a semaphore wait with
sigsuspend for async suspend. This is needed since sem_wait is not async-signal safe (yet sem_post is). Second, we now
respect interruption requests by having a pair of suspend signals, one with SA_RESTART and one without.
Onto the design of the suspension system, a few concepts that are useful looking around.
* Self suspend: This is when the thread decides to suspend itself.
* Async suspend: This is when a thread decides to suspend another thread.
* Suspend Initiator: This the name of a thread that decided to suspend one or more other threads. This is important
since all suspending threads will notify it when they are suspended. There can be only one initiator in the system
at a given time.
* Suspension count: Number of resume calls before a thread is back to running state.
There are 7 states that can happen while a thread is runnable:
* Running: just running...
* (Async|Self) Suspended: Suspended, the difference comes into play when resuming.
* (Async|Self) Suspend Requested: Suspend requested, but not completed. See more below for the discussion on why the request state is needed.
* Suspend In Progress: Self suspend started saving its state thus async suspend should not modify it.
* Suspend Promoted to Async: Async tried to suspend a thread in the middle of a self suspend, it wants to be notified.
Now to the suspension protocol and how it happens on a high level view.
Suspension starts with a suspend request, which bumps the suspend count by one. This suspend request can be fulfilled either
by an async or self suspend action. This is confusing as there's only one initiator but any number of threads can be self suspending.
Async suspend then performs a platform specific action such as posix signals that forces a transition on the target. In the case
of self suspend, it depends on the thread polling its state and trigger the transition.
This works fine except that the suspend state is one huge struct with tons of fields. To control concurrent access to it we use a
single initiator in the case of async suspend and we put the thread in a transitional "saving my state" in the case of self suspend.
In the case of async suspend, the initiator must wait for all 1+ threads to notify back that they have suspended. Only after that
it's possible to know if the async suspend request actually worked or not (we might have hit a dying thread).
Together with this, there's an optional implementation of STW in sgen that can use this new machinery. To enable it set the
MONO_ENABLE_UNIFIED_SUSPEND env var for now while it gets more testing.
This has been requested by the maintainers of Npgsql a few times already (https://bugzilla.xamarin.com/show_bug.cgi?id=23119) and we should do it for Mono 4.0.
Miguel gave his +1 on the mailing list already.
This variable must be set to all threads that have been properly suspended. This is
an initial step to simplify suspend state and use explicitly named variables instead
of hiding state in stopped_ip / stopped_domain.
MonoThreads was previously ignoring sgen's in_critical_region, which could lead
to a thread suspended inside a gc critical region leading to the GC not been able
to STW.
(some commits occurred while I have been cherry-picking a lot of "they are
in import-system-xml branch but it works with existing sys.xml" stuff.)
work in master
In referencesource, XmlReader.SchemaInfo does not return different instances
for each node at its state but just returns the XmlReader itself (which
implements IXmlSchemaInfo). Hence, if we just set the corresponding
IXmlScemaInfo to each XObject, it results in inconsistent state.
This fixes two regressions in ExtensionsTest (XAttributeFailValidate and
XAttributeThrowExceptionValidate).
With referencesource, XmlWriter for TextWriter buffers the output.
When closing XamlXmlWriter, it does not flush the output, causing
the buffered XmlWriter output discarded in the wild.
MTOM writer didn't expect multiple top-level elements are rejected at
ConformanceLevel.Auto, neiher do against Write[Start/End]Document() with
such elements.
Also Flush is often needed before directly writing to the Stream(Writer).
EOLs handling was also inconsistent between referencesource and old mono.
XML Schema compilation is done in referencesource.
XmlSchemaImporter is based on mono code. Hence this glitch happened.
The following regression is fixed:
1) MonoTests.System.Xml.Serialization.XmlSchemaImporterTests.DefaultTypeTopLevelElementImportsAllComplexTypes : System.InvalidOperationException : 'Root' is missing.
at System.Xml.Serialization.XmlSchemaImporter.ImportTypeMapping (System.Xml.XmlQualifiedName name) [0x0005a] in /svn/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSchemaImporter.cs:453
at MonoTests.System.Xml.Serialization.XmlSchemaImporterTests.DefaultTypeTopLevelElementImportsAllComplexTypes () [0x00039] in /svn/mono/mcs/class/System.XML/Test/System.Xml.Serialization/XmlSchemaImporterTests.cs:1104
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) [0x00054] in /svn/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
I initially discarded this change, because locking BaseSet (name, sec), didn't prevent the threads from trying to add the same key. That said, following the code, the point at which it actually fails is in NameObjectCollectionBase.BaseAdd, lines 331 and 332. The threads were arriving the second line at the same time:
if (_entriesTable[name] == null)
_entriesTable.Add(name, entry);
In brief, it's safe to call BaseSet twice with the same key, so it's safe to lock only the call to BaseSet
There was some glitch in CP932 encoding and referencesource Encoder
that caused error in Convert(), shown in System.XML tests.
To avoid this, bring back old Encoder as we used before and keep
compatible processing.
It might be buggier, but doesn't regress. We may be able to bring nlp-
based Encodings later too.
If two threads request the same section, which isn't yet cached, both try to insert it into the cache, causing a "Key duplication when adding...". It's neccesary to lock the getter. This solves bugs #5263, #7785, #18303
This generates an XML representation of the check-seq-points target,
as separate tests, which can be easily tracked by anything which
parses NUnit output (e.g. Jenkins or other CI systems). For example,
we are currently regressed on this on ARM.
Creating hardlinks in .NET doesn't have a nice API and using Mono.Unix/Pinvoke doesn't
seem worth the effort at this point since the feature is off by default on msbuild as well.
This is enabled by passing "aot=dump" to the Mono AOT driver and will create a JSON file in the working directory with the name of the assembly.
It's still a work-in-progress and will see improvements in the data dumped as it's needed.
CCLD monodis.exe
../../mono/metadata/.libs/libmonoruntimesgen-static.a(libmonoruntimesgen_static_la-opcodes.o): In function `mono_opcode_name':
/cygdrive/c/projects/mono-817/mono/metadata/opcodes.c:63: multiple definition of `mono_opcode_name'
../mini/.libs/libmonosgen-2.0.dll.a(d001720.o):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
This change does not involve Windows-specific NLS-based encodings.
We will be still using I18N assemblies until we make more grand design
changes (Xamarin products premise those assemblies).
This also fixes bug #23771 and probably more.
Right now (without this change), Debug.Assert **always** formats its string parameters, even if doing so wouldn't be necessary because the condition is true. This has a huge impact on code that asserts frequently because it assumes that calling Assert(true, ...) is cheap.
.NET implementation is able to get method tokens from other modules.
This was causing a regression on a System.Xml.Xsl.XslTransformTests.Bug487065 while using referencesource's System.Xml implementation.
Custom attributes encoding means it's possible to have a scope that will
point into a PCL facade even if we (just before saving) will resolve all
type references.
Since all other references can be made on the _real_ assembly and that
we do not want to include any facade assembly just for this we need to
resolve those type and update their scope.
This reverts commit c96e58280c.
Getting this to work right with regards to register allocation
is turning out to be more complicated than it seems. Going to
abandon this for now.
CharUnicodeInfo had conversion methods for uppercase/lowercase
conversion, and they are actually used by TextInfo. So moved them.
Then added another icall for "lite" version of internal character table
loader.
The new CharUnicodeInfo depends on "charinfo.nlp" resource file, which
does not exist in referencesource but can be generated by coreclr build
tools (as src/mscorlib/src/System/Globalization/Tables/CharInfo.nlp).
The coreclr rev. that built this specific checkin was c4eb037.
Works around the following compile error:
```/Users/triton/Development/mono/mono/metadata/decimal-ms.h:3:16: error: redefinition of 'struct tagDEC'
typedef struct tagDEC {
^
In file included from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/unknwn.h:37:0,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/objidl.h:477,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/objbase.h:66,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/ole2.h:17,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/wtypes.h:12,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/winscard.h:10,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/windows.h:97,
from /Users/triton/Development/mono/mono/io-layer/io-layer.h:24,
from /Users/triton/Development/mono/mono/metadata/process.h:17,
from /Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/unistd.h:11,
from /Users/triton/Development/mono/mono/metadata/icall.c:27:
/Users/triton/Development/monodroid/builds/toolchains/windows/mxe/usr/i686-w64-mingw32.static/include/wtypes.h:452:16: note: originally defined here
typedef struct tagDEC {
^
```
Design:
- Handle r4 types in the front-end normally like other types.
- Controlled using a 'float32' optimization flag, may become the default in the future.
- new stack type STACK_R4.
- new set of opcodes prefixed by 'R', use the same vregs as 'F' opcodes.
- opcodes which worked with r4 values are used as before, but generate different code
in the back end (OP_R4CONST/OP_LOADR4_MEMBASE/OP_STORER4_MEMBASE_REG, etc.).
The mono-context.h file uses definitions such as mips_fp and mips_sp,
which are defined in <mono/arch/mips/mips-codegen.h>, but this file is
not included, leading to build failures.
This fix is similar to 4437ecea91 (for
ARM).
Signed-off-by: Thomas Petazzoni <[email protected]>
It was caused by a mismatch of the `sig` and `csig` variables when looking the wrapper in the marshalling cache.
This was manifesting as the following crash in all Monodroid programs:
```
#0 mono_type_hash () at /Users/joao/Dev/droid/mono/mono/metadata/metadata.c:1390
#1 0x7512edf4 in mono_signature_hash () at /Users/joao/Dev/droid/mono/mono/metadata/metadata.c:4957
#2 0x75115d18 in signature_pointer_pair_hash () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#3 0x751dca10 in rehash () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#4 0x751dcbe0 in monoeg_g_hash_table_insert_replace () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#5 0x75119570 in mono_mb_create_and_cache_full () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#6 0x75127390 in mono_marshal_get_native_func_wrapper () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
#7 0x75127780 in mono_ftnptr_to_delegate () from /Users/joao/Dev/droid/monodroid/tests/runtime/gdb-symbols/libmonosgen-2.0.so
```
Originally introduced in https://github.com/mono/mono/pull/1540.
Olson TZ transitions are in UTC, and TryGetTransitionOffset used the TZ standard time.
TryGetTransitionOffset was comparing UTC with TZ standard times thus DST transitions could be obtained some hours before their start.
TryGetTransitionOffset is now changing provided times to UTC before comparing them with the transition times.
Fixes#25050.
This completes the list of methods in decimal-ms.c that are surfaced
to the Decimal class. This change also swaps out the Decimal class
from Mono to the Microsoft implementation.
This has not been tested yet, beyond the compiler being able to read
decimals (it did crash without it).
CoreCLR has two different bits of code for SearchScale, it looks like
one is just old and has not been updated. Moved to the new one, and
updated the code to pass the extra data that is missing from the
former one.
fread() spent a great deal of time locking, and we called malloc() once for
each entry. Replacing fread() with read() plus manual buffering, as well
as replacing malloc() with a static buffer, improves throughput by an
order of magnitude.
This also adds an '--input' option for reading from a stream other than
standard input.
This is a port of the CoreCLR Decimal support to C and to the Mono
coding conventions. In the process of porting the code, I removed a
bunch of COM-isms and some Windows-isms that were just workaround with
compatibility typedefs and replaced it instead with stdint.h data
types as well as Mono assertions.
There are still a few methods missing, and the managed library is not
plugged yet (both constructors likely need to be altered to be managed
proxies to the init method).
- otherwise we assert in sgen allocator
in sgen-gc.h:EMIT_TLS_ACCESS_NEXT_ADDR
thru sgen-alloc.c:create_allocator
- note that it is also disabled for ARM[64] and X86
on android
Despite what the makefiles would have you believe, this was never
actually used when running the test suites. Don't ask me why - my
make-fu isn't good enough. Regardless, it's a bad idea to only
run tests for a specific set of assemblies. If some tests fail or
are unstable, they should be fixed, or disabled and have a bug
filed. Sweeping them under the rug like this is the wrong thing
to do. Incidentally, this commit doesn't add any new failures.
* Removed all old profiles from VALID_PROFILE checks.
* Removed most logic under checks like ifeq (net_2_0), $(PROFILE)) as
it is dead code now that those old profiles are gone.
* Simplified the list of assemblies in mcs/class/Makefile now that we
only have one profile.
* LIBRARY_NEEDS_POSTPROCESSING has been removed as it was only used by
old 1.x assemblies that no longer exist.
* Build logic that sets MONO_PATH now points to mcs/class/lib/net_4_5
instead of mcs/class/lib/net_2_0.
The `make tzi.exe` target had bitrotted, and the
`make android-dump-tzdata` target generated inadvertent/unintentional
errors. Fix the makefile so that things build and run.
mono_marshal_get_native_func_wrapper now uses native_func_wrapper_cache indexed by SignaturePointerPair,
Using SignaturePointerPair index instead of MonoMethod index avoids problems when one native function needs multiple wrappers.
e.g: when the managed code creates delegates for function pointers with parameters that require different marshallings.
This fixes bug 26127.
Due to the removal of the net_2_0 profile, the files in ../System.Web/System.Web.Security aren't included in make dist anymore since they aren't used in System.Web (the classes got moved to System.Web.ApplicationServices.dll in .NET 4).
This breaks the tarball builds, as System.Web.ApplicationServices relies
on those files, so we now include the ReferenceSource equivalents instead.
When searching for a pointer with '--color' or '-c', the field in a
protocol entry that matched will be highlighted; when searching for
multiple pointers, they will be highlighted in different colors
according to their order on the command line. When highlighting more
than six pointers, colors will be reused.
The previous implementation did a ton of reflection and boxing making
it about 4x slower than it should be. This new (native) implementation
simply memcpy ()s the values out of the Enum objects and then does the
bitwise AND.
In addition, the JIT now recognizes this common IL pattern:
<push int or long ptr>
<push int or long>
box MyFlagsEnum
constrained. MyFlagsEnum
callvirt instace bool class [mscorlib] System.Enum::HasFlag (class [mscorlib] System.Enum)
This is generated from C# code such as:
MyFlagsEnum a = ..., b = ...;
a.HasFlag (b);
When the operand types of the `box` and `constrained.` instructions are
the same, we can skip all the slow stuff that HasFlag () normally does
and simply turn the whole thing into this IR:
<this> = loadi4_membase <this_ptr>
<temp> = int_and <this> <flag>
icompare <temp> <flag>
<result> = int_ceq
This is about 60x faster than the old HasFlag () without any JIT support
and about 15x faster than the new HasFlag () native implementation.
Also, added missing argument checks to HasFlag ().
This reverts partially commit 753229c72dd9f2b63beb097700e350164b887c2.
Marshallers are not called for ICalls parameters so the change of ICalls parameters to SafeHandle did not prevents handle reuse.
To prevent handle reuse ICalls are no longer called directly.
Instead we call a method that receives a SafeHandle and wraps the ICall call with safeHandle.DangerousAddRef and safeHandle.DangerousReleaseRef.
This guarantees that the safe handle reference countererence does not reach zero before or while the ICall, thus avoiding the handle beeing released and possibly reused.
By locking `threads_lock` before launching the thread, we guarantee that the thread is not going to remove itself from `threads` before we actually add it to `threads`.
The added file Test/symbolicate.expected contains the value that we expect to find in Test/out/symbolicate.out.
make check now uses Test/symbolicate.expected.
Sequences of OP_IL_SEQ_POINT instructions are now reduced to only the instruction.
This removes about half of the generated sequence point instructions.
This HMAC cipher accepts any key size (1), took from RFC2104, which uses
the full 64 bytes of key since it has a block length of 64 bytes.
(1): https://www.ietf.org/rfc/rfc2104.txt - Chapter 2: Definition of HMAC
Fixes a crash when there are two methods overloaded by arity:
System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[XElement] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00038] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2371
at System.Linq.Enumerable.SingleOrDefault[XElement] (IEnumerable`1 source, System.Func`2 predicate) [0x00007] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2445
at Xamarin.ApiDiff.MemberComparer.Find (IEnumerable`1 target) [0x00019] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:72
at Xamarin.ApiDiff.MemberComparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x0003c] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:83
at Xamarin.ApiDiff.MemberComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x000a2] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/MemberComparer.cs:55
at Xamarin.ApiDiff.ClassComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0005b] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ClassComparer.cs:210
at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
at Xamarin.ApiDiff.ClassComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x00055] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ClassComparer.cs:67
at Xamarin.ApiDiff.NamespaceComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0001a] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/NamespaceComparer.cs:75
at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
at Xamarin.ApiDiff.NamespaceComparer.Compare (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x00055] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/NamespaceComparer.cs:49
at Xamarin.ApiDiff.AssemblyComparer.Modified (System.Xml.Linq.XElement source, System.Xml.Linq.XElement target) [0x0002b] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs:70
at Xamarin.ApiDiff.Comparer.Compare (IEnumerable`1 source, IEnumerable`1 target) [0x00093] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/Comparer.cs:80
at Xamarin.ApiDiff.AssemblyComparer.Compare () [0x0004a] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/AssemblyComparer.cs:50
at Xamarin.ApiDiff.Program.Main (System.String[] args) [0x00328] in /Users/builder/data/lanes/macios-mac-master/177810cb/source/mono/mcs/tools/corcompare/mono-api-html/ApiDiff.cs:164
Many fonts, including the default DejaVu Sans, use kerning between
certain character pairs. This resulted in garbled or even invisible
display during typing of strings with a lot of kerning going on. An
attempt is made to retain the current speed-optimized implementation
while using accurate, slower string width measurements when needed.
See https://bugzilla.xamarin.com/show_bug.cgi?id=26478 for details.
This is so we can avoid miscompiling things left and right
when new overloads are added. For example, before this patch,
we miscompiled the new 4-parameter CAS () overload.
Calling mono with flag --compile-all=1 avoids running the code and possible stdout problems and it also compiles every method.
As test_op_il_seq_point.sh now only compiles it is now capable of testing libraries and executables that are expecting parameters.
Failure caused by https://github.com/mono/mono/commit/2f1b464beb14a1b6b6099a03fc332493293bef35.
```
../../../../../mono/mono/utils/mono-proclib.c:104:8: error: use of undeclared identifier 'errno'
if (errno != ENOMEM)
^
../../../../../mono/mono/utils/mono-proclib.c:104:17: error: use of undeclared identifier 'ENOMEM'
if (errno != ENOMEM)
```
This reverts commit 4d3877d23b.
We cannot remove this file as the build logic is expecting it since we override it from mono-extensions.
```System/Guid.cs(42,7): error CS0246: The type or namespace name `Crimson' could not be found. Are you missing an assembly reference?```
It started failing when code from MS referencesource was imported.
I checked on MS.NET and the list of attributes is now the same on Mono
(except an additional __DynamicallyInvokableAttribute on MS.NET).
These are emitted by recognizing Interlocked and Volatile methods. They allow
us to generate more efficient instruction sequences on certain architectures
(e.g. ARM64 which has specialized load-acquire and store-release instructions).
* Barrier semantics is now specified as acquire, release, and sequentially
consistent. This is in line with CIL/.NET semantics and also maps better to
LLVM's fence types.
* Use the mfence instruction for memory barriers on AMD64 as it's smaller
(and presumably also faster).
* We now emit specific barriers when using LLVM instead of always emitting
sequentially consistent barriers.
* Barriers emitted for the CIL volatile prefix instruction are now more
specific instead of always being sequentially consistent.
* Fixed emission of CEE_MONO_MEMORY_BARRIER in SGen's managed allocators. For
some reason (that I haven't had time to look into), mono_mb_emit_op ()
clobbers the barrier kind operand. This meant that in many cases we ended
up not actually emitting any barriers because the switches in the backends
didn't handle the clobbered values. mono_mb_emit_i4 () seems to work.
* Fixed handling of CEE_MONO_MEMORY_BARRIER in mono_method_to_ir (). Since it's
a custom opcode, the opcode is actually 2 bytes long. Another source of
barriers not actually being emitted.
This fixes Monodroid cross build, which broke with https://github.com/mono/mono/commit/adca49cdd28e7c7b0cc65073167c143cc5f52fdd.
Error:
```
/Users/joao/Dev/droid/mono/mono/mini/mini.c:6645:31: note: each undeclared identifier is reported only once for each function it appears in
/Users/joao/Dev/droid/mono/mono/mini/mini.c: In function 'mono_sigsegv_signal_handler':
/Users/joao/Dev/droid/mono/mono/mini/mini.c:6704:31: error: 'SIGSEGV' undeclared (first use in this function)
mono_handle_native_sigsegv (SIGSEGV, ctx, info);
```
At some point we zeroed all the unloaded domain's objects first, and then we cleared
weak links, ephemerons, etc. Because the objects were zeroes, we only had to
check that the vtable was null. Now we do it the other way around: clear weak links,
ephemerons, ..., and then zero objects. Obviously we now need to check for the
object's domain, because their vtables will not be null.
Add #ifdef to ignore code in mono/metadata/mono-route.c if OS=linux
Also remove mono-route.c from msvc/libmonoruntime.vcxproj (Windows)
Add #ifdef to ensure mono/metadata/mono-route.h code is not included
on Linux
Change to using #if defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD)
Use sizeof(addr) for maximum length of IP address string, instead of the hard-coded 16.
Should the size of addr ever change it will keep us from disaster in case if shrinking the array length.
Also, do not ignore snprintf return value - check for truncated output and act accordingly if it happens.
Add Tests for System.Net.NetworkInformation/IPInterfacePropertiesTest.cs and System.Net.NetworkInformation/NetworkInterfaceTest.cs
Remove accidental Copyright
add a space before the opening parenthesis, as shown in the coding guidelines.
Indent TestFixture to align with coding style of newer Test classes
Use G_N_ELEMENTS(mib) instead of sizeof(mib) / sizeof(mib[0])
Pinning is done in the worker thread, but reset in the main thread.
The main thread must wait for the worker jobs to finish until it can
reset pinning. We didn't do this before.
When importing a project that contains embedded resources, the id
of those resources must be generated using the path relative
to the project file that includes them, not relative to the
main project file. To fix this problem, we now generate a
Link metadata property for those resources that has the correct
relative path, and later this is used to generate the correct
id for the resource. We also now store a new metadata value
for all items (DefiningProjectFullPath) which contains the
path to the project file that defines the element. This is
used to check if an item was defined in an imported file,
in which case the Link assignment may need to be made.
This fixes bug BXC 20966.
In the TextBoxTest.PasteTest () test case we copy the string "ABCD" to the clipboard.
We then try to paste it again and see if it's the same.
Internally in WinForms, the clipboard data is retrieved via an X11 API that returns
a pointer to the string. In this case, we have a unicode/utf16 string that usually
looks as follows in memory (2 byte per character):
65 'A'
0
-
66 'B'
0
-
67 'C'
0
-
68 'D'
0
-
0 '\0' end of string
0 potential garbage from here on
-
0
0
...
The bug is that we use Marshal.PtrToStringUni (), which reads until the
first null *char* not the first null *byte*.
Imagine if we get the following (happens sometimes):
65 'A'
0
-
66 'B'
0
-
67 'C'
0
-
68 'D'
0
-
0 '\0' end of string
230 <--- garbage, but considered part of a char by PtrToStringUni ()
-
47
56
-
74
43
...
This produces garbage like "ABCD㠯⭊" since PtrToStringUni () reads beyond the original string.
The fix is to use the nitems variable that is returned by the X11 API (it contains the
actual number of bytes in the string) and copy the bytes manually. We already do
the same for the UTF8 case above.
This fixes the TextBoxTest.PasteTest () that intermittently fails on Jenkins.
Fixes#26008
We do not want (transition.DayOfWeek - first) % 7 to be negative.
As (transition.DayOfWeek - first) cannot be lower than -7, adding 7 to it solves the issue.
Little and big endian cases were inverted. It can be seen e.g. from the
reference http://locklessinc.com/articles/locks, where the ticket algorithm
is given for little-endian machines
As a consequence, without this patch, if TryEnter succeeds, it increments
ticket.Value instead of ticket.User, which puts the SpinLock in a corrupted
state, and makes it impossible to release afterwards.
SafeHandle.IsInvalid refer only to the handle value it self. Being true only if the handle is 0 || -1
In all cases, Releasing, Disposing or SetHandleAsInvalid does not change the handle value, so SafeHandle.IsInvalid will remain unchanged.
IsClosed will be true if the handle is released or if SetHandleAsInvalid is called.
The handle will not be released when calling Dispose if SetHandleAsInvalid was called.
The handle is not released at Dispose but when the last ref is removed by DangerousRelease
Some autoconf checks were missing when running on Windows.
Added stub for mono_get_local_interfaces back that was removed in b92e560d3f
for systems like Windows that have neither HAVE_SIOCGIFCONF nor HAVE_GETIFADDRS.
When config PhysicalMemoryLimitPercentage is not set or set to zero MemoryCache.PhysicalMemoryLimit value will depend on the total physical memory available.
Now even if multiple MemoryCacheEntry are added to CacheUsage with the same date time CacheEntryCollection is able to sort them for removal in the same order.
.NET was using this to retrieve the size of an object graph, by using special logic on its GC.
This version of SRef is not doing that, because Mono does not provide that kind of computation.
As the changes that the GC would require to support this are not trivial, SRef returns a wrong size for now.
Known problems:
- CacheMemoryMonitor does not trim the cache when it reaches its memory size limit.
- IMemoryCacheManager.UpdateCacheSize is called with incorrect size.
Performance counter "Available Physical Memory" return the current
amount of ram that is not in use.
This was added to be used by System.Runtime.Caching .NET integration
that relies on the available system memory to resize the cache.
(add a reference to System.Web.Services)
Without this patch we get the following exception after multiple call
to a soap web services:
Error while compiling generated serializer
/tmp/24ee1170/4996ddb2.cs(2519,27) : warning CS1522: Empty switch block
/tmp/24ee1170/4996ddb2.cs(969,29) : error CS0012: The type `System.Web.Services.Protocols.SoapHeader' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Signed-off-by: Frederic Mestayer <[email protected]>
Signed-off-by: Etienne CHAMPETIER <[email protected]>
We had previously used two separate loops for scanning card tables: One
loop that handled blocks where the object slots were larger than a single card,
and one loop where they were smaller. In the large case we would iterate over
the slots, check whether they were occupied, and if so, check their cards. In the
smaller case we would do it the opposite way: Check the card first, then check
the slots in the card.
For some workloads, the large loop resulted in lots of cache misses, because
we were fetching memory all over the blocks instead of just the cards. The small
loop, on the other hand, would sometimes scan objects twice, namely when they
crossed the boundary between two cards, and both cards were marked.
This new unified loop fixes both problems. We always look at the cards first,
and we keep a scan front pointer that prevents scanning objects more than
once.
For objects that were larger than a card we iterated over the objects in a block, rather
than iterate over the cards. To do that we had to load the object headers, which caused
cache misses. The card bits are consecutive, so they'll be in the cache.
The commit addresses race issues between the waiting on the lock semaphore and the release of the lock. The entry count and the owner field are grouped together into the status field. Accesses to it are done using atomic cas operations so threads aren't lost waiting for release on the lock semaphore.
Disable native fastpaths for now, until they are updated to the new implementation.
Without AOT only code size is checked
With AOT native code is checked.
We cannot compare the native code without AOT because some undeterministic data is stored in the middle of the code and there is no easy way of making the native code dumper ignore it.
Comparing native code is only possible with AOT because it is almost deterministic.
A diff of the smallest method changed by OP_IL_SEQ_POINT is now printed to ease problem identification.
That function is no longer needed since nothing calls it.
This was effective dead code for ages as it would only be used by targets
with no ipv6. So, unless you're using Debian Potato, nothing to see here.
By using a single networking abstraction for name resolution we no longer
need to have two code paths, one for struct hostent and one for struct addrinfo. Good riddance.
More specifically.
We now use functions to fetch protocol numbers and not rely on inline ifdefs.
We use the single abstraction over name resolution, which allows us to have a single code
path to convert the native structure into a managed one.
Finally, we moved the polyfill logic for missing functionality to a separate file to make
things easier.
This meant to replace the ifdef hell that is part of the current socket code and to
modernize the sockets code on some targets.
For some reason we still relied on gethostbyname (and variants) in 2015.
Those functions were deprecated circa the KAME project - yes, I'm that old to remember it.
With that in mind, we now rely on getaddrinfo for all sane targets and drop straight to
the lowest common denominator when it's not available, which is gethostbyname/gethostbyname2.
This patch removes support for the glibc gethostbyname2_r extension. Which is not a practical
problem because all linux/android target we can realistically run on have getaddrinfo.
Sorry grampa, no Slackware 8.0 anymore.
This code has a simpler structure of whole file ifdefs as much as possible, which is
a blessing to OOT ports.
In order to track emitted code with vtune you need to :
* pass --enable-vtune=yes to autogen.sh
* have in the LD_LIBRARY_PATH the path to the profiler libraries (ex $(installation_folder)/lib)
* pass argument --profiler=vtune to mono
Seems that on Jenkins, the request to the (non-existing) IP address used in the test returns before the 1s timeout,
causing the test to fail because the cancellation didn't fire.
Lowering the timeout to 1 millisecond should fix this.
I also verified that the test still correctly fails when the commit that fixed the original issue is reverted.
This fixes the case of the System.ObjectDisposedException being thrown
when editing a text cell in a DataGridView control a second time.
The problem is that the static control would be disposed by the code in
DataGridView's EditingControlInternal, but this instance was reused over
and over.
Instead, we now createa new editing control every time that the TextBoxCell
is created.
The investigation for this bug took place here:
https://bugzilla.xamarin.com/show_bug.cgi?id=9653
Fixes also:
https://bugzilla.xamarin.com/show_bug.cgi?id=22297
Removed the old string-based code and use CodeDom APIs for everything.
Implemented parameter support by adding the necessary properties to the generated class.
Fixed bug where the task references weren't passed to the compiler.
This should now work with VB code as well (assuming the compiler is installed).
Build error #1:
libtool: compile: gcc <...> -c mono-context.c -fPIC -DPIC -o .libs/mono-context.o
mono-context.c: In function 'mono_sigctx_to_monoctx':
mono-context.c:435:68: error: 'MONO_SAVED_GREGS' undeclared (first use in this function)
memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 13), sizeof (mgreg_t) * MONO_SAVED_GREGS);
^
mono-context.c:435:68: note: each undeclared identifier is reported only once for each function it appears in
mono-context.c:436:70: error: 'MONO_SAVED_FREGS' undeclared (first use in this function)
memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 14), sizeof (double) * MONO_SAVED_FREGS);
^
The MONO_SAVED_GREGS and MONO_SAVED_FREGS macros are defined in mini-ppc.h.
The problem happens because commit 7e056cd346
moved code using them from exceptions-ppc.h (which includes mini-ppc.h) to
mono-context.c (which doesn't), where they're not #included.
So, include mini-ppc.h in mono-context.c (in the existing powerpc ifdef block).
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Build error #2:
Now, it turns out mini-ppc.h doesn't know MonoMethod, MonoMethodSignature, and MonoObject.
So, include object.h (MonoObject), which includes metadata.h (MonoMethod and MonoMethodSignature),
in mini-ppc.h.
libtool: compile: gcc <...> -c mono-context.c -fPIC -DPIC -o .libs/mono-context.o
In file included from mono-context.c:427:0:
../../mono/mini/mini-ppc.h:37:2: error: unknown type name 'MonoMethod'
MonoMethod *method;
^
../../mono/mini/mini-ppc.h:306:31: error: unknown type name 'MonoMethodSignature'
mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
^
../../mono/mini/mini-ppc.h:306:64: error: unknown type name 'MonoMethodSignature'
mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
^
../../mono/mini/mini-ppc.h:312:27: error: unknown type name 'MonoObject'
mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, mgreg_t *int_regs, gdouble *fp_regs, gboolean rethrow) MONO_INTERNAL;
^
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Build error #1:
libtool: compile: gcc <...> -c mono-context.c -fPIC -DPIC -o .libs/mono-context.o
mono-context.c: In function 'mono_sigctx_to_monoctx':
mono-context.c:435:68: error: 'MONO_SAVED_GREGS' undeclared (first use in this function)
memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 13), sizeof (mgreg_t) * MONO_SAVED_GREGS);
^
mono-context.c:435:68: note: each undeclared identifier is reported only once for each function it appears in
mono-context.c:436:70: error: 'MONO_SAVED_FREGS' undeclared (first use in this function)
memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 14), sizeof (double) * MONO_SAVED_FREGS);
^
The MONO_SAVED_GREGS and MONO_SAVED_FREGS macros are defined in mini-ppc.h.
The problem happens because commit 7e056cd346
moved code using them from exceptions-ppc.h (which includes mini-ppc.h) to
mono-context.c (which doesn't), where they're not #included.
So, include mini-ppc.h in mono-context.c (in the existing powerpc ifdef block).
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Build error #2:
Now, it turns out mini-ppc.h doesn't know MonoMethod, MonoMethodSignature, and MonoObject.
So, include object.h (MonoObject), which includes metadata.h (MonoMethod and MonoMethodSignature),
in mini-ppc.h.
libtool: compile: gcc <...> -c mono-context.c -fPIC -DPIC -o .libs/mono-context.o
In file included from mono-context.c:427:0:
../../mono/mini/mini-ppc.h:37:2: error: unknown type name 'MonoMethod'
MonoMethod *method;
^
../../mono/mini/mini-ppc.h:306:31: error: unknown type name 'MonoMethodSignature'
mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
^
../../mono/mini/mini-ppc.h:306:64: error: unknown type name 'MonoMethodSignature'
mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
^
../../mono/mini/mini-ppc.h:312:27: error: unknown type name 'MonoObject'
mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, mgreg_t *int_regs, gdouble *fp_regs, gboolean rethrow) MONO_INTERNAL;
^
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Added methods mono_inst_next, mono_inst_prev, mono_bb_first_inst, mono_bb_last_inst
The added methods do respectively the same as ins->next, ins->prev, bb->code, bb->last_ins but skip the instruction until it matches the specified filter.
* Main use case - JSON.NET serialization of CLR objects containing DateTime fields, GetUtcOffset()=>GetApplicableRule() are the highest Mono methods in the profiler
* The property DateTime.Date access in the foreach is very expensive, this has been moved outside the foreach
* Performance for DateTime.Now passed as a parameter is 10x better than before
* This is the simplest possible change to yield an improvement, it would be better to replace the O(N) loop logic with a binary search - this yields a further 2-3x performance improvement, when master is building I may submit later
Whenever a connection to an FTP server is established, FtpWebRequest
sends an option command to the server to enable UTF8 encoding for the
transfer. So far we've failed to check the request status of that
command and assumed that UTF8 is enabled but *also* failed to actually
use the encoding when sending commands (we had the ASCII encoding
hard-coded). This resulted in failed requests whenever a command named a
file or path which included non-ASCII characters. This patch does two
things:
* checks the status of the UTF8 enabling command and uses UTF8 encoding
only if it succeeded. Otherwise Encoding.Default is used.
* uses the encoding detected above for the command stream.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=24611
[Tests will follow at a later date]
So in Linux the PingTimeOut test was returning TtlExpired and failing the assertion. Since I'm not exactly sure how ping behaves under all platforms, relax the test to only make sure it doesn't succeed.
Reverted the async delegate firing which is how Caching et al. expect FSW events; and properly handle the multicast case.
Also fixing a typo/regression in @2f1a136583c90cae805441e63b94bc4f277bb953
As-is, on non-Mac, Xbuild looks for MSBuildExtensionsPath in the folder specified by --prefix, i.e. /usr/local/mono/xbuild by default (which may not & should not exist).
After manager.Build is called, a "null" empty for TargetFrameworkDirectory is
a string containing only ";" - a "good" value is the target framework
directory with a trailing ";". By testing for string.Empty, we don't actually
test whether the value has been correctly populated (causing all subsequent
failures).
Used the following script to do this:
var d = XDocument.Load ("Strings.resx");
foreach (var j in d.XPathSelectElements ("/root/data")){ var v = j.XPathSelectElement ("value"); Console.WriteLine ("\tpublic const string {0}=\"{1}\";", j.Attribute ("name").Value, v.Value); }
This brings .NET's parameterized terminfo renderer, various fixes and
semantic changes.
The existing implementation of the Console did not have a proper an
implementation of terminfo's parameterized sequences. Instead of
this, a collection of hacks existed to hardcode both light colors and
cursor position. These are now gone, since the parameterized strings
do contain the correct values for this.
The search path for terminfo now picks the most modern location for
terminfo. With the old paths in place.
The lookup for terminfo databases only supported the lookup based on
the first character of a terminal, so for example, for xterm this was
$terminfo_dir/x/xterm, but OSX and maybe other systems now store the
files in $terminfo_dir/78/xterm (where 78 is the hex representation of
'x', the first letter of the terminal name).
The fallback is still in place for other Unix systems.
We no longer use the built-in terminfo databases as the first pick,
instead we try to load the system terminfo database before we use the
built-in versions.
Worth figuring out if we want to remove the two built-in ones (Linux
and xterm) as broken terminfo databases are no longer the norm in Unix
and just keep the ansi one as a database of last resort.
This means that the console actually now gets high colors on MacOS,
not just Linux.
This also fixes the issue with consoles with more than 256 colors. As
reported in bug 18315.
- XNodeWrite.FillXmlns was adding a prefix to the attribute when no prefix was found (prefix==null)
- XNodeWrite.LookupPrefix now returns string.Empty prefix when the namespace is the same as the element.
A string.Empty prefix explicitly states that it has no prefix whereas null states that prefix was not defined.
When LookupPrefix returns null for a namespace it means that a prefix should be generated first for anything that uses the namespace.
That is what XmlSerializationWriter.GetQualifiedName does.
Fixes#24300
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=24947
When an Android user changes the timezone, those TimeZone changes
aren't reflected in Xamarin.Android apps. Part of this is a
Xamarin.Android bug, in which it needs to listen for TimeZone change
notifications and in turn let Mono know that the TimeZone changed.
Xamarin.Android can/will call Thread.CurrentCulture.ClearCachedData()
and Thread.CurrentUICulture.ClearCachedData() when the TimeZone has
changed. This will allow Mono to lookup the TimeZone info again.
At which point we hit two problems within Mono:
1. TimeZoneInfo.AndroidTimeZones.Local is unnecessarily cached.
2. DateTime itself caches the UTC offset for use by DateTime.Now.
TimeZoneInfo.Local is *already* cached, and TimeZoneInfo.Local is
properly cleared by TimeZoneInfo.ClearCachedData() while
TimeZoneInfo.AndroidTimeZones.Local wasn't. Removing the extra
cache allows the TimeZoneInfo to be looked up again.
Which brings us to DateTime.Now: for my simple test case, after
calling CultureInfo.ClearCachedData() the result of
DateTime.Now.ToString() didn't reflect the newly current TimeZone. The
cause for this was DateTime.to_local_time_span_object and
DateTime.last_now, which DateTime.Now uses as a cache for the
TimeZone's UTC offset.
Since these DateTime fields weren't cleared, subsequent DateTime.Now
invocations reported the *previous* TimeZone instead of the current
timezone.
To fix this, add an `internal` DateTime.ClearCachedData() method, and
call DateTime.ClearCachedData() from CultureInfo.ClearCachedData().
We can't dereference an object's VTable before we know that it's not
tagged. In this case, forwarded. The access would be unaligned and
might even fault.
We call `mono_thread_pool_cleanup` twice from `mono_runtime_try_shutdown` and later `mono_domain_finalize`, which meant we tried to destroy the semaphore twice and that caused a crasher.
Fix this by clearing out the semaphore pointer. That way when we try to destroy it again it's already null and execution continues just fine.
There's an unlikely case that Roslyn triggers quite often on Linux: A
thread tries to allocate from the nursery, but it's full. It triggers
a nursery collection, then tries allocating again. Between the
collection and the allocation retry, another thread fills the nursery
so that the retry also fails.
We failed an assertion in this case. Now we always go to the major
heap if it happens.
This bug is not hit when doing managed allocations with SGen because the
managed allocator catches it. It can be triggered with the embedding API, as
well as when the heavy binary protocol is enabled, in which case `bug-17590`
fails.
Previous code subtracted 4 pixels of the height of the text of a
toolstrip button, presumably to leave a margin. However, margins
are handled elsewhere, so we ended up with truncated text.
The intention is to make build failures easy to spot instead of silently upgrading
target framework from 2 to 4 and then fail down the road on e.g type ambiguity
caused by new 4.0 framework types or methods
This is the fix for https://bugzilla.xamarin.com/show_bug.cgi?id=25158
Current implementation does not contain the DateTimeOffsetConverter
in the list of default converters. This cause NotSupportedException
to be thrown when trying to serialize/deserialize DateTimeOffset
values to/from strings.
In .NET Framework implementation this class is added to such a list.
This fixes bug #25086 (Xamarin.Android). Details described there.
To fix the issue, we use #if XAMARIN_ANDROID to avoid that old cygwin-only
code path. (We are not sure if simply removing the old code still works,
so we don't remove that for now.)
In the Windows implementation of the TabControl, Ctrl+PageUp
navigates to the previous tab and Ctrl+PageDown navigates to the
next tab (with both wrapping around). This change implements this
feature in the Mono implementation.
Change-Id: Ib940bd08d5ba641f05ed91c0e789e356e68f72bb
ToKey() ignores the setting parameter when calling RegistryKey.OpenSubKey() and
thus always asks for write permission. If you try to read read-only keys (say
HKLM without admin rights) it will fail with a SecurityException.
* Fixed the FileSystemEventArgs.Name property for all events
* Fixed regression of bug #5747 (and related path normalizing issues) https://bugzilla.xamarin.com/show_bug.cgi?id=5747
* Improved error handling, set hard limit on file descriptors to 200 for now to help isolate issues
* Fixed issues with rapid event Changed+Renamed firing
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=24742
Context: Commit f7fd52ad
Context: https://bugzilla.xamarin.com/show_bug.cgi?id=24958
The logic of Commit f7fd52ad was 'Desktop Mono returns "Local" from
TimeZoneInfo.Local.Id, so surely Xamarin.Android should', predicated
in part on the assumption that whatever Desktop Mono does should be
the same as what Desktop .NET does.
This assumption wasn't verified, and is in fact wrong; Desktop .NET
doesn't return "Local" from TimeZoneInfo.Local.Id, it returns an
actual identifier.
The reason why Desktop Mono returns "Local" is due to implementation
sanity, particularly on OS X: /etc/localtime may be a symlink OR a
copy of the timezone data, and when it's a copy there's no way to
determine the Olson ID for the timezone. Consequently, it may not be
possible to determine the TimeZone ID.
Xamarin.Android doesn't have that problem; it uses the Android
persist.sys.timezone system property value,
falling back to java.util.TimeZone.getDefault().getID() if necessary,
and thus always has access to an Olson ID.
Change TimeZoneInfo.Local.Id on Xamarin.Android to return the Olson ID
instead of "Local", partially reverting Commit f7fd52ad.
When we draw a button with ImageAboveText.ImageAboveText and the
text is too big to fit below the image we have to draw the text over
the image. This should happen from the bottom, not from the top as
the previous implementation did. With the previous code we ended up
having the text at the top of the button under certain conditions.
UriParseComponents.ParseUser was unescaping all escaped chars and when a non valid user info char was encountered it was assuming that those chars were not part of the user info. The chars were not consumed thus the problems while parsing the rest of the input.
UriParseComponents.ParseUser now keeps non valid user info chars escaped.
Due to an incompatibility in the project files and DLL API setup code, we were importing locally defined symbols as DLL. This manifested as a debug heap dialog in VS caused by allocating and freeing memory between two Windows modules (which have their own memory heap).
Fix this by simplifying the DLL defines in MSVC, we are relying on .def files to manually specify the exports anyway.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=24741
Xamarin.Android didn't previously support
TimeZoneInfo.FindSystemTimeZoneById("Local") because of oversight (and
overly nested #if conditionals).
Compare `id` against "Local" *before* doing platform-specific
codepaths so that finding the "Local" TimeZone works as expected on
Xamarin.Android, and merge the `#if MONODROID` with the existing code.
7d1b878fbf altered the behavior of removing rows, breaking
the DataGridViewRowCollectionTest.ClearRows () test
Before the change, this is what happened when the list was cleared
(the number in brackets is the value of the Index property of the DataGridViewRow):
[0] Remove [1] ReIndex [0] Remove [1] ReIndex [0]
[1] --------> [2] --------> [1] ------> [2] -------> [1] ...
[2] [3] [2]
[3]
After the offending commit, ReIndex is only called after the list is cleared, which means
the Index property of the rows is never updated (as there are no items in the list).
The fix is to explicitly set the Index of each row to 0.
This was the end result before the commit anyway, so we can omit the ReIndex call entirely.
Before, the first thing the user saw were instructions for niche platforms like Itanium or Solaris.
Instead, we now just link to the "Compiling Mono" guides for OSX, Linux and Windows on the Mono website.
Additionally, a bunch of instructions were outdated / no longer relevant, updated those.
The "Configuration options" section was moved to the bottom of the readme, it was pretty long and pushed
the other sections into oblivion.
We can't actually use the trick of setting both the pinned and forwarded
bits to indicate cemented objects because the Tarjan bridge requires those
two bits never be set at the same time.
The factor we used previously gave us object sizes in increments that made
some benchmarks use quite a lot more memory than necessary. In particular,
we didn't have a size for 24 byte objects (on 64 bits), just for 16 and 32.
The card scanning code assumed that the size of the block header is less
than the size of a card. If we put the block info into the header and increase
the block size enough, that assumption isn't true anymore, because the
mark bits take up space in proportion to the block size.
The idea here is to first extract all the references within an object
and then to process them, pre-fetching the objects they point to a few
steps ahead.
When the runtime shuts down the last thing the GC usually hears about it
is that the root domain is unloaded. If we don't flush the binary protocol
buffers at that point, we lose entries.
We still have two separate implementations of the scanning code: The optimized
one and the old one. The old one is still needed because it supports the concurrent
collector. For the non-concurrent collector we can now use the optimized
implementation, however.
Fasten is a small tool for optimizing compile-time options:
https://github.com/evincarofautumn/fasten
It does that by parsing source files for numbers that have been marked
as "fastenable", and fiddling around with them. We do this for all
the new optimizations.
We actually implement two separate mark/scan loops: One that doesn't
support evacuation and one that does. We dynamically choose which one
to use. The evacuation-less loop is faster, so we use it whenever we can.
The reason for having a small bitmap was that we could encode the object
size in the descriptor. The main attraction for having object size handy is that
we can quickly check whether an object is in the small object major heap or
in the LOS. We solve this problem by always using complex descriptor types
for large objects, so now we can tell whether an object is small just by looking
at the descriptor type.
To identify more small objects quicker.
Since we now use the runl-length descriptor types to indicate object
size as well, and strings can have any size, we can't use that type
for strings anymore, so we use the complex type which forces us to
look up its size to determine whether it's a small or large object.
We can do the cemented check faster by using the third vtable bit to
tag cemented objects (in addition to the pinned bit). In workloads
that are heavy on cementing (like `lcscbench` or `perimeter`) this
significantly increases performance.
Another experiment: What if we put the whole block info into the block
itself, not just a pointer to it. There's one less indirection we
need to do. On the other hand, many of them will share the same cache
lines. So do the pointers to the block infos, though.
When we scan a small object in the major heap we have to read the
block header of its block. It makes sense to prefetch that as well,
in addition to the object itself.
This is another experiment.
When marking on enqueue, what we need to do is look at the object
we're about to enqueue, to check whether it's a small or large object.
Then, when we dequeue to scan, we look at the object again, so we
essentially fetch each live object header twice.
With mark on dequeue, when we encounter a pointer we always enqueue
it, without even looking at the object. Only when we dequeue do we
figure out whether it's marked yet, and thus whether we need to scan
it.
The basic idea here is to make a loop that combines dequeuing from the
gray queue, scanning and marking/copying/enqueuing, with redundancies
removed and special-casing of the common case.
We make the small bitmap type descriptor only apply to small (as
opposed to LOS) objects so that we can quickly check in that case
whether an object is in the LOS or not without actually looking up its
size.
We disable evacuation and the split nursery because the code doesn't
support them yet.
Without heavy statistics it counts almost no objects, and even with
heavy statistics turned on, it doesn't count everything. SGen has an
accurate counter when heavy statistics are turned on.
In case the test runner returns null we will no longer suffer a NullArgumentException and the collector exceptions will be printed.
The test runner was returning null because of an IOException "Too many open files" on NUnit side.
* Add support for colorizing the HTML output. This can be turned off if desired.
* Some changes are now reported inline (using colors/underline/strikeout)
instead of generating an removed/added pair. This makes the diff
a lot easier to read.
As-is, winsetup.bat replaces config.h with winconfig.h, which is needed for the MSVC compilation - but breaks all further use of cygwin's make (e.g. to build the class library, or run "make install").
This patch introduces a new cygconfig.h as a backup prior to squashing config.h (if it exists, so the runtime can still be built without cygwin ever being used), and makes winconfig.h use it on non-MSVC compilers (i.e. cygwin)
This patch brings .NET's implementation of the RegularExpressions
stack and brings some of the supporting infrastructure required to
build without resource files.
The build commands have been updated with two new defines to assist in
bringing .NET code: MONO (to indicate that the code is being compiled
as part of Mono) and a more granular DISABLE_CAS_USE that is used to
mark regions where Code Access Security is being used in the source
code, as Mono does not actually ship with a working CAS implementation.
A tools thread is one that can access core runtime structures but not touch anything managed (code or heap).
It's intended to enable the profiler to resolve missing backtraces from its helper thread.
THIS IS A HACK.
The right solution would be to not perform this on the profiler at all and simply log IPs and let the decoder
resolve them. But then there's reality and we can't simply break the current format without consequences.
We're taking this hack for now until we can fix the profiler to do something sensible.
Unhelpfully, winconfig.h is used for building eglib, and it includes a hardcoded VERSION definition which needs to match configure.ac - otherwise msvc builds identify themselves as 2.11
MonoPosixHelper fails to build in my testing, due to config.h bailing the
build out if it doesn't think the build platform is XP SP2 or higher.
Adding this define forces that minimum Windows version, allowing mono.sln
to build fully.
For the opcodes sizeof, mkrefany and refanyval the jit
was resolving the operand tokens directly from the image.
In dynamic scenarios where the tokens are stored in the
wrapper data, this triggered TypeLoadExceptions.
This patch uses mini_get_class, as used everywhere else,
to resolve the operand tokens of those opcodes.
Consider spans and absolute sizes in computing PreferredSize for
TableLayoutPanel.
Also fix bug in allocating unused width to SizeType.Absolute columns.
Change-Id: Ic5065b83ced8195d1c5be39087f33b0d632fc9a6
A previous change (885b065e) accidentally calculated the text size
in some places without padding. This resulted in a slightly to small
text rectangle, causing the text to be truncated.
This property uses the new CMD_STACK_FRAME_GET_DOMAIN command
to retrieve and cache the domain in which the stack frame
is executing.
Bump the protocol version to match the runtime.
When cross compiling with gcc, LIBC is defined and
thus never checks the registry for the timezone information.
This change is released under the MIT license.
The underlying problem for bug 7716 [1] was that the Mono C14N XML
canonicalizer was not sorting the XML attributes in the same order as
Microsoft .NET's canonicalizer.
The C14N specification [2] states: "the attributes are sorted
lexicographically by attribute name (based on Unicode character code
points)." This wording suggests that the order of attributes should be
strictly ascending based on Unicode byte value. This commit changes the
attribute sort order to match the specification.
The new tests pass on Windows, fail on Mono before this change, and
succeed on Mono after this change.
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=7716
[2] http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html
When the VirtualListSize changes, the focus_item_index should
be reset (similar to how it currently resets the selected indices).
If the last item in a ListView has focus and it is removed by
an another action on the form (i.e. push a button to remove the
current item), then the focused_item_index is not updated when
the VirtualListSize changes, even though that item doesn't exist
anymore. When the ListView receives focus again, it tries to
invalidate the current focused item which causes an
ArgumentOutOfRangeException.
The previous value was -2, that could introduce comparison issues.
Added flag MONO_SEQ_POINT_FLAG_EXIT_IL that is used to encode the exit IL, this avoids a 4 byte IL offset delta.
This fixes ~30 ppc-specific failures in mono/tests (e.g., appdomain), like this:
wrong maximal instruction length of instruction atomic_add_i4 (expected 20, got 28)
* Assertion: should not be reached at mini-ppc.c:5235
The commit 51c454f6b0 introduced 2 ppc_sync
instructions in OP_ATOMIC_CAS_I4/8 *and* OP_ATOMIC_ADD_NEW_I4/8 (mini-ppc64.c).
Accordingly, commit 83a34c40c6 updated the maxlength
(+8 bytes) of atomic_cas_i4/8 - *but not* atomic_add_new_i4/8 (cpu-ppc64.md).
Recently, commit b784b866da made atomic_add_new_i4/8
exercised (as 'atomic_add_i4/8') - with an incorrect/non-updated 20-byte maxlength,
which should actually be 28.
Thus:
wrong maximal instruction length of instruction atomic_add_i4 (expected 20, got 28)
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
The ELFv2 ABI specifies some particular cases for in-register parameter
passing, return values, float/double structs; e.g.,
- small struct returned via registers (2 doublewords)
- homogeneous float struct returned via registers (8 members)
- small float struct passed/returned via FR registers
- return via multiple registers
Author: Bill Seurer <[email protected]>
Origin: https://launchpad.net/ubuntu/+source/mono/3.2.8+dfsg-4ubuntu2
Changes: Mauricio Faria de Oliveira <[email protected]>
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
After the mechanical exchange of ppc_r11 and ppc_r12 we now can use
ppc_r12 for global calls to hold the callees address without clobbering
r11 (which potentially contains IMT_REG, VTABLE_REG and RGCTX_REG).
We don't need to change all indirect calls, only those potentially reaching
functions containing a TOC setup based on r12 (in particular functions
in shared libs). As the instruction sequence patcher can only deal
with one destination register we also need to make some additional
calls use r12. We probably should convert all calls that currently
use r0 to use r12 if no other conflicts arise but this is enough to build.
Author: Michael Matz <[email protected]>
Origin: https://build.opensuse.org/request/show/225490
Changes: Mauricio Faria de Oliveira <[email protected]>
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
This is a preliminary patch for ppc64le ELFv2 support. That one requires
r12 to hold a functions address at calls to normal (global) C functions.
As is r12 is also used by mini for its IMT_REG, VTABLE_REG and RGCTX_REG
to pass around values to functions outside the normal argument registers
(ugh!), so there's a conflict. This mechanical (by sed) patch simply switches
ppc_r11 and ppc_r12 everywhere, r11 doesn't have any special use in the ABI.
Author: Michael Matz <[email protected]>
Origin: https://build.opensuse.org/request/show/225490
Changes: Mauricio Faria de Oliveira <[email protected]>
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
This adds initial support for ppc64le to the ppc64 port. That is:
* little endian aware (also in strtod),
* and ELFv2 aware (not using function descriptors)
* adjust various block sizes to be multiple of 64k, the default
pagesize on ppc64le. The sources should have used the system function
to ensure alignment on pagesize, so this is just a stop-gap
It also corrects the list of registers for the precise GC, but that isn't
used in mini at all on any architecture currently.
Author: Michael Matz <[email protected]>
Origin: https://build.opensuse.org/request/show/225490
Changes: Mauricio Faria de Oliveira <[email protected]>
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
MonoSeqPointInfo has now a pointer to a buffer containing encoded sequence points, and to a buffer containing next values.
As there is no longer an array of SeqPoint ready to be read, SeqPointIterator was added.
This line enable the ASP Javascript validators in IE9 and upper. the user agent the IE10 is "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)".
We don't update mark bits atomically, so we can't have two threads
marking at the same time, which means we have to stop the concurrent
collector worker thread while we do work in the main GC thread. That
includes nursery collections, because they also touch mark bits.
Also problematic are mod-union updates. The worker threads can add
global remsets, which they do in the main cardtable. This will conflict
with updating the mod-union table, so having the workers stopped also
applies there.
Before we do all the major heap work in the finish mark pause of a
concurrent collection, we perform a nursery collection, for simplicity's
sake.
The nursery collection left pinned objects in the nursery, without
following their references into the major heap, so the major heap work
had to scan those objects again. There was no special provisioning
for this—major mark would do the pinning again, and we would
automatically end up scanning the objects again.
The way we determine the stack end for the GC thread, however,
had the effect of making pinning non-deterministic. We would
conservatively scan part of the GC thread's stack, which was
subject to change, to pinning again might result in less or more
objects pinned.
The proper solution would be to determine the stack end correctly,
but for now we will just the whole nursery.
As mentioned in commit 789517f8, I'm trying to compare inter-API level
differences in Mono.Android.dll, and want to reduce as much
"meaningless noise" as possible -- changes which don't meaningfully
break API or ABI.
Among those "meaningless" changes are the addition of property setters
to properties. Adding a setter doesn't break API or ABI.
Add a `mono-api-html --ignore-changes-property-setters` option.
--ignore-changes-property-setters:
Ignore the addition of property setters.
If a source property contains a getter and the target property
contains both a getter and a setter, do not flag this as a
change.
As mentioned in commit 789517f8, the intentino of
`mono-api-html --ignore-changes-virtual` is so that when a method is
changed from non-virtual to virtual or override, or from virtual to
override, a "Removed member" message isn't triggered.
However, the previous implementation was too lenient. While *adding*
virtual to the method is fine, *removing* is NOT fine, as that would
be an API breaking change (e.g. all classes which attempt to override
a previously virtual method could no longer do so).
Make the virtual check stricter so that virtual/override to
non-virtual changes are not ignored.
I've been trying to review API diffs in Xamarin.Android between API
levels, but the diffs are "noisy" because Google will change parameter
names at-will, or will change a non-virtual method into a virtual
method, or a virtual method into an override, all of which are
acceptable changes but individually generate a Removed line in
mono-api-html output, and manually removing the *hundreds* of changes
is error-prone.
Add two new option flags to mono-api-html:
--ignore-changes-parameter-names:
Ignore changes in constructor and method parameter names.
If parameter names change between <reference.xml> and
<assembly.xml>, don't report a change for the constructor or
method.
--ignore-changes-virtual:
Ignore changes in "virtual-ness".
If a method or property changes from non-virtual to virtual,
non-virtual to override, or virtual to override, don't report a
change for the member.
We change the function to use the lock/validate pattern. This is both
more scalable and enables us to use the image lock, since the amount of
work done with it held is now trivial.
The function mono_method_inflated_lookup no longer needs the loader lock to be held
as the hashtable is now protected by the imageset lock.
This means that mono_class_inflate_generic_method_full_checked doesn't need to take the
loader lock.
The function mono_method_set_generic_container uses mono_image_property_insert which takes
the image lock and not the loader lock. Adjust the locking comment.
This is used for counters that are defined after runtime initialization. It implies that TYPE_SAMPLE_COUNTERS_DESC can now be emitted at any time, and not only once.
The same counter instance would be returned if we use the "instance" parameter instead of the "counter"
parameter. Also it is the name of the counter that is stored in mono_perfcounter_create (mono-perfcounters.c:1488).
Fix the following bug : shared_data_find_room return twice the same memory region because it was not marked as "in use" by setting the header.ftype value.
This bug is triggered when we want to create a new shared area (for example a new FTYPE_INSTANCE area) while creating another area (for example a new FTYPE_CATEGORY).
The structure of the encoded SharedCounter is as follow :
- compressed data type : 1 byte
- index in the category : 1 byte
- name of the counter : null terminated string
- help of the counter : null terminated string
DataGridView keeps track of the first visible row in first_row_index.
DataGridViewRowCollection will notify DataGridView its about to delete 1 or
more rows via OnRowsPreRemovedInternal(). When this happens, we need to
ensure first_row_index will still fall within the number of rows that
will remain after the row removal.
This fixes https://bugzilla.xamarin.com/show_bug.cgi?id=24372 which I
reported.
This is a jumbo commit that addresses multiple issues with statistical backtrace collection:
1) It's not possible to reliably collect MonoMethod* so we check that they exist before
serializing to the .mlpd file and retrieve in sync context.
2) It was reporting the generic instance MonoMethod* under gsharing. Those methods are
not reported to the profiler since they are never compiled. They would turn out as unknowns.
3) Collecting IL offsets from async context is currently impossible to be done safely, so it's
now disabled. The way we'll do it in the future is by serializing the sequence point table when
JIT'ing.
4) The way we used to collect frames in statistical ignored all frames until the first LMF, which
discards a lot of them under statistical mode. We now properly pass sigcontext and have it been consumed.
In the future we should simply use the callchain mode.
When issuing a Clear() to remove all rows, a ReIndex() was being called for
each row that was being removed. This is extremely inefficient, instead
do a single ReIndex() after all rows have been removed.
Before doing a Clear() of 30k rows was taking 5.8 seconds. With this patch
it now takes 670ms.
This is useful in the case of the benchmarking suite because we are only interested in the counters, and they represent a minimal part of the output file size.
+ Fix NRE when source_file or source_file.Usings is null. This will now return back an empty string or empty List
+ **Note** that we are returning the ToString() value of NamespaceExpression which is the full resolved namespace of "System.Drawing" instead of "Drawing".
+ Add ToString override for NamespaceExpression to return the full resolved name of the namespace.
Before this change, those Last*Time properties returned only based on
seconds (truncated), which could cause inaccurate time comparison.
Consider code like this:
var fileUpdated = DateTime.Now;
...
File.WriteAllText (path, "foobar");
...
if (fileUpdated > new UnixFileInfo (path).LastWriteTime)
OnUpdatedFile (path);
This could always result in raising update event, even if there was
no update after writing.
Last*Time With milliseconds makes it very unlikely to happen.
The XML work in 661430fd1f and bf39f5aec0 changed the whitespace handling, so the mdoc test suite failed.
Refreshing the files makes them identical to what MS.NET produces and fixes the mdoc tests.
If we run out of memory during the nursery collection in the finishing collection pause,
there will be late-pinned objects in the nursery: pinned objects that were not pinned
from conservative roots (or cementing). We need to scan those, too, so in that case
we just walk the nursery and scan all objects.
The two collectors stepped on each other's toes. Specifically, updating the mod union
card table while the worker thread might mark cards in the card table will not work.
The simplest solution for now is to stop the worker thread during concurrent updates
and nursery collections. In the future we can have the thread help with the nursery
collection.
Cementing can happen during a concurrent collection when processing
the cardtable. We use a separate cementing hash during concurrent
collections but we didn't pin objects from there.
Reset of adjustment rules is mandatory when the base offset is changed because the rules are relative to the base offset.
Adjustment rules are now kept until the base offset changes.
- merge fix for https://bugzilla.xamarin.com/show_bug.cgi?id=21578
the MulticastOption's 'private IPAddress local' field was
removed by linker and the app crashed later at runtime.
- when System.Net.Sockets.MulticastOption object
is passed to System.Net.Sockets.Socket.SetSocketOption
and thru it to System.Net.Sockets.Socket.SetSocketOption_internal
it accesses passed object fields
(thru few more native calls).
The current signal profiling code depended on invalid linux behavior of setitimer
allowing multiple threads to register for the same timer. Linux kernel 2.6.12 fixed
this and only the main thread gets the signal. Always.
The correct POSIX behavior happens on OSX/iOS.
On Linux we could use timer_create and SIGEV_THREAD_ID but that would not work on iOS/OSX
since it's specific to it. Given that little detail, I'll leave implementing it as an
exercise to the reader.
The solution, which aims to be as portable as possible, is to use a pair of signals and
have the first one fire the second one against all other threads.
We use a pair of signals since it's not well defined which thread will receive the signal
so detecting this from the signal is non-trivial.
Parameter names are part of the ABI because of C#4 named parameter.
Consequently, they *must* be consistent with .NET, and .NET a
parameter name of "errorInfo", *not* "errorInfoPtr" [0]:
public static Exception GetExceptionForHR(
int errorCode,
IntPtr errorInfo
)
Change the parameter name from `errorCodeInfo` to `errorCode` so that
the parameter name is consistent with .NET.
[0]: http://msdn.microsoft.com/en-us/library/3xade62s(v=vs.100).aspx
Extend functionality of SgenPointerQueue.
The purpose of this commit is to avoid dependency between GC code and the obtaining of the hash from the object's synchronisation field, which might require additional processing.
for reading the input stream.
According to the MSDN docs, if ReadEntityBodyMode returns "Classic" the code should use
the old method to read the input stream (HttpRequestBase.InputStream) which is fully
implemented in mono.
Manually applied patch from martinjt
Add Makefile rules to automagically download the TimeZone database
from the Android target $(ADB_TARGET), and build the tzi.exe app.
$ make android-dump-tzdata ADB_TARGET=-d
# downloads timezone data into ./android/tzdb.
# dumps timezone data into ./android/tzdata
# builds ./tzi.exe
# Show adjustment rules for a given timezone dump
$ mono tzi.exe -i=tzdata/Asia/Amman
Add `tzi.exe -R` option to show the TimeZoneInfo.GetAdjustmentRules()
output for all encountered timezones.
Add `tzi.exe -o=PATH` option to dump the TimeZone data to disk for
interrogation.
Add `tzi.exe -i=PATH` option to read in the specified TimeZone data
file and dump the rules contained therein.
Update usage comments.
Makefile defines GC_WIN32_THREADS as 1 but gc_config_macros was
redefining as defined but with no value.
Signed-off-by: Alex J Lennon <[email protected]>
FileSystemWatcher.cs: Fixed multicast events.
SearchPattern.cs : Fixed issue where case insensitivity was not being honored.
KeventWatcher.cs:
* Fixed several race conditions
* Fixed file descriptor duplication & leaks
* thread-safe/cleaner state transitions for watcher, and much cleaner stopping
* Now uses fsw.Filter parameter and respects IncludeSubdirectories = false. Use fsw.Filter to watch very large trees
* Added more error handling + OnError event
* Lots of behavior/reliability fixes and optimizations for Monitor() loop
* Fixed kevent/timespec struct definitions (for 64-bit build)
Reworked a lot of the internals of the kqueue FileSystemWatcher. There
is now a separate thread and a separate kqueue for each FileSystemWatcher
object.
https://bugzilla.xamarin.com/show_bug.cgi?id=16259
Adds a configuration file to facilitate build of Mono with Cygwin
on Appveyor Windows-based build workers.
Dependencies are installed on a clean Appveyor build image for
each build and the result of the 'make install' step is stored
as a build output 'artifact' for further testing or deployment.
Signed-off-by: Alex J Lennon <[email protected]>
Error generated by socket-io.c was:
/usr/i686-pc-mingw32/sys-root/mingw/include/ws2tcpip.h:38:2:
error: #error "ws2tcpip.h is not compatible with winsock.h.
Include winsock2.h instead."
Signed-off-by: Alex J Lennon <[email protected]>
- Ref: https://bugzilla.xamarin.com/show_bug.cgi?id=20048
- Mono currently doesn't support 2-args Socket ctor added in .NET 4.5
- Absence of this ctor prevents KestrelHttpServer (web server for
ASP.NET vNext: https://github.com/aspnet/KestrelHttpServer ) test
code from working
- I hesitated to put IPv4 only implementation, but full dual stack
(IPv4/v6) support would need bunch of works to be done. So, I pinned
supported protocol of new ctor to IPv4. Also, I filed v4/v6 support
issue as a MonoTODO entry inside the source code.
- Don't subtract room for ellipsis. Ellipsis should be
handled by the renderer so we shouldn't reserve space for it.
Otherwise we end up not getting ellipsis (because the renderer
thinks there is enough space available), or we don't use up the
available space.
- Don't allow text to go below button if we want to show ellipsis.
When a button is pressed the image and the text needs to be rendered one
pixel to the right and to the bottom so that there is some visual
feedback of the button press. Previously this was only the case if
TextImageRelation was set to Overlay.
On Mono/.NET, TimeZoneInfo.Local has a TimeZoneInfo.Id value of
"Local" and a TimeZoneInfo.DisplayName value of "Local":
$ csharp
csharp> TimeZoneInfo.Local.Id;
"Local"
csharp> TimeZoneInfo.Local.DisplayName;
"Local"
That isn't the case on Xamarin.Android, which returns the timezoneinfo
ID value from both DisplayName and Id, e.g. TimeZoneInfo.Local could
have Id and DisplayName values of "Australia/Sydney".
Rework things so that the TimeZoneInfo.Id and TimeZoneInfo.DisplayName
properties return "Local" on Xamarin.Android for the instance returned
from TimeZoneInfo.Local, just like normal Mono/.NET does.
NUnit breaks when these URI's are treated as UNC paths, so I have no way of
running the tests on Windows without this change to see if it broke anything.
Not all URI tests pass, but the ones that fail seem unrelated to my change.
On Unix, the tests all work, but of course on Unix this is a no-op.
This commit licensed as MIT/X11.
The issue was with the new heuristic of the thread pool which would not create new threads, leading to deadlock between dependent tasks.
The fix is to check if every worker threads are sleeping, waiting or joining, and if that's the case, then we create a new thread because we might be in the case where the tasks being currently run depends on one still being enqueued in the cq or one of the wsq.
The following tests would previously fail :
1) MonoTests.System.Threading.Tasks.TaskTests.DoubleWaitTest : #1
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.<DoubleWaitTest>m__27 () [0x00077] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:800
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.TaskTests.DoubleWaitTest () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:790
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
2) MonoTests.System.Threading.Tasks.TaskTests.HideSchedulerTest : #1
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.HideSchedulerTest () [0x0003d] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:1914
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
3) MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsAfter : #1
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsAfter () [0x00070] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:317
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
4) MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsBefore : #1
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsBefore () [0x00070] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:341
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
5) MonoTests.System.Threading.Tasks.TaskTests.WaitAnyTest : #3
Expected: not -1
But was: -1
at MonoTests.System.Threading.Tasks.TaskTests.<WaitAnyTest>m__0 () [0x00026] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:142
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action) [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:42
at MonoTests.System.Threading.Tasks.TaskTests.WaitAnyTest () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:128
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
6) MonoTests.System.Threading.Tasks.TaskTests.WaitChildTestCase : #0b
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.<WaitChildTestCase>m__25 () [0x0006d] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:705
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.TaskTests.WaitChildTestCase () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:684
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
7) MonoTests.System.Threading.Tasks.TaskTests.WaitingForChildrenToComplete : #3
Expected: True
But was: False
at MonoTests.System.Threading.Tasks.TaskTests.WaitingForChildrenToComplete () [0x00048] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:734
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) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
The internal allocator used size segregated blocks which were always
16k large. Since we have quite a few different size classes this led
to a lot of allocation even for very small programs.
We now use block sizes that are determined by the slot size and are as
small as possible. They're power-of-two multiples of the page size,
so we end up with blocks of 4k, 8k and 16k.
The formula for calculating allowance was not only overly complicated
but completely broken, which resulted in the allowance always being the
minimum (4 times the nursery size). That resulted in too frequent garbage
collections when the heap grew larger.
Now we do something very similar to what Boehm does: Allow the heap
to grow by a third before the next major collection happens.
This is especially relevant if we have to shrink the width because of
padding. In this case it is possible that MeasureString calculated that
the string would fit in one line, but because of padding we reduce the
width. If the button is large enough we want to display additional lines
even if MeasureString told us we only need one line.
pid_t (used at line 216) is available on Linux in `unistd.h` and so on on FreeBSD (`sys/types.h` to be precise, included in `unistd.h`), yet on FreeBSD this header is not automatically included.
Unless running in on-demand AOT mode, the AOT runtime will look for an AOT cache alongside the assembly (e.g. /usr/lib/mono/4.5/mscorlib.dll.so).
This patch adds a second search path to the non-on-demand AOT loader, /usr/lib/mono/aot-cache/ARCHITECTURE/path/to/assembly.dll.so
This new structure makes it possible to have more than one Mono architecture on a system, sharing assemblies but not sharing AOT caches (for example, i386 and amd64 Mono on the same system, for different needs)
Because the monitor thread was not marked as background thread, remove_and_abort_threads (threads.c:2807) would mark it as needed to be waited to shutdown the runtime, and wait_for_tids (threads.c:2652) would then wait indefinitely for it to finish. The issue was that the monitor was waiting on the semaphore monitor_sem, and thus would never exit.
Thread 7 (Thread 0x1c13 of process 99776):
#0 0x00007fff86590a56 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1 0x00000001003cc03a in mono_sem_wait (sem=0x1004f7f50, alertable=0) at mono-semaphore.c:103
#2 0x00000001002cef41 in monitor_thread (unused=0x0) at threadpool.c:898
#3 0x00000001002cb78f in start_wrapper_internal (data=0x10500abf0) at threads.c:657
#4 0x00000001002cb4a1 in start_wrapper (data=0x10500abf0) at threads.c:704
#5 0x00000001003d61d4 in inner_start_thread (arg=0x7fff5fbfe500) at mono-threads-posix.c:84
#6 0x00007fff8e7c9899 in _pthread_body () from /usr/lib/system/libsystem_pthread.dylib
#7 0x00007fff8e7c972a in _pthread_start () from /usr/lib/system/libsystem_pthread.dylib
#8 0x00007fff8e7cdfc9 in thread_start () from /usr/lib/system/libsystem_pthread.dylib
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 0x1503 of process 99776):
#0 0x00007fff86594716 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1 0x00007fff8e7cbc3b in _pthread_cond_wait () from /usr/lib/system/libsystem_pthread.dylib
#2 0x000000010039cfaa in _wapi_handle_timedwait_signal_handle (handle=0xa55, timeout=0x0, alertable=1, poll=0) at handles.c:1595
#3 0x000000010039d03d in _wapi_handle_wait_signal_handle (handle=0xa55, alertable=1) at handles.c:1540
#4 0x00000001003b7ba3 in WaitForSingleObjectEx (handle=0xa55, timeout=4294967295, alertable=1) at wait.c:194
#5 0x00000001003b865d in WaitForMultipleObjectsEx (numobjects=1, handles=0x7fff5fbff1f8, waitall=1, timeout=4294967295, alertable=1) at wait.c:516
#6 0x00000001002c75df in wait_for_tids (wait=0x7fff5fbff1f8, timeout=4294967295) at threads.c:2658
#7 0x00000001002c70e5 in mono_thread_manage () at threads.c:2951
#8 0x00000001000d551b in mono_main (argc=6, argv=0x7fff5fbff9e8) at driver.c:2021
#9 0x0000000100001bd1 in mono_main_with_options (argc=6, argv=0x7fff5fbff9e8) at ./main.c:91
#10 0x00000001000017d3 in main (argc=6, argv=0x7fff5fbff9e8) at ./main.c:122
Thanks @akoeplinger for the help debugging
Because the monitor thread was not marked as background thread, remove_and_abort_threads (threads.c:2807) would mark it as needed to be waited to shutdown the runtime, and wait_for_tids (threads.c:2652) would then wait indefinitely for it to finish. The issue was that the monitor was waiting on the semaphore monitor_sem, and thus would never exit.
Thread 7 (Thread 0x1c13 of process 99776):
#0 0x00007fff86590a56 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1 0x00000001003cc03a in mono_sem_wait (sem=0x1004f7f50, alertable=0) at mono-semaphore.c:103
#2 0x00000001002cef41 in monitor_thread (unused=0x0) at threadpool.c:898
#3 0x00000001002cb78f in start_wrapper_internal (data=0x10500abf0) at threads.c:657
#4 0x00000001002cb4a1 in start_wrapper (data=0x10500abf0) at threads.c:704
#5 0x00000001003d61d4 in inner_start_thread (arg=0x7fff5fbfe500) at mono-threads-posix.c:84
#6 0x00007fff8e7c9899 in _pthread_body () from /usr/lib/system/libsystem_pthread.dylib
#7 0x00007fff8e7c972a in _pthread_start () from /usr/lib/system/libsystem_pthread.dylib
#8 0x00007fff8e7cdfc9 in thread_start () from /usr/lib/system/libsystem_pthread.dylib
#9 0x0000000000000000 in ?? ()
Thread 1 (Thread 0x1503 of process 99776):
#0 0x00007fff86594716 in ?? () from /usr/lib/system/libsystem_kernel.dylib
#1 0x00007fff8e7cbc3b in _pthread_cond_wait () from /usr/lib/system/libsystem_pthread.dylib
#2 0x000000010039cfaa in _wapi_handle_timedwait_signal_handle (handle=0xa55, timeout=0x0, alertable=1, poll=0) at handles.c:1595
#3 0x000000010039d03d in _wapi_handle_wait_signal_handle (handle=0xa55, alertable=1) at handles.c:1540
#4 0x00000001003b7ba3 in WaitForSingleObjectEx (handle=0xa55, timeout=4294967295, alertable=1) at wait.c:194
#5 0x00000001003b865d in WaitForMultipleObjectsEx (numobjects=1, handles=0x7fff5fbff1f8, waitall=1, timeout=4294967295, alertable=1) at wait.c:516
#6 0x00000001002c75df in wait_for_tids (wait=0x7fff5fbff1f8, timeout=4294967295) at threads.c:2658
#7 0x00000001002c70e5 in mono_thread_manage () at threads.c:2951
#8 0x00000001000d551b in mono_main (argc=6, argv=0x7fff5fbff9e8) at driver.c:2021
#9 0x0000000100001bd1 in mono_main_with_options (argc=6, argv=0x7fff5fbff9e8) at ./main.c:91
#10 0x00000001000017d3 in main (argc=6, argv=0x7fff5fbff9e8) at ./main.c:122
Commit 5564dad1 broke the self-test (for testing on the developer
machine, not an Android target). Fixup the comment so that appropriate
data is grabbed and used for testing, and improve
AndroidTimeZones.GetDefaultTimeZoneName() so that the default timezone
ID can be specified via the __XA_OVERRIDE_TIMEZONE_ID__ environment
variable for testing.
Finally, demonstrate TimeZoneInfo.GetUtcOffset(DateTime) use so that I
can get better insight into the timezone data stored within the
database:
$ __XA_OVERRIDE_TIMEZONE_ID__=America/New_York ANDROID_ROOT=`pwd` ANDROID_DATA=`pwd` mono --debug tzi.exe --offset=1969-01-01
Using DateTime Offset: 1/1/1969 12:00:00 AM
DB type: System.AndroidTzData
name=Africa/Abidjan Africa/Abidjan From Offset: 00:00:00
name=Africa/Accra Africa/Accra From Offset: 00:00:00
name=Africa/Addis_Ababa Africa/Addis_Ababa From Offset: 03:00:00
...
This fixes a problem with calculating the text width of a button
which caused the text to get truncated under certain circumstances
instead of being wrapped. This fixes Xamarin-23168.
Change-Id: Iac0d8a2720a99cf5433e05d5123a04c4b019e493
The test changes TZ environment variable and compares DateTime.Now with system date.
The test checks all the timezones installed in /usr/share/zoneinfo/.
The change does not have a negative impact on StringBuilder performance; under variable-string-length microbenchmarks it seems to perform ~15-20% faster than the managed implementation.
Use the new MONO_GC_DEBUG option "nursery-canaries" to suffix each nursery object with a canary (guard) word, which is checked on each minor collection. Can be used to detect/debug
heap corruption issues.
Adding canaries to LOS is also easy if wanted - not sure about major heap.
In some cases the timezone transitions provided by iOS are not convertible to AdjustmentRules because of changes on the base offset.
Now we store the transitions so they can be used instead of an incomplete list of AdjustmentRules.
Depending on alignment and packing, part of the string might be inside the MonoString struct boundaries. This e.g. shows up on 64-bit builds of mono where we were allocating 4 extra bytes per string.
We were spending a lot of time in major_iterate_live_block_ranges() on
the lcscbench benchmark, mainly from following the linked block list.
This change makes it much faster.
We trim the free list of the gray queue to a maximum number of
sections, but we did it at each collection start, so the extraneous
sections were kept around between collections.
At the point where we enqueue objects we have already fetched their
descriptors, and when we later scan them (after dequeuing) we need the
descriptor again, so we avoid cache misses by enqueuing them together.
Later on, when we enqueue objects with their GC descriptors, we won't
load the vtable before scanning (because we'll already have the
descriptor), so the scanning macros shouldn't take them as arguments.
It's not well-tested, not widely used, we can surpass its speed with
upcoming improvements and we won't put those into the fixed
configuration because it's too much of a diversion.
Before the change when the property default value was not null or empty the deserialized value would be the concatenation of the default value and the serialized value.
The correct behavior is to use the serialized value only.
Fixes 18908.
To resolve casting we make all relevant interfaces to use the generic variance casting code.
This only affected ICollection`1 and IList`1, which are not terribly popular.
To fix dispatch we augment vtable resolution to treat those interfaces as variant and use
the already in place machinery.
Memory reduction numbers for the corlib test suite:
Initialized classes 8004 -> 7470 (7% reduction)
Corlib mempool size: 2719832 -> 2678872 (1.5% reduction)
Inflated classes 4500: 3.972 (12% reduction)
Inflated signatures size: 166128 -> 139812 (16% reduction)
Inflated methods size: 565152 -> 485664 (15$ reduction)
https://bugzilla.xamarin.com/show_bug.cgi?id=18411
If a class explicitly implements an internal interface, those members will no
longer be documented, nor will the interface show up in the class' signature.
This allows for a library to hide internal implementation details that an end
user would not be able to take advantage of (ie. can't cast to internal
interface to call methods).
Includes test (check-monodocer-internal-interface) added to makefile.
This should fix c30a3e46d2 failing to link properly with ld 2.22 and GCC 4.9.1, on Linux, with non-LLVM builds.
./.libs/libmini.a(libmini_la-mini.o): In function `llvm_init_inner':
mini.c:(.text+0x1182b): undefined reference to `mono_llvm_init'
/usr/bin/ld: .libs/libmonoboehm-2.0.so.1.0.0: hidden symbol `mono_llvm_init' isn't defined
/usr/bin/ld: final link failed: Bad value
- Tds.cs: Use SecureString objects for passwords; Add method to retrieve string from SecureString
- Tds42.cs: Use SecureString for passwords
- Tds50.cs: Use SecureString for passwords
- Tds70.cs: Use SecureString for passwords
- TdsConnectionParameters.cs: Use SecureString for passwords; Initialize Password parameter as cleared string; Add indicator for when password is set
- SqlConnection.cs: Use SecureString for passwords; Add SqlConnect method that accepts an SqlCredential along with the Connection string; Perform checking of parameters to ensure user/password not specified in connection string if credentials have been specified or using credentials when domain login is specified.
- SqlCredential.cs: Add new class with support for credentials
- System.Data.dll.sources: Add SqlCredential.cs to the build list
[02131] CC libmonoruntimesgen_la-sgen-marksweep.lo
[02131] In file included from sgen-major-copy-object.h:35:0,
[02131] from sgen-marksweep.c:1128:
[02131] sgen-copy-object.h:38:1: warning: always_inline function might not be inlinable [-Wattributes]
[02131] par_copy_object_no_checks (char *destination, MonoVTable *vt, void *obj, mword objsize, SgenGrayQueue *queue)
[02131] ^
[02131] sgen-marksweep.c: In function 'par_copy_object_no_checks':
[02131] sgen-copy-object.h:38:1: error: function 'par_copy_object_no_checks' can never be copied because it saves address of local label in a static variable
[02131] make[3]: *** [libmonoruntimesgen_la-sgen-marksweep.lo] Error 1
[02131] make[3]: Leaving directory `/root/rpmbuild/BUILD/mono-3.10.1/mono/metadata'
[02131] make[2]: *** [all-recursive] Error 1
[02131] make[2]: Leaving directory `/root/rpmbuild/BUILD/mono-3.10.1/mono'
[02131] make[1]: *** [all-recursive] Error 1
[02131] make[1]: Leaving directory `/root/rpmbuild/BUILD/mono-3.10.1'
[02131] make: *** [all] Error 2
[02131] error: Bad exit status from /var/tmp/rpm-tmp.YxcUOE (%build)
Kpp.Load() will throw an unhandled exception if _filename (a folder to use as the key store) does not exist and it cannot be created.
This is an entirely valid thing to have happen - cert importing into the machine store (mozroots --import --machine --sync) as root will create a /usr/share/.mono/certs/ folder, but will not create /usr/share/.mono/keypairs - and since the root user owns /usr/share/.mono/, if the user tries to enumerate the certificates in /usr/share/.mono/certs/, they get 0 certificates returned due to the unhandled exception dropping each loaded certificate on the floor.
Closes: Xamarin bug 23015
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=23077
Reverts commit 53ce92470.
Commit 53ce92470 disabled use of statfs(2) on Android, for unspecified
reasons. (My *suspicion* is that the Android version mono was
originally ported to didn't have statfs(2), but I can neither confirm
nor deny that guess.)
Android has supported statfs(2) since API-4 Android v1.6 (in that
statfs(2) is in the header files); what's missing is MNT_RDONLY. What
IS present is MS_RDONLY, which appears to serve the same purpose.
Re-enable use of statfs(2) and use MS_RDONLY when building against the
Android NDK.
This fixes the command to check for dos2unix and makes mkbundle usable again with mingw.
We need first to redirect the standard input, otherwise the check always fails with an InvalidOperationException and set CreateNoWindow=false to avoid spawning a new window.
The problem already starts when creating the OperationDescription; we need
to also look at the End* method here to correctly parse the reply parameters.
Then ClientRuntimeChannel.Process needs to distinguish between sync/async
and copy the out/byref parameters when needed.
SerializationCodeGenerator and XmlSerializationWriterInterpreter will no longer serialize an attribute named {V} if its object has a method named ShouldSerialize{V}() that returns false.
{V}Specified now is also checked to be true before serializating the attribute even if it is a property that is not settable.
Fixes#1852.
{V}Specified is a property or field and ShouldSerialize{V} is a method that can be set to false if we do not want to serialize an attribute with name {V}.
On *nix files are not executable by default where on Windows they
are. This causes problems if installing a NuGet package on *nix that
contains .exe files intended to be used by build tasks. On Windows the
build will invoke these without complaining whereas on *nix the build
will fail with "Native error: cannot find file specified".
On mono, the action that will be taken is to pass the path to the .exe
file to mono as a command-line argument. If this was done in a shell it
would succeed whether or not the .exe file has the executable bit set,
so it seems that this should also succeed within a program.
With thanks to @akoeplinger for help designing the test.
I release this under the MIT license.
Based on pull request feedback, this is a simpler usage, and meets our required use-case. A sample version of this parameter would be: `--dropns MyUnifiedAssembly=MyDroppedPrefix`
We take the loader and the root domain locks before doing a thread dump. This reduces the odds
of us suspending a thread that holds either of them and deadlocking, for example, while decoding
AOT JIs.
Users have been complaining about strange errors arising when using the OracleClient classes.
I have tracked it down to the OciDefineHandle and OciDefineByPos calls, and OracleParameter
handling of amanged objects by unmanaged code. Currently two of the parameters passed to the
above OCI call are short variables. They are passed as "ref" fields as Oracle uses their
address to put size and indicator data once the data is fetched. However, being defined as
short means that they are eligible for being moved during garbage collection. Thus if that
field is moved between the OciDefineByPos call and the fetch of the data then what Oracle is
pointing to may no longer be variable. I'm thinking it may be better to define these fields as
IntPtr and allocate them and retrieve their values via Marshal.ReadInt16. As for OracleParameter,
it uses a managed object "indicator" that is also used in a similar way. This reference is replaced
by a IntPtr and a get/set method to access the contents.
iOS 8 GM lists "Asia/Chita" among its time zones, but when requesting
the time zone data for that time zone, no data is returned.
With this change we ignore time zones without any data when fetching
all the timezones on the system.
In some cases fixed_from_dmy is used with the month parameter greater than the number of months of that year.
Year is now incremented until month parameter is valid.
The changes from 3408b8e5f1 cause
regressions in distros which do not use lib as folder for
arch-specific libraries, like Fedora x86_64.
Instead, reloc_libdir should be used (as in data/mono.pc.in).
This change is released under the MIT/X11 license.
We observed on multiples benchmarks that most internal allocations are for 8, 16, 296 (32bits), 328 (64bits), 504 (32bits) and 1016 (64bits) bytes of memory. To minimize waste, we added these memory sizes to the default allocator sizes.
On Microsoft's implementation of the Uri class, the contructors and TryCreate method both lower-case the host. This commit fixes the issue where the constructors lower-cased the host but the TryCreate method did not.
Currently JsonObject uses a Dictionary and JsonValue does not sort the keys
in SaveInternal(). As iterating over a Dictionary returns the values in
random order, this causes the JSON string to be non-deterministic.
Switching to SortedDictionary makes sure that the same object always will
produce the same JSON string.
The keys are sorted using StringComparer.Ordinal to produce the same order
in all locales.
Marshal.GetHRForException had a MonoTODO because it needs to set
the errorinfo object so that exceptions get properly passed to
unmanaged code. Since not all managed exceptions have a corresponding
HR value but we might need to get to the original thrown exception
we implement a ManagedErrorInfo helper class that implements the
IErrorInfo interface but also stores the exception.
In GetExceptionForHR we check if the errorinfo we get is a
ManagedErrorInfo. If it is we return the exception stored in there
(if it converts to the same error code), otherwise we construct a new
exception.
Also use additional information provided by IErrorInfo to fill in
exception details.
To make use of IErrorInfo on Linux a suitable implementation has to be
provided, e.g. by including libcom plus adding a mapping from
oleauth32.dll to the shared library that provides the implementation.
This completes mono bug 496138
(https://bugzilla.novell.com/show_bug.cgi?id=496138)
1. Make sure that you used GNU tar to unpack this package, as
Solaris tar will not unpack this correctly, and you will get strange errors.
2. Make sure that you use the GNU toolchain to build the software.
3. Optional dependencies
* libgdiplus - Required for System.Drawing. This library in turn requires glib and pkg-config
* pkg-config - Available at: http://www.freedesktop.org/Software/pkgconfig
* glib 2.4 - Available at: http://www.gtk.org/
* libzlib - This library and the development headers are required for compression
file support in the 2.0 profile.
4. Mono is required to build Mono. Use a system package or monolite (explained further below)
5. If you have a system Mono (not monolite), you will need to read this: http://mono-project.com/Parallel_Mono_Environments#Setting_up_a_Build_Environment
b. Building the Software
------------------------
If you obtained this package as an officially released tarball,
this is very simple, use configure and make:
`./configure --prefix=/usr/local ; make ; make install`
Mono supports a JIT engine on x86, SPARC, SPARCv9, S/390,
S/390x, AMD64, ARM and PowerPC systems.
If you obtained this as a snapshot, you will need an existing
Mono installation. To upgrade your installation, unpack both
mono and mcs:
tar xzf mcs-XXXX.tar.gz
tar xzf mono-XXXX.tar.gz
mv mono-XXX mono
mv mcs-XXX mcs
cd mono
./autogen.sh --prefix=/usr/local
make
The Mono build system is silent for most compilation commands.
To enable a more verbose compile (for example, to pinpoint
problems in your makefiles or your system) pass the V=1 flag to make, like this:
` make V=1`
c. Building the software from GIT
---------------------------------
If you are building the software from GIT, make sure that you
have up-to-date mcs and mono sources:
* If you are an anonymous user: `git clone git://github.com/mono/mono.git`
* If you are a Mono contributor with read/write privileges: `git clone [email protected]:mono/mono.git`
Then, go into the mono directory, and configure:
cd mono
./autogen.sh --prefix=/usr/local
make
For people with non-standard installations of the auto* utils and of
pkg-config (common on misconfigured OSX and windows boxes), you could get
an error like this:
./configure: line 19176: syntax error near unexpected token 'PKG_CHECK_MODULES(BASE_DEPENDENCIES,' ...
This means that you need to set the ACLOCAL_FLAGS environment variable
* Currently this is used with Mono's AOT engine as
Native Client does not support JIT engines yet.
Using Mono
==========
Working With Submodules
=======================
Once you have installed the software, you can run a few programs:
Mono references several external git submodules, for example
a fork of Microsoft's reference source code that has been altered
to be suitable for use with the Mono runtime.
*`mono program.exe` runtime engine
This section describes how to use it.
*`mcs program.cs` C# compiler
An initial clone should be done recursively so all submodules will also be
cloned in a single pass:
*`monodis program.exe` CIL Disassembler
$ git clone --recursive git@github.com:mono/mono
See the man pages for mono(1), mint(1), monodis(1) and mcs(2)
for further details.
Once cloned, submodules can be updated to pull down the latest changes.
This can also be done after an initial non-recursive clone:
Directory Roadmap
=================
$ git submodule update --init --recursive
*`docs/` - Technical documents about the Mono runtime.
To pull external changes into a submodule:
*`data/` - Configuration files installed as part of the Mono runtime.
$ cd <submodule>
$ git pull origin <branch>
$ cd <top-level>
$ git add <submodule>
$ git commit
*`mono/` - The core of the Mono Runtime.
By default, submodules are detached because they point to a specific commit.
Use `git checkout` to move back to a branch before making changes:
*`metadata/` - The object system and metadata reader.
$ cd <submodule>
$ git checkout <branch>
# work as normal; the submodule is a normal repo
$ git commit/push new changes to the repo (submodule)
*`mini/` - The Just in Time Compiler.
$ cd <top-level>
$ git add <submodule> # this will record the new commits to the submodule
$ git commit
*`dis/` - CIL executable Disassembler
To switch the repo of a submodule (this should not be a common or normal thing
to do at all), first edit `.gitmodules` to point to the new location, then:
*`cli/` - Common code for the JIT and the interpreter.
$ git submodule sync -- <path of the submodule>
$ git submodule update --recursive
$ git checkout <desired new hash or branch>
*`io-layer/` - The I/O layer and system abstraction for
emulating the .NET IO model.
*`cil/` - Common Intermediate Representation, XML
definition of the CIL bytecodes.
*`interp/` - Interpreter for CLI executables (obsolete).
*`arch/` - Architecture specific portions.
*`man/` - Manual pages for the various Mono commands and programs.
*`samples/` -Some simple sample programs on uses of the Mono
runtime as an embedded library.
*`scripts/` - Scripts used to invoke Mono and the corresponding program.
*`runtime/` - A directory that contains the Makefiles that link the
mono/ and mcs/ build systems.
*`../olive/`
* If the directory ../olive is present (as an
independent checkout) from the Mono module, that
directory is automatically configured to share the
same prefix than this module gets.
Contributing to Mono
====================
Before submitting changes to Mono, please review the contribution guidelines at http://mono-project.com/Contributing. Please pay particular attention to the [Important Rules](http://mono-project.com/Contributing#Important_Rules) section.
Git submodules maintenance
==========================
Read documentation at http://mono-project.com/Git_Submodule_Maintenance
Maintainer
==========
Mono is maintained by miguel@xamarin.com
Reporting bugs
==============
To submit bug reports, please use Xamarin's Bugzilla:
https://bugzilla.xamarin.com/
Please use the search facility to ensure the same bug hasn't already
been submitted and follow our guidelines on how to make a good bug
Loaded 100 of 13457 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.