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

StackoverflowException #899

Closed
nopara73 opened this issue Nov 27, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@nopara73
Copy link
Collaborator

commented Nov 27, 2018

I've been getting StackoverflowException once or twice a day while mixing on my main wallet. I used WinDBG to debug it based on the instructions of the following resources:

WinDBG output:

ModLoad: 00007ff9`fc7a0000 00007ff9`fc805000   C:\WINDOWS\system32\Ninput.dll
(9130.6258): Stack overflow - code c00000fd (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
coreclr!GCHeapUtilities::UseThreadAllocationContexts+0xe [inlined in coreclr!AllocateArrayEx+0x1d1]:
00007ff9`c37554bd e866020000      call    coreclr!GetCurrentProcessCpuCount (00007ff9`c3755728)
0:000> .loadby sos corecrl
Unable to find module 'corecrl'
0:000> .loadby sos crl
Unable to find module 'crl'
0:000> .loadby sos coreclr
0:000> !clrstack
OS Thread Id: 0x6258 (0)
        Child SP               IP Call Site
0000002f7a8061d8 00007ff9c37554bd [HelperMethodFrame: 0000002f7a8061d8] 
0000002f7a806320 <link alt="!U /d 00007ff9d3a95ea5" cmd="!U /d 00007ff9d3a95ea5"><u>00007ff9d3a95ea5</u></link> System.Collections.Generic.Queue`1[[System.__Canon, System.Private.CoreLib]].SetCapacity(Int32)
0000002f7a806370 <link alt="!U /d 00007ff9d3a959ec" cmd="!U /d 00007ff9d3a959ec"><u>00007ff9d3a959ec</u></link> System.Collections.Generic.Queue`1[[System.__Canon, System.Private.CoreLib]].Enqueue(System.__Canon)
0000002f7a8063b0 <link alt="!U /d 00007ff963da82e4" cmd="!U /d 00007ff963da82e4"><u>00007ff963da82e4</u></link> System.Reactive.Concurrency.AsyncLock.Wait(System.Action) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\AsyncLock.cs @ 36]
0000002f7a806410 <link alt="!U /d 00007ff963da8204" cmd="!U /d 00007ff963da8204"><u>00007ff963da8204</u></link> System.Reactive.Concurrency.ImmediateScheduler+AsyncLockScheduler.Schedule[[System.__Canon, System.Private.CoreLib]](System.__Canon, System.Func`3&lt;System.Reactive.Concurrency.IScheduler,System.__Canon,System.IDisposable&gt;) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\ImmediateScheduler.cs @ 89]
0000002f7a806460 <link alt="!U /d 00007ff963da7fe6" cmd="!U /d 00007ff963da7fe6"><u>00007ff963da7fe6</u></link> System.Reactive.Concurrency.Scheduler+c__DisplayClass49_0`1[[System.__Canon, System.Private.CoreLib]].b__1(System.__Canon) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Recursive.cs @ 60]
0000002f7a8064e0 <link alt="!U /d 00007ff964e4df2c" cmd="!U /d 00007ff964e4df2c"><u>00007ff964e4df2c</u></link> System.Reactive.ScheduledObserver`1[[System.__Canon, System.Private.CoreLib]].Run(System.Object, System.Action`1&lt;System.Object&gt;) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\ScheduledObserver.cs @ 268]
0000002f7a806560 <link alt="!U /d 00007ff963da78f6" cmd="!U /d 00007ff963da78f6"><u>00007ff963da78f6</u></link> System.Reactive.Concurrency.Scheduler.InvokeRec1[[System.__Canon, System.Private.CoreLib]](System.Reactive.Concurrency.IScheduler, Pair`2&lt;System.__Canon,System.Action`2&lt;System.__Canon,System.Action`1&lt;System.__Canon&gt;&gt;&gt;) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Recursive.cs @ 89]
0000002f7a8065c0 <link alt="!U /d 00007ff963da778c" cmd="!U /d 00007ff963da778c"><u>00007ff963da778c</u></link> System.Reactive.Concurrency.ImmediateScheduler.Schedule[[System.Reactive.Concurrency.Scheduler+Pair`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]], System.Reactive]](Pair`2&lt;System.__Canon,System.__Canon&gt;, System.Func`3&lt;System.Reactive.Concurrency.IScheduler,Pair`2&lt;System.__Canon,System.__Canon&gt;,System.IDisposable&gt;)
0000002f7a806600 <link alt="!U /d 00007ff963da729b" cmd="!U /d 00007ff963da729b"><u>00007ff963da729b</u></link> System.Reactive.Concurrency.Scheduler.Schedule[[System.__Canon, System.Private.CoreLib]](System.Reactive.Concurrency.IScheduler, System.__Canon, System.Action`2&lt;System.__Canon,System.Action`1&lt;System.__Canon&gt;&gt;)
0000002f7a806680 <link alt="!U /d 00007ff964e4dc6d" cmd="!U /d 00007ff964e4dc6d"><u>00007ff964e4dc6d</u></link> System.Reactive.ScheduledObserver`1[[System.__Canon, System.Private.CoreLib]].EnsureActiveSlow() [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\ScheduledObserver.cs @ 180]
0000002f7a8066d0 <link alt="!U /d 00007ff9646e481a" cmd="!U /d 00007ff9646e481a"><u>00007ff9646e481a</u></link> System.Reactive.Linq.ObservableImpl.Select`2+Selector+_[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].OnNext(System.__Canon) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Select.cs @ 49]
0000002f7a806720 <link alt="!U /d 00007ff964db93dc" cmd="!U /d 00007ff964db93dc"><u>00007ff964db93dc</u></link> System.Reactive.SafeObserver`1[[System.__Canon, System.Private.CoreLib]].OnNext(System.__Canon) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\SafeObserver.cs @ 41]
0000002f7a806780 <link alt="!U /d 00007ff964e4df1e" cmd="!U /d 00007ff964e4df1e"><u>00007ff964e4df1e</u></link> System.Reactive.ScheduledObserver`1[[System.__Canon, System.Private.CoreLib]].Run(System.Object, System.Action`1&lt;System.Object&gt;) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\ScheduledObserver.cs @ 254]
0000002f7a806800 <link alt="!U /d 00007ff963da8619" cmd="!U /d 00007ff963da8619"><u>00007ff963da8619</u></link> System.Reactive.Concurrency.Scheduler+c__DisplayClass49_1`1[[System.__Canon, System.Private.CoreLib]].b__2(System.Reactive.Concurrency.IScheduler, System.__Canon) [D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Recursive.cs @ 73]
0000002f7a806860 <link alt="!U /d 00007ff964deb392" cmd="!U /d 00007ff964deb392"><u>00007ff964deb392</u></link> Avalonia.Threading.AvaloniaScheduler.Schedule[[System.__Canon, System.Private.CoreLib]](System.__Canon, System.TimeSpan, System.Func`3&lt;System.Reactive.Concurrency.IScheduler,System.__Canon,System.IDisposable&gt;)

