To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at

If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

Plug In an UPS and Get a Program Crash

Plug In an UPS and Get a Program Crash

Aug 29 2013

After publishing the article "Grounded Pointers", a lot of people commented on it. Among other things, they mentioned that various devices are often shipped with extremely poor software. And that gets on nerves quite a bit sometimes. However, I'm not going to grumble about that. Instead, I'd like to tell you a funny story to the point.

I was a student then and worked as a programmer in one firm. Its field was computer simulation. We developed software packages designed to compute various parameters as well as data visualizers.

Now the story itself. One day I was sitting and writing some code as usual. Here, a physicist colleague of mine appears from his cabin and approaches me. And he has that strange expression and odd smile on his face. Now he gets serious and says, "Your wonderful app "ABCD" suggests that I contact the manufacturer - so here I am".

That's it. I see what he means. When a program crashes, it displays a message in the "Please contact manufacturer" style. Since I am one of the developers of "ABCD", he has come for me. But what does that strange smile mean and why not simply report the bug in the bugtracker? Without much thinking about it, I stand up and follow him.

A common sight: a crash report window. Big deal! No, don't think it crashes every 5 minutes; but there's nothing to wonder at, too. I ask, "What've you done?"

He smiles widely, and the following dialogue takes place:

"I've plugged my computer to a new UPS [uninterruptable power supply]. The program won't run after that - it crashes at launch."

"H'm... What else?"


"Ha-ha. Oh yeah, sure! So, it had worked before you plugged in the UPS and now it doesn't."

An even wider smile spreads over my colleague's face:

"That's it! Look, I'll show you a trick."

He turns off the computer, crawls under the desk, rustles there for a while, unplugging the UPS power cable and plugging in the ordinary mains power cable. Then he turns on the computer, runs our program - it works well.

Then he again turns off the computer, crawls under the desk and plugs in the UPS power cable back. He turns on the computer and, now smiling as hell, runs the program - it crashes right after the start!

I was shocked. You know, never in my life I've been so much confused when dealing with computers.

It all cleared up pretty soon, of course. And I'll tell you about that - the reason was awfully trivial.

But it was at that moment that I doubted my understanding of the computer's operation principles and basic laws of physics. The joke about bits being deformed in a cable seemed not that much a joke to me then.

That must have been the strongest impression a computer has ever made on me. Don't even know what to compare it to. Perhaps I felt something similar when experimenting with the Apogei BK-01 computer and discovering that I could control it by simply moving my hand close to it. You could read and process the random noise from the input/output ports (don't remember how to call them properly) not connected to anything.

I'm not sure I can express my feelings at that moment in words. Try to imagine a situation when an application you are well familiar with runs well on the mains power and crashes when running on an UPS.

It turned out to be pretty simple, though. It was not some magic voltage drop caused by a defective UPS. Neither was it deformed bits.

Poor software was the reason for that magic and my astonishment. And also my colleague appeared a nasty guy, for he had at first concealed one important thing finding it irrelevant.

It was not only the UPS plugged to the computer. It shipped together with a disk with software and a USB cable to connect it to the computer. The app from the disk allowed you to perform various tasks. For example, you could click on its icon in Systray and view the battery charge. What's important, my colleague had installed that app too - just for the sake of it.

The consequences were fatal. That marvelous app, messing around in Systray, knocked out not only our program, but - as we found out later - many other applications as well. How did it manage to do that? Ha, shit coders can do much more than that!

Investigations of the reasons for the crash revealed that the OpenGL subsystem had been broken. But our program didn't use OpenGL too much. Other OpenGL programs were broken too. For example, Quake stopped working - or was it some other shooter? I don't remember now. Yeah, sometimes we spent our after-work time shooting each other in the virtual world. Aren't all students like that?

For some reason this shit-app for the UPS exploited OpenGL when drawing a nice round diagram of the battery charge percent. Moreover, it did it very unceremoniously: after being launched, it consumed all the OpenGL resources. It resulted in OpenGL being used by this monitor app alone, while leaving a fat lot for others. It didn't matter if you were viewing its beautiful picture or not - all the resources were already exhausted. It's been much time since then, so I don't remember what it did in particular. But the general tactics was the following. It kept creating some OpenGL objects without freeing them. Those objects ran out at one instant, but the app didn't give a damn. It itself was running perfectly well, while other programs could not create an object for themselves - they got an error status instead of descriptors.

The problem disappeared when turning off the UPS with its USB cable still connected to the computer. I guess the app worked somehow differently when it stopped seeing the UPS. It was that very mechanism my colleague had demonstrated me, shaking my sense of reality.

That accident has resulted in us creating a more thorough diagnostic of such errors by our tool and rejecting the "marvel-monster-app" visualizing the UPS's state.

That's a good example of awful software devices sometimes come shipped with.

Popular related articles
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
Free PVS-Studio for those who develops open source projects

Date: Dec 22 2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →