Hi there! My name is Adrian Kummerländer and I am a software developer currently studying mathematics in Karlsruhe. On these pages you will find blog articles covering amongst other topics some of my experiences in software development, open source and self hosting as well as repositories and information on some of my personal projects. If you have any comments or questions feel free to reach out. I hope you will find something here worth your time.

» Visualisierung von Metriken in Voronoi-Diagrammen

May 22, 2016 | Adrian Kummerländer

In der Analysis 2 Vorlesung meines Mathematik Studiums beschäftigen wir uns derzeit mit Normen und Metriken in endlich dimensionalen Vektorräumen, welche wiederum die Grundlage für die Übertragung der, aus Analysis 1 bekannten, Konvergenz und Stetigkeitsbegriffe in höhere Dimensionen schaffen. Während der Bearbeitung der entsprechenden Übungsblätter habe ich dabei nach Visualisierungsmöglichkeiten recherchiert, um eine bessere Intuition für diese Begriffe zu erlangen. Voronoi-Diagramme sind eine solche Möglichkeit, deren Grundlagen und Generierung ich in diesem Artikel zwischen Theorie und Praxis näher erläutern möchte.

» Notes on function interposition in C++

February 21, 2016 | Adrian Kummerländer

To counterbalance the vastly increased amount of time I am spending on purely theoretical topics since I started studying mathematics, my most recent leisure time project was to familiarize myself with function interposition in C++ on Linux. This article will document some of the ins and outs of using this technique in an actual project in addition to describing how the acquisition of the interposed function’s pointer may be reasonably abstracted by a function template.

» The joys of IPv6

September 24, 2015 | Adrian Kummerländer

A couple of weeks ago I moved to Karlsruhe where I will study Mathematics starting this fall. Among other things this meant that I had to search for an Internet provider for my new appartment. Previously I used a DSL connection by Telekom which offered nothing to complain about if one disregards the abysmal bandwidth available in my small home village in southern Germany. Luckily my new appartment offers the option of accessing the Internet via TV-cable instead of POTS which promises a better connection bandwidth than DSL even in the city. As my new provider uses a special kind of dual stack system I was finally confronted with IPv6 and want to summarize my experiences in this article.

» Implement support of server side math expression rendering

May 4, 2016 at 21:39 | blog.kummerlaender.eu | 67162f | Adrian Kummerlaender

Many websites employ the MathJax library for dynamically rendering LaTeX math expressions on the client side. I expect to require support for doing just that in the future. But as with syntax highlighting I am of the opinion that this kind of stuff should be performed once during site compilation instead of wasting ressources by forcing each client to do this job for every single page request.

Luckily there is a MathJax-node module that allows using the MathJax library on the server side.

This commit adds support for rendering math expressions written in Markdown respectively LaTeX as follows: $$1 + 1 \neq 0$$ on the server side.

This required the introduction of a new math_highlighter helper template in formatter.xsl based on the tex2html utility provided by MathJax-node. This formatter is matched against the (Markdown parser generated) script node in formatter.xsl’s embellish mode. The HTML rendering of the expression is then embedded in a p class="math" node. This explicit labeling allows master.xsl to include the math.css rules only for pages that actually contain math expressions.

Note that the XHTML rendering utility stylesheet xhtml.xsl currently adds a XML comment to each span node. This is a workaround to prevent Xalan from collapsing “empty” span tag pairs into single nodes which otherwise leads to rendering errors as it is not valid HTML and is interpreted as a wrong tree structure by the browser.

Note that the CSS rules declared in math.css are explicitly not part of the MIT licensed part of this repository but where generated by MathJax.

As there is currently no productive content making use of math expressions a demo page is available under page/math_test/.

» Interpose `open` library function

February 20, 2016 at 21:30 | change | b3ef0f | Adrian Kummerlaender

open is not as side effect free as I had imagined - i.e. if the flag O_TRUNC is passed it truncates the file contents alongside opening the file descriptor. In practice this is done by emacs prior to writing the new file content and as such needs to be intercepted so we can start tracking the file before it is changed.

Interposing open required some changes to make the library work without including fcntl.h. This header not only defines some of the flags we require to check if a library call actually is able to change files but also defines the open library function.

While implementing this change I noticed that the function interpositions implemented in C++ actually need to be declared as external "C" so their names do not get wrangled during compilation. I suspect that this was previously implicitly done for e.g. mmap and write by the included C standard library headers. However this did not work for open which is why all function interpositions are now explicitly declared external.

End result: emacs file changes are now tracked correctly.

» Implement static allocator for initialization

February 17, 2016 at 14:02 | change | af756d | Adrian Kummerlaender

The previous interposition logic based on plain usage of dlsym analogously to various online examples led to a deadlock during neovim startup. This deadlock was caused by neovim’s custom memory allocation library jemalloc because it calls mmap during its initialization phase. The problem with calling mmap during initialization is that this already leads to executing libChangeLog’s mmap version whoes static actual_mmap function pointer is not initialized at this point in time. This is detected and leads to a call to dlsym to remedy this situation. Sadly dlsym in turn requires memory allocation using calloc which leads us back to initializing jemalloc and as such to a deadlock.

I first saw this as a bug in jemalloc which seemed to be confirmed by a short search in my search engine of choice. This prompted me to create an appropriate bug report which was dismissed as a problem in the way mmap was interposed and not as a bug in the library. Thus it seems to be accepted practice that it is not the responsibility of a custom memory allocator to cater to the initialization needs of other libraries relying on function interposition. This is of course a valid position as the whole issue is a kind of chicken and egg problem where both sides can be argued.