@danwalmsley @lontivero @molnard Can you share your thoughts on it? This is the last pressing issue before the next release.

@nopara73 nopara73 added the debug label Nov 27, 2018

@lontivero

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

SOEs are in my experience always because of recursive calls and that's the first thing that jumps to my face here where a read Scheduler.Recursive.cs. It seems the problem is in the AvaloniaScheduler or in the System.Reactive.Concurrency.Scheduler.

IMO this is a Rx problem, I just gave a flash look to the code and it looks to me that when scheduled actions cannot be executed at the expected time because some other action has a lock adquired, that action is put in a queue where it waits for the opportunity to run, however I can't see why that would push something into the stack

https://github.com/dotnet/reactive/blob/50274fb3fe912605cff86f1325179cffb4578047/Rx.NET/Source/src/System.Reactive/Concurrency/AsyncLock.cs#L79

BTW, the Rx team fixed an SOE in 4.1.0 (Avalonia is using 4.0.0 i think) here dotnet/reactive#738. I think that is not the same SOE we have but it could worth to consider the update in Avalonia.

Gene

@lontivero

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

I've been trying to make it fail with no luck. I used variants on the following test:

	[Fact]
	public void ForceStackOverflowException()
	{
		var threading = new InternalPlatformThreadingInterface();
		AvaloniaLocator.CurrentMutable
			.Bind<IPlatformThreadingInterface>().ToConstant(threading);

		var state = default(object);
		Func<IScheduler, object, IDisposable> action = (_scheduler, _state) => { 
			// Some time consuming lines here
			output.WriteLine(".");
			return new Disposable(); 
			};
		var rnd = new Random();
		var scheduler = AvaloniaScheduler.Instance;
		Task.Run(()=>threading.RunLoop(default(CancellationToken)));

		for(var i=0; i< 1_000; i++)
		{
			var dueTime = TimeSpan.FromMilliseconds(rnd.Next(0, 5)); 
			scheduler.Schedule(state, dueTime, action);
		}
	}
}

class Disposable : IDisposable
{
	public void Dispose()	{}
}
@nopara73

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 28, 2018

@molnard is currently replacing the RX magic, so hopefully that'll solve it.

@danwalmsley

This comment has been minimized.

Copy link
Contributor

commented Nov 28, 2018

In this case it could be something that schedules something, that schedules something that schedules something recursively.

Is you window minimized at all when this happen , or minimized then restored?

How would I try to repro, just leave some coins mixing, have you used test net to repro?

@nopara73

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 28, 2018

Is you window minimized at all when this happen , or minimized then restored?

It happens both in maximized and minimized. It seems like this issue doesn't happen when I'm away, only when I'm doing stuff, like watching youtube video or something. But pretty random.

How would I try to repro, just leave some coins mixing, have you used test net to repro?

Have no idea. It comes once or twice a day consistently, but randomly while mixing. Not sure the mixing part has a relevance here, but I don't leave Wasabi open long without mixing.

@nopara73

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 29, 2018

It think it's been fixed. We've done some refactoring and now it doesn't seem to happen anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.