contour: Set terminal title by .Net console application throwing an exception

Contour Terminal version

0.3.11.258

Installer source

GitHub: release page

Operating System

Ubuntu 22.04.2 LTS

Architecture

x86-64

Other Software

NVIM v0.9.0

Steps to reproduce

Creating a dotnet console application with:

dotnet new console 

That will creates a .Net application, so just edit the file Program.cs:

Console.Title = "Test"

And run it:

dotnet run

Expected Behavior

The behavior expected is the name of console changes the bottom title bar:

Before execution: image

After execution:

image

Actual Behavior

Throwing an exception:

Unhandled exception. System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.ThrowForEmptyStack()
   at System.Collections.Generic.Stack`1.Pop()
   at System.TermInfo.ParameterizedStrings.EvaluateInternal(String format, Int32& pos, FormatParam[] args, Stack`1 stack, FormatParam[]& dynamicVars, FormatParam[]& staticVars)
   at System.TermInfo.ParameterizedStrings.Evaluate(String format, FormatParam[] args)
   at System.ConsolePal.set_Title(String value)

image

Additional notes

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (14 by maintainers)

Most upvoted comments

To summarise the Discord’s outcome.

  • the terminfo used is a bit old (we really need to create a new point release ASAP)
  • the old terminfo wasn’t bad though, but it is expecting two parameters to be passed, with the second one being a column to start writing to in the status line (since tsl stands for “to status line” and was only abused by xterm and the likes to set the window title, which is wrong to begin with)
  • there is varying documentation, some saying %d does pop from stack, others say it doesn’t.
  • however, dotnet should probably not hard-fail on internal (and especially recoverable) errors, but instead fallback when not being able to set the title. External data (e.g. unexpected terminfo entries) should not cause your application to crash 😃

We’ve fixed the problem for @AugustoDeveloper by providing an up-to-date terminfo file (which contains a more trivialized form of tsl to move to the (host writable) status line, which also does not imply 2 parameters on the stack anymore.

But it also showed that we really should create a new bugfix release ASAP. 😃

I can’t reproduce it on latest master image

Looks like something is wrond with terminfo file, can you check what is echo $TERM telling you? First thing that you can try is to set same TERM (export TERM=....) for contour as for gnome-terminal, and see if this will resolve issue, then we can identify what we need to fix exactly.