When VLC Doesn’t Update Anymore

Most of us probably ran into a bug in some application at one point. Sometimes it’s not very obvious, e.g. a random crash, while other times you may know that, if you for example perform certain five steps it will crash. But what do you do when you find an issue? Do you just avoid the crashing steps? Do you restart the app and keep working? Or do you put in some time and try and report the issue to the developer?

As a developer myself, detailed bug reports and active involvement in the bug report have been among the most valuable things in fixing bugs. As such, I can only highly recommend to send in bug reports whenever possible! Here is just some bug hunting story from last weeks.

Last week I opened the great video player VLC to playback some Opus audio file. Shortly after opening the application, it reported that there was a software update. I vaguely remembered that it already previously mentioned that, so I was a bit confused why I didn’t update then. Of course I accepted to download the new version and after 22% through the download process, VLC simply crashed. Aha! That’s why I didn’t update VLC last time. And indeed whenever you try to update VLC it would simply crash.

VLC Crash

I remembered back when ShareX didn’t update when you clicked on the auto-update message and also remembered that they put up a notice on their website to manually update it. Certainly a broken update function in a quite popular media player would have been reported by now and thus I checked the website. To my surprise however there was no notice and searching a bit further I couldn’t find a report either. So I took things to the VideoLAN IRC channel and quickly found some active user.

After some digging we found the debug nightly builds. With that in hand, I thought it would be very easy to get a stack trace of the crash, but because this was a nightly build, the update feature points to a test server and while it actually triggered an update to be run, the build to update to wasn’t available anymore and thus nothing happened.

My next idea was to simply spoof the update server and change the update information. Having Python installed on my system I could just run python -m http.server 80 and it would launch a web server that served the files in the working directory. Then I added the update server to my hosts file, placed the update text file in the web server’s directory and … VLC’s update feature now simply threw an error. Luckily the debug build also output a lot of useful information in the console, so I saw that the update tests a signature file. This security feature prevents exactly this kind of “attack” where the DNS is spoofed and the fake server serves a malicious update. Having a file with a PGP signature ensures that only the ones with the private key can provide binaries with matching signatures.

So the new plan was to simply take the update file for the latest release version and its signature file. Finally, VLC crashed and I could get the stack trace. With an impressive list of 1637 entries, it became clear that the crash must be some sort of infinite recursion, which fills up the stack and finally leads to the crash. Since the problem seems to occur around lots of Qt functions, it may end up being less of an VLC issue and more one of Qt. A report was filed and now the waiting game beings.

Critique

In my books having a broken update function seems quite critical, as your users won’t get any security updates anymore, but need to go to the website and manually update VLC and many will probably just disable auto-update to not receive that message anymore. As such the reaction so far have been too low for my liking and I’m surprised that nobody else has experienced this issue. Then again VLC is an open source software maintained by developers in their free time, so it’s not a surprise that things take a bit longer.

The fact that the update feature doesn’t work due to outdated files in the nightly/development builds is a bit concerning. If it can’t be tested easily, then it simply won’t be tested at all and bugs like the one mentioned won’t be found during development.

VLC’s automatic reporting system doesn’t work (anymore). The FTP server the reports gets send to, doesn’t seem to exist anymore. In the consumer market direct reports to the team like mine are quite rare, so an automatic crash report system should work, so you actually see in case VLC suddenly keeps crashing all around the world.

Summary

As a software user, report bugs whenever you can and include as much information as possible!

As a software developer, make sure your features can be tested and that debug builds/symbols are available to get more detailed information.

I wanted to write some more on how to report bugs, but this post has already turned into a longer one, so I’ll reserve that for a dedicated entry.

SFML 2.2 Released!

I’ve gotten rather quiet here on this blog, but I’d say it’s a good sign, because that way I could spend more time on helping get SFML where it is now. After nearly one and a half years SFML has finally reached version 2.2!

SFML

A lot in the SFML source code has changed, though I think the biggest change is not the source itself, but that SFML is now managed by the SFML Team and that with the team new guidelines had to be set in place. Laurent has maintained SFML for a long time alone with help from the community and Marco (aka Hirua) for the OS X parts, but with real life getting more and more time consuming the development slowly but steadily stagnated. Realizing that development was nearly at a stop, he placed Jan (aka Nexus or Bromeon) in charge. This worked relatively well, but the main issue wasn’t solved: SFML is a rather complex project by now and with so more and more users willing to use it, it becomes rather impossible for one person to do all the work, discussing on the forum, writing code for all modules, organizing issues, updating the website, etc. and with such a workload it becomes easy to deny many feature request and keep things as easy as possible. After I had started a discussion on Rethinking the definition of “Simple” we could clear many things and the solution was the birth of the SFML Team.

We all would’ve loved to release SFML 2.2 as fast as possible, but there were just too many issues piled up to go and release a new version, while a lot was still broken. We first wanted to implement multiple features, but then decided to focus on just the Window Focus feature and fixing many other issues. After 177 closed issues the 2.2 milestone has been closed the source code has been tagged. This can essentially be seen as the release, however for many you can only call it a full release if you also provide binaries and as of today, they are online:

» SFML Downloads

The website now also features Contribution Guidelines, a Code Style Guide, explanation on our new Git Workflow, the full Changelog with nice links to all the issues and nearly the most important page Frequently Asked Questions. The FAQ page already holds answers to many, many, many of the common problems which can arise with SFML and we as a team believe that it will reduce the amount of redundant questions and help all the new users advance faster. Next to these new pages we also added a button to the now official SFML IRC channel on irc.boxbox.org and made a lot of changes to the website in general.

With the Holidays coming up soon, there probably will be not that much development happening, but we already have a possible roadmap setup for SFML 2.3 and this time, we’ll make sure it won’t take as long anymore. Stay tuned and Happy Holidays!

Recursive Algorithm

Now that we’ve looked at what an algorithm is, we can go a bit deeper and take on one of the most common section of algorithms: Recursion

Recursive algorithms are actually quite easy to understand and we often use it intuitively in our daily life. Recursion only means, that a function calls itself. To illustrate things, we’ll be taking the calculation of the Fibbonaci numbers as an example. The following image shows the first few numbers and a mathematical definition:

So as you see the function f has one initial values for n = 0 and n = 1. For every other n, we call the function f recursively.
Since we as programmers are not that interested in the mathematical terms, here goes a very easy and straight forward implementation:

unsigned int f(unsigned int n)
{
    if(n == 0 || n == 1)
        return 1;
    else
        return f(n-1)+f(n-2);
}

As you see it nearly matches the mathematical definition after all. If we now were to test this function, we’d soon notice how long it takes to figure out for example n = 50. So how do we make it faster? To answer that question, we’ll first have to take a look at why the algorithm is so slow and for that we need to take a closer look at how applications work in general.

Every application gets a memory area with fixed size, aka as stack, on which it does all its local operations. For every recursion we’re making, all the currently active variables, states, etc. have to be saved onto the stack and only then the “content” for the new function will be loaded. Doing this a few thousand times will crush your performance and can essentially even lead to stack overflows, which means your application will crash.

One way to fix this, is to trade some memory for performance. The main problem of the recursive algorithm is, that it will calculate the same number over and over again. You’ll end up with a tree which is built with the same sub-trees all over again:

With the acquired knowledge we can turn the whole algorithm around and instead of starting at the top, we start at the bottom, save every result in between and then apply the formula for n+1. Now we can immediately look up what the result for any n-i is, we only had to calculate it once and we don’t need to recursively call the function.

#include <vector>

unsigned int f(unsigned int n)
{
    std::vector<unsigned int> mem(n+1, 0);

    mem[0] = 1;
    mem[1] = 1;

    for(unsigned int i = 2; i < n+1; ++i)
        mem[i] = mem[i-1] + mem[i-2];

    return mem[n];
}

You can obviously also use an array if you’d like, but I prefer to use modern containers, which should also assert for out of bound mistakes. The pre-allocation of the vector will give us a bit a better performance due to the fact that, vector won’t have to resize itself while inserting new numbers, but in comparison to the recursive algorithm this won’t be noticeable anyways.

Although this might seem to have worked just for this specific case, the used principles can be applied to quite a few recursive algorithms and is called memoization (no it’s not memorization). Here are the steps again:

  1. Find the recursive formula.
  2. Implement a straight forward algorithm.
  3. Bottom-Up the algorithm and ‘memo(r)ize’ all the steps.

Keep in mind though, that this method is just one way to optimize algorithms and that it might work for other problems, but not be the best way to do it.

I hope my article wasn’t too unstructured and confusing, but gave you some insight or refreshment on that topic.
A complete example with benchmarking can be found on GitHub.

What are Algorithms?

Although I guess most of you know exactly what an algorithm is, I felt anyways that I needed to give a small definition, before I’ll be able to cover specific (types) of algorithms.

When dealing with problems in computer science one generally looks at the ‘theory’ behind solving the problem and the actual implementation separately. Thus an algorithm can informally be defined as the way/idea on how to solve a certain problem, but it often won’t contain an actual implementation to keep a very general layer.

A formal definition of what an algorithm is, can be quite philosophical and complex and is only needed, if you for example have to prove that there doesn’t exist an algorithm for a given problem. Anyways I won’t be going any deeper on that topic and I often won’t stay very general and will give C++ implementations to most of the algorithms.

The course at the university is in fact called “Algorithm and Datastructures”, thus you can imagine that I’ll be also looking at different datastructures. In essence are datastructures also algorithm; they solve the problem of efficiently storing and retrieving data and make use of various other algorithms for their implementation (i.e. a heap sorts its node in a certain way, as describe by an algorithm).

All in all not a very interesting or in-depth article, but it seemed important anyways. Of course if you’re all about knowledge go read the Wikipedia article and start click your way from there into the wildness of the internet.

Stay tuned for further updates! 🙂

Website Update & Announcement

If you’re reading this on the actual blog website and not through RSS or similar, then you might have already noticed, that I’ve changed the WordPress design. Although I really liked the old one, it has some troubles with the titles and lacked a clean separation between the posts. The current theme ‘Emire’ hasn’t been modified in any way, but I might add a custom header in the future.

In addition to the new theme I’ve also added a new plugin, which allows you to share my posts with the two-step share buttons. So you won’t get tracked by Google or Facebook, but still got the ability to share it directly from my posts. Strange enough the buttons don’t appear always (like when I’m logged in), so I’m not sure if everyone will be able to see them.

As for the announcement part, I’ll be starting a series of posts related to various computer science topics. There isn’t a fixed plan or any greater goal, but I just want to recycle the stuff I’m learning at the university and having to rephrase everything in my own words, seems like a good way to let it sink in and got the additional benefit of sharing knowledge with others. If you’re interested in a specific topic, let me know in the comments/e-mail/Twitter and I’ll see what I can do about it.