#21862·mono

Console ctor exception with terminfo files bigger than 4kb (like xterm)

Author: SquaduckCreated Aug 22, 2026Updated Aug 24, 2026

When trying to initialize the console on a terminal with a "large" terminfo entry, (ex: xterm) an exception is thrown. This is because of a hard-coded size check here: https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mcs/class/corlib/System/TermInfoReader.cs#L92 (xterm-256color's terminfo is 4246 bytes on my system)

Steps to Reproduce

  1. Open any terminal that reports itself as xterm (Eg, Konsole, xterm)
  2. Run csharp or any mono application that initializes System.Console

Current Behavior

An exception is immediately thrown.

Expected Behavior

The console initializes successfully and the application runs.

On which platforms did you notice this

[ ] macOS [X] Linux [ ] Windows

Version Used:

Mono JIT compiler version 6.12.0.199 (tarball Mon Jul 27 02:44:24 UTC 2026)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        Interpreter:   yes
        LLVM:          supported, not enabled.
        Suspend:       hybrid
        GC:            sgen (concurrent by default)

Stacktrace

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: File must be smaller than 4K
  at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0001d] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
  at System.TermInfoDriver..ctor (System.String term) [0x00055] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
  at System.ConsoleDriver..cctor () [0x0004d] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
   --- End of inner exception stack trace ---
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
  at System.Console..cctor () [0x0007d] in <14c11be9d17f4b08805ee8ddaf6ded80>:0 
   --- End of inner exception stack trace ---
  at Mono.Driver.Main (System.String[] args) [0x00010] in <f969de5971c44e4c9e70d64a878b5067>:0