Monthly Archives: December 2016



First, a wrap-up of the last Quiztime. For an excellent explanation of the issue, read this comment. Also note that this is not the most nice way to do plugins with C++, it’s a boiled down piece of code I debugged.


I’m not sure if there is some confusion about the current development model of Shotwell. I noticed that some distributions seem to try to pick up the current development branch (0.25.x). I strongly advise against that at this point in time. It has just seen a major change in the Menu handling code and might still have severe usability regressions.

While I appreciate any testing of the code, I would really not have the current unstable version of Shotwell stuck in a released distribution. If you want to try those releases on Ubuntu, there is an unstable PPA available.

So to sum up: Shotwell follows the “traditional” version scheme of “Odd is unstable, even is stable” and roughly tries to stick to the GNOME release schedule.

Quiztime II

So, following up from the last quiztime which was about the importance of explicit linking, another case from the wonderful world of shared libraries.

This time we study the implications of dlopen, its parameters and C++. Consider the program and module below. If you run that, it will crash somewhat obscurely in libstdc++. Why?

#0  0x00007f687b2eb126 in std::ostream::sentry::sentry(std::ostream&) () from /usr/lib/x86_64-linux-gnu/
#1  0x00007f687b2eb889 in std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, long) () from /usr/lib/x86_64-linux-gnu/
#2  0x00007f687b2ebd57 in std::basic_ostream >& std::operator< <  >(std::basic_ostream >&, char const*) () from /usr/lib/x86_64-linux-gnu/
#3  0x00007f687a6f01a0 in Impl::print (this=0x558a9bc1f2e0, str="Hello") at
#4  0x0000558a99de3d1b in main (argc=1, argv=0x7ffca28cf538) at
#include <string>
class IInterface {
        virtual ~IInterface() {};
        virtual void print(const std::string& str) = 0;
#endif // INTERFACE_H
#include "interface.h"
#include <iostream>
class Impl : public IInterface {
        virtual ~Impl();
        void print(const std::string& str);
extern "C" {
void *entry_point(void)
    return new Impl;
Impl::Impl() {};
Impl::~Impl() {};
void Impl::print(const std::string& str)
    std::cerr < <"Some text to print\n";
    std::cerr << "Got passed this: " << str << "\n";
    std::cerr << "=====\n";
#include <dlfcn .h>
#include <iostream>
#include "interface.h"
extern "C" {
typedef void *(*EntryFunction)(void);
int main(int argc, char *argv[])
    IInterface *iface;
    EntryFunction f;
    void *lib = dlopen("./", RTLD_NOW | RTLD_DEEPBIND);
    if (lib == nullptr) {
        std::cerr < < dlerror () << "\n";
        return 1;
    f = (EntryFunction) dlsym (lib, "entry_point");
    if (f == nullptr) {
        std::cerr << dlerror () << "\n";
        return 1;
    iface = reinterpret_cast<IInterface *>(f());
    while (true) {
        iface->print ("Hello");
.PHONY: all clean
all: main
	rm -f main
	rm -f
	g++ -g -o $@ $< -ldl
	g++ -g -o $@ -shared $< -fPIC