Skip to content

AsyncObservable.DeferAsync calls itselfs recursively. #1976

Description

@pwretmo

Hello and thank you for using dotnet/reactive. Please select a category and detail your issue by answering the questions there:

Bug

Despite our best efforts, bugs can slip into releases or corner cases forgotten about. We will try our best to remedy the situation
and/or provide workarounds. Note that certain (odd) behaviors are by design and as such are not considered bugs.

Which library version?

System.Reactive.Async 6.0.0-alpha.18

What are the platform(s), environment(s) and related component version(s)?

Windows 10 x64, .NET 7.0

What is the use case or problem?

The DeferAsync overload taking an CancellationToken calls itself recursively.

public static IAsyncObservable<TSource> AsyncObservable.DeferAsync<TSource>(Func<CancellationToken, ValueTask<IAsyncObservable<TSource>>> observableFactory) => DeferAsync(observableFactory);

What is the expected outcome?

An IAsyncObservable is returned.

What is the actual outcome?

Stackoverflow exception

The program '[36248] testhost.exe: Program Trace' has exited with code 0 (0x0).
The program '[36248] testhost.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.
The program '[36248] testhost.exe' has exited with code 4294967295 (0xffffffff).

What is the stacktrace of the exception(s) if any?

The active test run was aborted. Reason: Test host process crashed : Stack overflow.
Repeat 24063 times:


   at System.Reactive.Linq.AsyncObservable.DeferAsync[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`2<System.Threading.CancellationToken,System.Threading.Tasks.ValueTask`1<System.IAsyncObservable`1<System.__Canon>>>)

Do you have a code snippet or project that reproduces the problem?

AsyncObservable.DeferAsync(cancellationToken => ValueTask.FromResult(AsyncObservable.Return(Unit.Default)));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions