In the same business code scenario, the program compiled and ran normally in a CentOS 7 environment. However, when switching to CentOS 8 and using an updated version of GCC for compilation, the program crashed. It’s worth noting that the issue only occurs in Release mode, while Debug mode does not exhibit any problems. This is the first time we’ve encountered a situation like this; after three days of investigation, we finally identified the root cause.
Background: The business system, running in Windows version, is deployed locally and consumes approximately 5% of CPU resources. The Linux version of the business system, deployed within a VMware-installed CentOS8 environment, exhibits abnormal resource consumption.
Problem Description
- Host Machine: Windows 10 Enterprise
- VMware: 17.5
- Virtual Machine: CentOS8
The virtual machine resource allocation is
4C8GB, running the business system. The business system is deployed in the Linux system within the virtual machine, and the internal top command observes system resource usage. CPU utilization is not high, while the external Windows system’s Task Manager shows very high CPU resource consumption. Examining processes reveals that the VMware process consumes a large amount of CPU resources.
+—————————+ | Windows | | | | +——————–+ | | | VMware | | | | Program | | | +——————–+ | | | +—————————+
This article aims to reveal the potential for program crashes when `std::map` containers are incorrectly used in C++ programming. Specifically, attempting to access a non-existent key using bracket operator automatically adds an empty element. We will delve into this misunderstanding and demonstrate its potential risks through example code.
Storing simple values poses no problem; however, if you store pointers, issues arise. Because a pointer is an address, and if it's not initialized, the address is undefined, leading to program crashes.
Text
In the C++ standard library, std::map is an associative container that stores elements in ascending order of keys (key) and provides efficient keyword lookup functionality. However, novice developers sometimes fall into trouble because they misunderstand the behavior of the square bracket operator [] in std::map. In fact, when using [] to access a non-existent key, std::map inserts a new key-value pair, and the default constructor will be used to initialize the value type corresponding to that key.
In software development and operations, deadlocked processes are frequently encountered. This situation can lead to performance degradation or service unavailability. This article introduces how to use the pstack tool to troubleshoot deadlocked process issues by analyzing process stack information to identify the root cause and resolve it.
Background: A child service within the risk control system experienced a deadlocked state, resulting in the unavailability of the risk control service. Due to the lack of service availability monitoring, the deadlocked process situation was not detected in a timely manner, leading to system unavailability.
If things had gone as the family planned, I would have stuck to studying power grids honestly and diligently, without venturing into coding. Had I erased the dust from my memory, it all stemmed from a chat with my roommate near the Spring Festival, which led to a review of my experiences over the years.
Chapter One
The results of the gaokao (national college entrance examination) couldn’t be described as good or bad; I got into a 211 university, and according to Dad’s original plan, I should have studied power grids and returned to work for the local electricity supply bureau. Earlier accounts had also mentioned how to gradually transition onto the IT path – something that hadn’t been fully articulated before: financial perspective and self-discipline.
Designed a行情 SDK, implementing different callback function implementations, and performed an extensive test. Recently I’ve been looking into C++ function programming, where functions have become first-class citizens, flowing within the program internally – what’s the difference in performance?
Previous article link: Compiler, Callback Functions, Performance Testing
leimao大佬 also did similar tests, so I borrowed their code.
Regarding byte order: A layman’s explanation Host Order, Network Order, observed directly via debugger
In the field of computer science, certain design habits have formed due to historical reasons, just like the width of a hip dictates the width of a rocket’s thrusters – there’s no need to rigidly analyze their “advantages” and “disadvantages”; it’s simply a matter of historical convention.
Suddenly, I was feeling the urge to browse for new wallpapers, sticking with my usual black series, with some areas colored in, and the desktop needing to display icons. Other color schemes would result in blurry icons.
I stared at the assembly code, trying to figure it out, but couldn’t understand it. I tried throwing it to an AI, explaining the instructions, but it failed to explain the context – clearly, this was a command used for a specific scenario. Regular code isn’t like that.