dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.88k stars 384 forks source link

Endless recursion hangs processes #2733

Open oliversturm opened 1 year ago

oliversturm commented 1 year ago

Describe the bug

I enter some code that runs a simple recursion, making the mistake to forget a small part and thereby rendering the loop endless. I have tried this in C# and F#, like this:

let rec fact x = if x > 0 then x * (fact x) else 1

printfn "%d" (fact 5)

(Should be fact (x - 1) in the then part, of course.)

Problem is that when I run this, it starts counting execution time and never ends (or crashes - not even in C#).

I can't stop using the Stop button either -- it simply doesn't react at all to being clicked.

Even after quitting VS Code, there are dotnet processes hanging around in the system that need to be killed manually.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

Version: 1.0.410202+fce65bd557e21539f9eb0ba3f9c6a64300386c94

Library version: 1.0.0-beta.23102.2+fce65bd557e21539f9eb0ba3f9c6a64300386c94

Build date: 2023-02-14T10:39:47.1022769Z

JDiLenarda commented 1 year ago

Note sure if helpful, but I'm surprised it doesn't end in a stack overflow exception, since your function is not tail recursive. When run in F# Interactive, it does.

oliversturm commented 1 year ago

I just came here with the intention of reporting this same problem, since I encountered it again and I'd completely forgotten that I had reported it previously. Yes, it should be a stack overflow! Actually, I'm demonstrating some samples of this kind specifically with the intention of dying in a stack overflow...

@brettfo I don't agree with the low impact assessment. This strange issue means that C# Interactive is completely useless for an entire category of my C# language demonstrations since it just doesn't behave the same way any "normal" command line based method would.

oliversturm commented 4 months ago

Problems remains unresolved with this version info

Version: 1.0.522904+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074

Library version: 1.0.0-beta.24229.4+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074

Build date: 2024-05-16T07:32:39.7613154Z