question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fsiSession.Run() is crashing the hosting app.

See original GitHub issue

I am hosting FCS in another app. (Rhino 3D) When I create an FSI session and call Run() it crashes the App. I could not catch an exception. Are these comments here explaining why? The hosting app has already other active threads: https://github.com/dotnet/fsharp/blob/main/src/Compiler/Interactive/fsi.fs#L3759

member x.Run() =
        progress <- condition "FSHARP_INTERACTIVE_PROGRESS"

        // Explanation: When Run is called we do a bunch of processing. For fsi.exe
        // and fsiAnyCpu.exe there are no other active threads at this point, so we can assume this is the
        // unique compilation thread.  For other users of FsiEvaluationSession it is reasonable to assume that
        // the object is not accessed concurrently during startup preparation.
        //
        // We later switch to doing interaction-by-interaction processing on the "event loop" thread

        ...

Skipping this call to Run() and just using the session for evaluations seems to be mostly OK. But I have some other not so critical issues like line numbers missing in exceptions despite using --multiemit. see https://github.com/dotnet/fsharp/discussions/13293#discussioncomment-2949022

What am I missing in my fsi sessions if I don’t call the Run() method at the beginning ?

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KevinRansomcommented, Dec 19, 2022

@goswinr If your app is already pumping messages ‘Application.Run() starts that I believe’, then yes you probably don’t need fsi.Run().

Are you creating a desktop or a dotnet WPF App.

Just for background, we haven’t done any work to enable FSI and dotnet WPF or WinForms projects to work from fcs, although back in the day some work was done to ensure that fsi.exe does not block message pumping. So, from a particularly narrow view of the world the scenarios are currently unsupported. However, they look useful and interesting, I’m sure we can try to help you work through any blockers that may exist.

Please supply the complete project file for your sample, and I will take a look over the holidays if I get a chance.

0reactions
goswinrcommented, Dec 21, 2022

@KevinRansom

“we haven’t done any work to enable FSI and dotnet WPF or WinForms”

For now I assume I don’t need to call fsiSession.Run() . Do you have an idea why it crashes the WPF app? It actually works well without since a few years now. I started with the Tsunami Editor as seen here, now I am using AvalonEdit. I am not using fsi.exe just the FCS nuget. Soon I want to make my Scripting Editor public too.

“Are you creating a desktop or a dotnet WPF App.”

For hosting in Rhino3D I use net48, for standalone scripting I use net7.

“I’m sure we can try to help you work through any blockers that may exist.”

Thanks, that’s very kind of you. Only when watching the source of fsharp I see how much work you are actually putting into it. The biggest blocker was https://github.com/dotnet/fsharp/issues/11770 , but now I have a workaround.

but I will try again and if unsuccessful create separate issues and samples for those. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes at runtime when attemp…
However, when I attempt to run my code, if any of my Views are using the new method of declaring Previews, the app...
Read more >
How to troubleshoot/fix Azure Function host crashing?
1 Answer 1 ... Check whether Function host is not running is consistent after restarting Function app. And make sure we checked the...
Read more >
"Test host process crashed" error hard to diagnose #2952
Our CI has an intermittent failure: The active test run was aborted. Reason: Test host process crashed Results File: ...
Read more >
Diagnosing an ASP.NET Core hard crash
The web server runs ASP.NET Core within a WPF application to make it easy to interact with logs while it's running, and to...
Read more >
Applications on a host being scanned crash while Nessus ...
During a Nessus scan, applications may crash because of the service detection that is performed on open ports. Service detection is designed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found