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

Stack overflow with MapT on T<Seq> #1236

Closed
torkjel opened this issue Aug 4, 2023 · 1 comment
Closed

Stack overflow with MapT on T<Seq> #1236

torkjel opened this issue Aug 4, 2023 · 1 comment

Comments

@torkjel
Copy link

torkjel commented Aug 4, 2023

.Net 7 and language-ext 4.4.2

    public void Test() {
        var wrappedData = Seq1(
            Enumerable
                .Range(0, 30000)
                .Select(_ => Guid.NewGuid().ToString())
                .ToSeq()
        );

        var count = wrappedData
            .MapT(r => r.ToArray())    
            .CountT();

        Assert.Equal(30000, count);
    }

I've tested this with Task, Optional and Seq as the outermost type, which all fails the same way.

Replacing the MapT call with .Map(r => r.Map(s => s.ToArray())) works as expected.

End of stack trace:

The active test run was aborted. Reason: Test host process crashed : Stack overflow.
   at LanguageExt.SeqLazy`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetEnumerator()
   at LanguageExt.Seq`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetEnumerator()
   at LanguageExt.ClassInstances.MSeq`1+<>c__DisplayClass11_0+<<Plus>g__Yield|0>d[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.Enum`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Get(Int32)
   at LanguageExt.SeqLazy`1+<GetEnumerator>d__35[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.ClassInstances.MSeq`1+<>c__DisplayClass11_0+<<Plus>g__Yield|0>d[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.Enum`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Get(Int32)
   at LanguageExt.SeqLazy`1+<GetEnumerator>d__35[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.ClassInstances.MSeq`1+<>c__DisplayClass11_0+<<Plus>g__Yield|0>d[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.Enum`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Get(Int32)
   at LanguageExt.SeqLazy`1+<GetEnumerator>d__35[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at LanguageExt.ClassInstances.MSeq`1+<>c__DisplayClass11_0+<<Plus>g__Yield|0>d[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
...
louthy added a commit that referenced this issue Aug 6, 2023
Some legacy code for concatenation in the MSeq type, this has already been resolved in Seq.Concat, so use that instead.
@louthy
Copy link
Owner

louthy commented Aug 6, 2023

Thanks for that, will be fixed in the next release 👍

@louthy louthy closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants