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.
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.
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.
AM_CONDITIONAL(SUPPORT_SGEN, test x$buildsgen = xyes)
@@ -3285,7 +3192,7 @@ case "$host" in
X11="libX11.so.6"
;;
*-*-*freebsd*)
LIBC="libc.so"
LIBC="libc.so.7"
INTL="libintl.so"
SQLITE="libsqlite.so"
SQLITE3="libsqlite3.so"
@@ -3401,7 +3308,7 @@ if test ${TARGET} = ARM; then
fpu=NONE
# iOS GCC always uses the 'softfp' ABI.
if test x"$GCC" = xyes && test x$platform_darwin = xyes; then
if test x"$GCC" = xyes && test x$host_darwin = xyes; then
fpu=VFP
fi
@@ -3535,10 +3442,12 @@ case "x$libgc" in
;;
esac
AC_ARG_WITH(profile4_5,[ --with-profile4_5=yes,no If you want to install the 4.5 FX (defaults to yes)], [], [with_profile4_5=yes])
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=no])
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no,only If you want to build the MonoTouch assemblies (defaults to no)], [], [with_monotouch=no])
AC_ARG_WITH(xammac, [ --with-xammac=yes,no,only If you want to build the Xamarin.Mac assemblies (defaults to no)],[], [with_xammac=no])
AC_ARG_WITH(profile4_x, [ --with-profile4=yes,no If you want to install the 4.6 FX (defaults to yes)], [], [with_profile4_x=yes])
AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=no])
AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the Xamarin.iOS assemblies (defaults to no)], [], [with_monotouch=no])
AC_ARG_WITH(monotouch_watch, [ --with-monotouch_watch=yes,no If you want to build the Xamarin.WatchOS assemblies (defaults to no)],[], [with_monotouch_watch=no])
AC_ARG_WITH(monotouch_tv, [ --with-monotouch_tv=yes,no If you want to build the Xamarin.TVOS assemblies (defaults to no)], [], [with_monotouch_tv=no])
AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you want to build the Xamarin.Mac assemblies (defaults to no)], [], [with_xammac=no])
OPROFILE=no
AC_ARG_WITH(oprofile,[ --with-oprofile=no,<oprofile install dir> Enable oprofile support (defaults to no)],[
@@ -3569,7 +3478,7 @@ AC_ARG_WITH(mcs_docs,[ --with-mcs-docs=yes,no If you want to build the
if [ ! -f "TestResult-$(PROFILE).xml" ]; then echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='1' total='1' not-run='0' name='bcl-tests' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='$(strip $(test_assemblies))' success='False' time='0'><results><test-case name='crash' executed='True' success='False' time='0'><failure><message>The test runner didn't produce a test result XML, probably due to a crash of the runtime. Check the log for more details.</message><stack-trace></stack-trace></failure></test-case></results></test-suite></test-results>" > TestResult-$(PROFILE).xml; fi; \
$(TEST_HARNESS_POSTPROC) ; $$ok
## Instructs compiler to compile to target .net execution, it can be usefull in rare cases when runtime detection is not possible
Loaded 100 of 3275 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.