Thoughts on Investing in Bitcoin and other Crypto-Currencies

About two years ago I became interested in Bitcoin and the underlying blockchain technology. At the time, it was mostly tech and finance circles discussing their potential.

Today, it seems everybody is talking about it. As the price of Bitcoin has soared even mainstream media feel they need to report on it.

Is it a bubble?

Earlier this year, I figured that simply being interesting in crypto-currencies wasn’t enough. In order to talk about it credibly, I wanted to be more invested in it (literally). So I decided a take a few hundred Euros to buy small mounts of Bitcoin, Ether and Ripple, even though they had already increased quite substantially in previous months. I reasoned, if the bubble burst, the financial loss would be bearable, but if it increased ten-fold, I would turn a nice profit. Either outcome seemed equally likely then.

Of all the crypto-currencies out there, I chose these three, because

  1. Bitcoin was (and still is) the most popular and thus in my mind has the largest chances of being driven up by speculators.
  2. Ether is the value token of the Ethereum smart-contract platform, which is a technology I thought had a lot of promise as the building blocks of many digital innovations yet to come.
  3. Ripple is different from other crypto-currencies in that it was not really competing with existing currencies and the banking system, but rather complementing them. In my opinion, it also neatly solves a few of the issues in other real-time gross settlement systems, such as the complexity of managing standard settlement instructions (SSIs).

When to get out?

Initially, my investments languished. But particularly in these last few weeks, interest in crypto-currencies has spiked and I suppose, as the rise in Bitcoin has people looking for alternatives, Ether and Ripple have been driven up as well.

Thus, my investments in Bitcoin and Ripple have now increased four- to five-fold (Ether a little less). Naturally, no one knows when this is going to end (but end it must, I believe). So I decided to limit my down-side risk and sell about a fourth or a fifth of my stake in Bitcoin and Ripple.

This way, I’ve fully recouped my initial investment, but still have hundreds of Euros worth of crypto-currency left. Now, a couple of days later, Bitcoin has continued to appreciate, but I am not worried about the money I did not make by selling early. I can now sit back relaxed, knowing that I cannot lose anything, but still have a lot to gain as I watch the crypto-currency story unfold and hopefully realize its full potential.

Should I invest?

I don’t give investment advice. Not in real life and particularly not on the internet.

But whenever you need to ask someone, whether something is a good idea, you obviously don’t know enough about it to make an informed decision for yourself.

Advertisements

Hiking in Heimbach (Eifel)

As there were two holidays last week, I decided to get out of town to take a short vacation in Heimbach (Eifel) for some hiking. The Eifel is only two hours away by train, but you feel so much closer to nature around all the forests and lakes.

Burg Hengebach

Burg Hengebach mit Brücke

The landscape is dominated by various reservoirs and dams, most notably the Rur dam. Below the view from the Hirschley atop the Kermeter onto the Rur lake.

Hirschley Panorama

Rursee

More reservoirs downstream from the Rur dam.

Stauanlage Heimbach

Rurtalsperre

The Art Nouveau hydro-electric power plant in Heimbach.

Jugendstilkraftwerk

Vitra Architecture Tour

On the last day of my Obereggenen vacation, we went to Vitra in Weil am Rhein. They are a maker of designer furniture, show-casing some of their offerings in this stylish building.

Vitra Alice in Wonderland

Vitra Haus

As part of their architecture tour we got to see their production facilities where almost every building has been designed by famous architects; e.g. passage cover by Álvaro Siza and fire station by Zaha Hadid.

Vitra Überdachung

Vitra Fire Station

Vitra Zelt

Vitra Zeltdach

Vitra Bank

The Case of a Delphi Application hanging in ExitProcess

A colleague came to me with a Delphi application that would not shut down, but just hang. The application in question had been refactored such that one module was extracted into a DLL to be reused in another application. When this extracted module was loaded into the application and the application was closed, it would hang. If the module was not loaded, the application would shut down normally.

Analysis

Debugging the application was initially unsuccessful. Stepping through our code we verified that the shutdown logic executed normally with destructors running as expected. Interestingly, it was not possible to break into the application once it had become unresponsive. Trying to pause the hung program from within the IDE would simply cause the IDE to hang as well.

Thus we used Process Explorer instead to look at the application’s threads and their callstacks.

There we saw that there was one thread stuck on a call to WaitForSingleObject which originated in our DLL code. Higher up the callstack was ExitProcess. I looked at the documentation for ExitProcess to see look for ways in which it could deadlock. One sentence looked promising: “If one of the terminated threads in the process holds a lock and the DLL detach code in one of the loaded DLLs attempts to acquire the same lock, then calling ExitProcess results in a deadlock.” But since there was only one thread, this could not be it.

Looking next at what happens exactly inside ExitProcess, two other things jumped at me:

  • All threads are terminated (except for the one calling ExitProcess).
  • All DLLs are unloaded.

Cause

It turns out, the initial analysis that “the shutdown logic executed normally” was wrong. One of the shared units compiled into the DLL (through several layers of indirections), had a finalization section. In this finalization section, a background thread that had been created in the corresponding initialization section, was being destroyed. As part of the destructor code, the thread class was waiting for an event that was set when the thread had stopped executing.

Holzscheite (4)

This finalization section was running as part of the “all DLLs are unloaded” step by ExitProcess. Unfortunately, all threads (including the one created in the initialization) had already been terminated. I am not quite sure how that was accomplished, but it apparently circumvented the normal thread termination logic which set the event that the thread had stopped executing.

This is different for code in the main application, where finalization sections are run while the application is still in working order.

Solution

Instead of waiting for the thread to set its “stopped executing” event, I wait on the thread handle to check if the thread was even there to set the event. When run from the DLL’s finalization section, this detects the thread’s absence and just returns.