MangoHud Crash Report Proc_vram Issue In Transport Fever 2

by StackCamp Team 59 views

Introduction

This article addresses a critical bug report detailing a crash in the native Linux version of Transport Fever 2 when using MangoHud. The issue stems from a recent commit that added the proc_vram option. This comprehensive analysis delves into the specifics of the bug, the steps to reproduce it, and the technical details provided in the debug logs. Understanding this issue is crucial for gamers and developers alike who rely on MangoHud for performance monitoring and overlay functionalities.

Background on MangoHud and Transport Fever 2

Before diving into the technical details, it’s important to understand the context. MangoHud is a popular open-source overlay for monitoring hardware performance metrics in real-time, particularly useful for gamers and developers. It displays information such as CPU and GPU usage, frame rates, and memory consumption directly on the screen. Transport Fever 2, on the other hand, is a transportation simulation game known for its intricate details and resource-intensive gameplay. The combination of these two tools provides users with valuable insights into how the game performs under different conditions.

Understanding the Bug

The core issue revolves around a crash occurring in Transport Fever 2 after a specific commit ([1042aaa752ab5be72ac112f09fcae12b948286cd]) was introduced in MangoHud. This commit added the proc_vram option, which aims to display the video memory usage of the process. However, this addition has inadvertently caused a crash in the game, irrespective of whether the setting is enabled or disabled. This suggests a deeper underlying problem that affects the stability of MangoHud in conjunction with Transport Fever 2.

The error message provides a critical clue:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 10) > this->size() (which is 9)
This option is not available. Please see --help for all possible usages.
/mnt/Games/steam/common/Transport Fever 2/run.sh: line 8: 244380 Aborted (core dumped) LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./TransportFever2

This error indicates an out-of-range exception within the basic_string::substr function, suggesting that the code is trying to access a part of a string that does not exist. Specifically, it attempts to access the character at position 10 in a string that is only 9 characters long. This type of error often occurs due to incorrect indexing or string manipulation, highlighting a potential flaw in how the proc_vram option is implemented or how it interacts with the game.

Hardware and Software Context

The bug report provides valuable information about the hardware and software environment in which the crash occurs. The system configuration includes:

  • Operating System: Arch Linux
  • MangoHud Version: Commit [1042aaa752ab5be72ac112f09fcae12b948286cd] or later
  • GPU: AMD Radeon RX 9070 XT

This information is essential for developers to replicate the issue and identify the root cause. The fact that the crash occurs on Arch Linux with a high-end AMD GPU suggests that the bug may be specific to certain system configurations or driver versions.

Steps to Reproduce

The bug report clearly outlines the steps to reproduce the crash, which is crucial for debugging. The steps are straightforward:

  1. Install MangoHud version [1042aaa752ab5be72ac112f09fcae12b948286cd] or later.
  2. Launch the native Linux version of Transport Fever 2.

These simple steps allow developers to quickly verify the bug and begin the debugging process. The ease of reproduction underscores the importance of this bug report in ensuring the stability of MangoHud.

Debug Log Analysis

The debug log provides a detailed trace of MangoHud's execution, offering valuable insights into the sequence of events leading to the crash. Let's break down the key elements of the log:

[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:902] Version: v0.8.1-94-ga4b64a2+
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [config.cpp:117] skipping config: '/mnt/Games/steam/common/Transport Fever 2/MangoHud.conf' [ not found ]
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [config.cpp:117] skipping config: '/home/nodscher/.config/MangoHud/TransportFever2.conf' [ not found ]
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [config.cpp:117] skipping config: '/etc/MangoHud.conf' [ not found ]
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [config.cpp:122] parsing config: '/home/nodscher/.config/MangoHud/MangoHud.conf'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1176] Failed to read presets file: '/home/nodscher/.config/MangoHud/presets.conf'. Falling back to default presets

The initial lines indicate that MangoHud is starting up, checking for configuration files, and parsing the main configuration file (/home/nodscher/.config/MangoHud/MangoHud.conf). The failure to read the presets file is a minor issue but does not directly contribute to the crash.

[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'gpu_stats' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'gpu_power' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'cpu_stats' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'cpu_mhz' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'vram' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'procmem' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'proc_vram' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'fps' = '1'
[2025-07-07 22:00:53.403] [MANGOHUD] [debug] [overlay_params.cpp:1110] Param: 'frametime' = '1'

These lines show the parsing of various parameters from the configuration file. Notably, both procmem and proc_vram are enabled. The proc_vram parameter, introduced by the problematic commit, is a prime suspect in the crash.

[2025-07-07 22:00:53.421] [MANGOHUD] [debug] [vulkan.cpp:1877] gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
[2025-07-07 22:00:53.424] [MANGOHUD] [debug] [vulkan.cpp:1563] Present mode: IMMEDIATE
[2025-07-07 22:00:53.424] [MANGOHUD] [debug] [vulkan.cpp:720] Recreating font image
[2025-07-07 22:00:53.448] [MANGOHUD] [debug] [vulkan.cpp:739] Default font tex size: 1024x2048px
[2025-07-07 22:00:54.281] [MANGOHUD] [debug] [gpu_fdinfo.h:131] GPU driver is "amdgpu"
[2025-07-07 22:00:54.281] [MANGOHUD] [debug] [gpu_fdinfo.cpp:17] fdinfo_dir = /proc/244380/fdinfo

These lines provide information about the GPU (AMD Radeon RX 9070 XT) and the Vulkan driver being used. The fdinfo_dir points to the file descriptor information directory for the Transport Fever 2 process (PID 244380), which is crucial for monitoring process-specific resources.

Potential Causes and Solutions

Based on the error message and the debug log, several potential causes can be identified:

  1. String Handling Error: The std::out_of_range exception suggests that the code handling string manipulation for the proc_vram option has a flaw. This could be due to incorrect string indexing, parsing, or formatting.
  2. Process Memory Access: The proc_vram option likely involves reading memory information from the target process (Transport Fever 2). If the memory information is not formatted as expected or if access is not properly handled, it could lead to a crash.
  3. Compatibility Issues: The bug might be specific to certain GPU drivers or system configurations. The AMD Radeon RX 9070 XT and Arch Linux combination could expose a previously undetected issue.

To address this issue, the following steps can be taken:

  1. Code Review: A thorough review of the code related to the proc_vram option, particularly the string handling and memory access routines, is essential.
  2. Debugging: Using debugging tools to trace the execution flow and identify the exact location of the crash can provide valuable insights.
  3. Testing: Testing MangoHud with different configurations and hardware setups can help identify any compatibility issues.
  4. Error Handling: Implementing robust error handling and boundary checks can prevent similar crashes in the future.

Conclusion

The crash report highlights a critical issue in MangoHud that affects Transport Fever 2 on Linux systems. The introduction of the proc_vram option, while intended to enhance monitoring capabilities, has inadvertently introduced a bug that leads to program termination. By analyzing the error message, debug logs, and system configuration, we can identify potential causes and propose solutions. Addressing this bug is crucial for maintaining the stability and reliability of MangoHud, ensuring a smooth experience for gamers and developers alike. The collaboration between users who report bugs and developers who address them is vital for the continued improvement of open-source tools like MangoHud.

This detailed analysis should assist developers in pinpointing the issue and implementing a fix, ultimately benefiting the wider community of MangoHud users and Transport Fever 2 players.