To cut to the chase I was left with the only option of working around this deadlock by adapting libChangeLog to call dlsym without relying on the wrapped application’s memory allocator of choice. The most straight forward way to do this is to provide another custom memory allocator alongside the payload function interpositions of mmap and friends.

init/alloc.cc implements such a selectively transparent memory allocator that offers a small static buffer for usage in the context of executing dlsym.The choice between forwarding memory allocation requests to the wrapped application’s allocator and using the static buffer is governed by init::dlsymContext. This tiny helper class maintains an dlsym_level counter by posing as a scope guard.

The end result of this extension to libChangeLog is that it now also works with applications using jemalloc such as neovim and should overall be much more robust during its initialization phase.

» Implement support for excluding arbitrary paths from tracking

February 14, 2016 at 19:52 | change | 1ffaf3 | Adrian Kummerlaender

The library may be provided with a new-line separated list of regular expressions via the newly introduced CHANGE_LOG_IGNORE_PATTERN_PATH.

Any proposed tracking path that is matched by any of the provided patterns is excluded from change reporting. This functionality uses the Standard’s regular expression parsing functionality and as such doesn’t introduce any new dependencies. If no file path is provided or the provided file path is unreadable all paths will be tracked.

change was adapted to set CHANGE_LOG_IGNORE_PATTERN_PATH to .change_log_ignore which means that it will by default exclude any patterns provided via this file in the current working directory.

An example for such a file customized for hiding vim’s internal write logic may look as follows:

[0-9]+
[^~]*~
[.*\.viminfo
.*\.swp

Note that this is implemented in a fashion where it is not guaranteed that the full canonical path is checked against the patterns. It remains to be decided if this is enough for all common use cases of this new functionality.

tracking::PathMatcher lacks any explicit thread synchronization - according to my current knowledge this should not be necessary as we are only ever reading the private std::vector<std::regex> instance. If invalid regular expressions are provided they are silently ignored.

» Delay tracking activation

February 11, 2016 at 17:43 | change | 7582ab | Adrian Kummerlaender

Introduce global static enabled variable used to signal the interposed functions to either start tracking or perform plain forwarding without any additional logic. This is required as e.g. nvim crashed when wrapped in libChangeLog because it called interposed functions during library initialization.

» Add initial working directory to settings handler

December 12, 2015 at 22:31 | MetaTerm | e3f734 | Adrian Kummerlaender

In addition to increasing customizability this change makes it clear that the working directory property only concerns the intial working directory and is not updated if the contained process changes its directory.

Note that setting the intial working directory is broken in upstream QMLTermWidget and the appropriate patch 1 is not merged at the time of this commit.

» Reimplemented `kill` command using actual signal sending

September 4, 2015 at 20:05 | MetaTerm | 52dd09 | Adrian Kummerlaender

Previously kill merely destroyed the terminal widget. This is contrary to the expected notion of kill, i.e. actually killing the process explicitly instead of relying on side effects.

The normal mode d verb now explicitly destroys the current item’s content, be it a terminal widget or a history view.

» Prevent visual selection change on `kill` command

August 30, 2015 at 16:41 | MetaTerm | e5a3db | Adrian Kummerlaender

TerminalItem’s reset member method wrongly performed a visual selection change which led to inconsistency when calling kill on a non-selected index. Visual selection update is now performed on history view instantiation.

» Automatically destroy terminal when killed and display history

August 29, 2015 at 20:12 | MetaTerm | 0dd495 | Adrian Kummerlaender

Child processes of MetaTerm may be terminated using other ways that the integrated kill command. Automatic terminal widget destruction in such a event prevents the user from viewing the output of non-interactive applications. This requires MetaTerm to display the application’s output after it was terminated. This requirement is implemented via the new HistoryViewer widget that is instantiated after the terminal widget instance has been destroyed.

» Extract all settings into `SettingsHandler` object

August 19, 2015 at 09:13 | MetaTerm | 4cb435 | Adrian Kummerlaender

This enables the user to straight forwardly change all application settings via command mode.

During the implementation of this change I discovered that the way I was passing around StateHandler and SettingsHandler instances using properties was unnecessary. If all object instances are created in a common hierarchy they can access each other by their id property - i.e. settings and mode are available to the whole application without property trickery.

» Restructure QML and JS sources

August 15, 2015 at 14:06 | MetaTerm | d84312 | Adrian Kummerlaender

list holds the components of the central list UI element. command holds the UI and implementation parts of the command mode. widget holds more or less general purpose elements that may also be of use in other circumstances.

» Changed token determination regarding identifier values

June 10, 2015 at 18:32 | SimpleParser | 0985a6 | Adrian Kummerlaender

» Implemented basic tape log printout in _Turing_ example

March 14, 2015 at 21:43 | TypeAsValue | 73be8f | Adrian Kummerlaender

» Changed `tav::Apply` implementation selection to template alias

March 7, 2015 at 15:14 | TypeAsValue | cb2a79 | Adrian Kummerlaender

» Renamed `Any` list query to `Every`

February 27, 2015 at 20:30 | TypeAsValue | 741e45 | Adrian Kummerlaender

» Enabled `Concatenate` to concatenate a variadic pack of lists

February 26, 2015 at 18:06 | TypeAsValue | 34530d | Adrian Kummerlaender