Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[watch] MonoTouchFixtures.ObjCRuntime.RuntimeTest.UsableUntilDead fails on arm64_32 #7076

Open
lewurm opened this issue Sep 23, 2019 · 0 comments
Assignees
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS watchOS
Milestone

Comments

@lewurm
Copy link
Contributor

lewurm commented Sep 23, 2019

Steps to Reproduce

  1. build Xamarin.iOS that includes watch4 debug support (soon in master)
  2. run monotouch-tests

Expected Behavior

MonoTouchFixtures.ObjCRuntime.RuntimeTest.UsableUntilDead should pass.

[Test]
public void UsableUntilDead ()
{
// The test can be inconclusive once in a while.
// 100 times in a row is a bit too much though.
for (int i = 0; i < 100; i++) {
if (UsableUntilDeadImpl ())
return;
}
Assert.Inconclusive ("Failed to collect the notification object at least once in 100 runs.");
}
public bool UsableUntilDeadImpl ()
{
// This test ensure that the main thread can send messages to a garbage collected object,
// until the final 'release' message for the managed reference has been sent
// (on the main thread).
var notifierHandle = IntPtr.Zero;
// bool isDeallocated = false;
Action deallocated = () => {
//Console.WriteLine ("Final release!");
// isDeallocated = true;
};
ManualResetEvent isCollected = new ManualResetEvent (false);
Action collected = () => {
//Console.WriteLine ("Garbage collected!");
isCollected.Set ();
};
bool isNotified = false;
Action notified = () => {
//Console.WriteLine ("Notified");
isNotified = true;
};
// Create an object whose handle we store in a local variable. We do not
// store the object itself, since we want the object to be garbage collected.
var t = new Thread (() => {
var obj = new Notifier (collected, notified);
ReleaseNotifier.NotifyWhenDeallocated (obj, deallocated);
notifierHandle = obj.Handle;
}) {
IsBackground = true,
};
t.Start ();
t.Join ();
// Now we have a handle to an object that may be garbage collected at any time.
int counter = 0;
do {
GC.Collect ();
GC.WaitForPendingFinalizers ();
} while (counter++ < 10 && !isCollected.WaitOne (10));
// Now we have a handle to a garbage collected object.
if (!isCollected.WaitOne (0)) {
// Objects may randomly not end up collected (at least in Boehm), because
// other objects may happen to contain a random value pointing to the
// object we're waiting to become freed.
return false;
}
// Send a message to the collected object.
Messaging.void_objc_msgSend (notifierHandle, Selector.GetHandle ("notify"));
Assert.IsTrue (isNotified, "notified");
// We're done. Cleanup.
NSRunLoop.Main.RunUntil (NSDate.Now.AddSeconds (0.1));
// Don't verify cleanup, it's not consistent.
// And in any case it's not what this test is about.
// Assert.IsTrue (isDeallocated, "released");
return true;
}

Actual Behavior

it crashes:

(lldb) c
Process 1251 resuming
Process 1251 stopped
* thread #10, name = 'tid_9a0b', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x1b5826c4 libobjc.A.dylib`objc_msgSend + 36
libobjc.A.dylib`objc_msgSend:
->  0x1b5826c4 <+36>: ldp    w10, w11, [x16, #0x8]
    0x1b5826c8 <+40>: and    w11, w11, #0xffff
    0x1b5826cc <+44>: and    w12, w1, w11
    0x1b5826d0 <+48>: add    w12, w10, w12, lsl #3
Target 0: (monotouchtest) stopped.

(lldb) mbt
* thread #10
  * frame #0: 0x1b5826c4 libobjc.A.dylib`objc_msgSend + 36
    frame #1: 0x047397e8 monotouchtest`::xamarin_pinvoke_wrapper_void_objc_msgSend(receiver=0x19091ec0, selector=0x20fd9264) at pinvokes.m:420:4
    frame #2: 0x04a96b58 monotouchtest`do_icall(frame=<unavailable>, sig=0x181a8340, op=<unavailable>, sp=0x194bdb10, ptr=<unavailable>, save_last_error=0) at interp.c:1949:3 [opt]
    frame #3: 0x04a956ac monotouchtest`do_icall_wrapper(frame=0x194bdce8, sig=0x181a8340, op=547, sp=0x194bdb20, ptr=0x047397b8, save_last_error=0) at interp.c:2039:7 [opt]
    Messaging::void_objc_msgSend @ 34 "calli.nat.fast" || frame #4: 0x04a916e8 monotouchtest`interp_exec_method_full(frame=0x194bdce8, context=<unavailable>, clause_args=0x00000000, error=0x194be318) at interp.c:3238:9 [opt]
    RuntimeTest::UsableUntilDeadImpl @ 403567510 "vcall" || frame #5: 0x04a8d8ec monotouchtest`interp_exec_method_full(frame=0x194bde08, context=<unavailable>, clause_args=0x00000000, error=0x194be318) at interp.c:3410:4 [opt]
    RuntimeTest::UsableUntilDead @ 403566530 "call" || frame #6: 0x04a8d8ec monotouchtest`interp_exec_method_full(frame=0x194bdf38, context=<unavailable>, clause_args=0x00000000, error=0x194be318) at interp.c:3410:4 [opt]
    Object::runtime_invoke_direct_void__this__ @ 403566190 "vcall" || frame #7: 0x04a8d8ec monotouchtest`interp_exec_method_full(frame=0x194bdfe8, context=<unavailable>, clause_args=0x00000000, error=0x194be318) at interp.c:3410:4 [opt]
 
@lewurm lewurm self-assigned this Sep 23, 2019
@chamons chamons added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS labels Sep 25, 2019
@chamons chamons added this to the Future milestone Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS watchOS
Projects
None yet
Development

No branches or pull requests

3 participants