RSSAmplifier

Blog

Rambles around computer science

Diverting trains of thought, wasting precious time

humprog.orgRSS feed ↗40 posts

Latest posts

System call instrumentation on Linux/x86-64 using memory-indirect calls (in vain?), part two

In my last post I identified some approaches to system call instrumentation on x86-64 Linux that combine instruction punning with the memory-indirect call and (most eccentrically) lcall (“far call”) instructions. I mentioned these have some interesting differences with the direct relative jmp or register-indirect call used by straightforward instruction punning or zpoline approaches.…

IFIP foray

This is really a meta-level post... after attending two meetings as a visitor, most recently in Santiago, Chile, I was recently invited to join the IFIP working group on programming language design (2.16) . Essentially this is a collection of researchers, mostly academics but not entirely, who meet retreat-style for a week every year to discuss, roughly, their programming-language-flavoured…

Universities: is bigger better?

In the news recently have been the plans for acquisition of Cranfield University by King's College London. Although “merger” is the official word, it is rather misleading given the relative sizes and balance sheets of the institutions. Under the proposed post-merger arrangement, it appears that Cranfield will be swallowed up organisationally, its name used only for brand continuity.…

System call instrumentation on Linux/x86-64 using memory-indirect calls (in vain?), part one

My libsystrap library provides a simple instrumentation of system calls in Linux x86-64 userland. However, its current implementation suffers a double-trap overhead: system calls become ud2 , which generates a SIGILL trap. Then we run the system call itself from within the signal handler, causing a second trap and some interesting tricky cases . There has been some interesting research in this…

System call stack alignment

[Quick new post... it's June and I'm emerging from my academic season, so hopefully lots of new content will appear here over the rest of the year.] Recently, in one of my exam-season “procrastination projects” (about which more anon), I found myself with a simple enough question. What stack pointer alignment is required when making a system call on Linux on x86-64? You'd think this'd…

Enabling monoglot programming

&ldquo;Polyglot programming&rdquo; is a wrong metaphor. It's taken me about fifteen years to realise this. In his keynote at <Programming> back in June last year, Thomas Wuerthinger made an intriguing comment, something like &ldquo;people don't actually like polyglot programming, because programming in one language is hard enough already&rdquo;. He was talking about GraalVM and the considerable…

Support for Stephen (to be measured out in coffee spoons?)

You can now crowdfund me! As I mooted a while back, I have gone part-time on my academic job and am exploring new ways to help get my research done. In fact I have created a standing page about this, so the rest of this post just consists of what it currently says! I may tweak things as we go along, so do check the standing page if you are reading this in the future. As of November 2025 I am…

Reversing abstractions: an existential crisis

Computer science in general, and language implementation in particular, are founded on the idea of realising abstractions in a way I'll call &ldquo;forwards&rdquo; and also &ldquo;existential&rdquo;. This post is about how these aren't the only way to think about programming infrastructure and abstractions. The theory goes that you pick some desired abstraction&mdash;it could be a programming…

The art of appearing research-productive as an academic

(It's not an art like &ldquo;fine art&rdquo;, or even like motorcycle maintenance. It's more like &ldquo;being artful&rdquo;.) I'm always working pretty hard on my research. I like to think I have a plan, am tackling important problems, and in at least vaguely fruitful ways. So why does my &ldquo;research output&rdquo; always seem lacking, at least from the bean-counters' point of view? Partly,…

Academic promotion in the time of (arguable) underfunding

A brief recent conversation with some non-academic friends reminded me that promotion in the academic world is already strange. Firstly, promotions are applied for, in a process that is a bit like re-applying for your job, i.e. quite tedious, and is usually an annual exercise (in the institutions I've experienced). Secondly, when you get promoted, you have near-enough* exactly the same job. You…

Software substrates: should there be only one?

I apologise for the slightly provocative title... of course it depends on what &ldquo;substrate&rdquo; means. To date it seems to be a word people like to use, either in spite of or (more likely) because of its diversity of possible meanings. Still, back in June I took part in a fun workshop on this topic of &ldquo;software substrates&rdquo;. My position statement had been written hastily in a…

Interposing on <tt>clone()</tt> system calls in-process, from Linux userspace

I've written before about a simple user-space approach to intercepting and modifying system calls , by turning system calls into SIGILL and then executing the perhaps-modified system call in the signal handler. I also mentioned that handling clone() , Linux's system call for creating a new thread, is challenging in this context. Let's imagine we want our handler firstly to print out a message,…

Management hierarchy in academic research

In 2020, Simon Peyton Jones gave an &ldquo;Ask Me Anything&rdquo; session at (virtual) PLDI , in which he made a throwaway remark something like this. &ldquo;I've recently achieved a life goal: I turned 60 and still have nobody who reports to me!&rdquo; In other words, he doesn't manage anyone and he's happy about that. I'm sure I'm not the only researcher with whom this resonated. It seems pretty…

Top of the slops

The cartoonist Dick Guindon famously wrote as follows. Writing is nature's way of letting you know how sloppy your thinking is. The number 1 prefixing that is my addition. Programmers and sometime-mathematicians also know that there are further stages of the same idea. Programming is nature's way of letting you know how sloppy your writing is. Mathematical proof is nature's way of letting you know…

Writing a preloadable <tt>malloc</tt> in Rust, using MMTk

[Obligatory banner-esque note: between now and August-ish I'm prospecting for crowdfunding that might support my research and writing in the future, as I move to being only a part-time academic. Read more in my earlier post , or you can directly drop me a no-commitment HTML form submission if you think you might be able to contribute, or e-mail me . Thanks so much to everyone who has done so…

Ross remembered

[It's over a year since we lost Ross Anderson . Last month I very much appreciated the RossFest event organised in his memory. So it's about time I posted the following reminiscences, most of which I wrote pretty soon after he died.] Although Ross lectured me when I was an undergraduate, and did so very memorably, our first interactions came when I'd joined the Lab. We would both frequent the…

A more punny self-remaking C program

To follow on from my previous proof-of-concept and later musings , here's another form of self-remaking C program in one file. This one involves some shell code that generates C code, to be included, using some punning a bit similar to my shell-and-Make one-filer . ///usr/bin/[ " 0".bin -nt " 0" ] || cc -save-temps -g " 0" -o " 0".bin <<EOSHELL || exit 1; exec " 0".bin " @"; exit 42 #ifdef EOSHELL…

The mess I'm in

[TL;DR: I'm starting to suspect my work is incompatible with holding a full-time academic job at a present-day university, at least in the UK. I plan to drop my academic duties to some part-time percentage, to make time to pursue projects I care about and for other income streams. That could be contracting, but could also be crowdfunding from supporters. A little support could free me up to do…

Is your CS department serious?

I've found myself using &ldquo;serious&rdquo; as a mental shorthand for what I recognise as &ldquo;things done right&rdquo; in an academic department, which in my case means computer science (CS) departments. I thought it would be interesting to make a list of these things, so here it is. They are somewhat subjective. Also, they are a function not only of organisational maturity and wisdom, but…

Self-rebuilding programs done slightly better

Over on the development side of the blog, I recently wrote a throwaway hacky hash-bang recipe for making a single-file C source program executable and self-rebuilding . I've recently done what I think is slightly better, by dispensing with a hash-bang line entirely, in favour of what I call a &ldquo;slash-slash line&rdquo;. //usr/bin/[ " 0".bin -nt " 0" ] || cc -g " 0" -o " 0".bin || exit 1; exec…

A tiny self-remaking C program

In my last post I floated the idea of writing a slow, edit-prone shell script instead as a self-rebuilding C program. Just for fun, here is the briefest way I've found to make a one-file C program self-rebuilding. Note that it only works given an env that implements the -S option. That includes the env in GNU Coreutils 8.30 or above, and (so I'm told) FreeBSD's. So regard it as a total hack not…

How to really wrap a C compiler and preprocessor, really*

* really Suppose we want to interfere with how a vaguely Unix-style C compiler does its job, and that we want to try compiling existing software with this modified compiler. Assuming the build system will let us do something like: CC=/path/to/my/wrapper make or CC=/path/to/my/wrapper ./configure && make ... then we'd like something that is a drop-in replacement at the command-line level. Let's…

How to &ldquo;make&rdquo; a shell script

This post is about the following strange program I wrote recently. dummy=; define () { true; } define dummy echo "Hello from shell; PATH is ${PATH}" return 0 2>/dev/null || exit 0 endef .PHONY: say-hello say-hello: @echo "Hello from make; makevar PATH is $(PATH), envvar PATH is $${PATH}" One of my guilty secrets is that &lsquo;make&rsquo; is one of my favourite programming languages. It has…

A process by any other name

On Linux, what is a process's name? I've found this to be more complicated than I thought it would be. Clearly it's non-trivial because it seems top and ps can disagree about a process's name. As usual I have Firefox and some of its worker processes cheerfully burning some CPU for no apparent reason, so let's use one of those. top - 14:53:48 up 5 days, 3:20, 28 users, load average: 0.47, 0.82,…

Teaching loads in computer science: it's not just lectures

About four years ago, when I had spent a year at the University of Kent in my first job as a lecturer (or &ldquo;Assistant Professor&rdquo; for North American-style readers), I had to fill in a probation review form. One question asked me to reflect on my teaching load over the previous year, which had consisted of 1.4 courses or &ldquo;modules&rdquo;. One module lasts for a 12-week teaching term,…

Interoperability: what's rich is still poor

Is there good interoperability with C from C++? I could have named any two languages, and for most pairs the answer would be a clear &ldquo;no&rdquo;. But in the case of working with C code from C++, the situation is a lot better than normal. In this post I'll observe why it's still not good, via the lens of a particular programming task I carried out recently. I'll end with some notes on what I…

Understanding C99 inlines

For a long time I struggled to remember the rules for using inline in C. I think I've cracked it now, though. As often with C, the trick is to think about how it's implemented. It doesn't help that in C++, the programmer-facing semantics of inline are much more straightforward. If you want to hint that a function should be inlined, put inline (or, for a member function, define it within its…

How to do link-time symbol wrapping... as a plugin

I wrote recently about the problems with link-time symbol wrapping using the --wrap option to GNU linkers and similar. In short, references don't get wrapped in some cases when they arguably should, if definition and use are in the same file. But there is another way, using symbol replacement, that can do such wrapping if we're careful about self-references and the like. I've now created a plugin…

How and why to do link-time symbol wrapping (or not?)

It's sometimes useful to hook functions at link time. On ELF platforms (among others) a GNU-style linker offers the --wrap option which seems to be exactly what we want. --wrap=symbol Use a wrapper function for symbol. Any undefined reference to symbol will be resolved to "__wrap_symbol". Any undefined reference to "__real_symbol" will be resolved to symbol. Unfortunately there are several…

Anti-prosperity in the UK, part one

(I thought about calling this &ldquo;Never Mind the Bullshit Jobs&rdquo;... but that would apply better to a future part.) Various rhetoric about government-funded academic research here in the UK seems increasingly to use the word &ldquo;prosperity&rdquo;. For me this has become a major red flag. Despite the positive-sounding line that &ldquo;prosperity&rdquo; exists as an easily recognised and…

De-escalating the submission backlog

About two and a half years ago, I submitted a two-page abstract entitled &ldquo;De-escalating software: counterproductivity versus conviviality&rdquo; to the conference on History and Philosophy of Computation (HaPoC) , proposing a talk the philosophy of Ivan Illich interpreted in the domain of software. I had already given a couple of experimental talks about it that appeared to be well-received.…

(Tell me why) I don't like funding {applications, bodies, policies}

I was recently successful in my first non-trivial grant application, for a New Investigator Award from EPSRC . Great! Well, sort of. It's great because it will hopefully enable a talented person (who isn't me) to spend a few years doing some interesting research. In other ways, it's not so great. I have been grimacing at every well-meaning &ldquo;congratulation&rdquo; I've received. The process is…

ELF dynamic linking: a brief introduction

[I wrote this to help current or future students who might want to do projects involving dynamic linking. But it may be of interest more widely. There may well be an equivalent or better article out there; if anyone knows one, please let me know.] In old-fashioned static linking, the executable file captures a complete starting &ldquo;memory image&rdquo; of the program being loaded. The kernel…

Tracing system calls in-process, using a chain loader

Some months back I wrote about a possible better alternative to LD_PRELOAD using chain loading. And I promised a follow-up with more details... so here it is. We'll walk through a little system call tracer built using this technique. Unlike strace and similar, it will do its tracing in-process , without using ptrace() or equivalents. I should add that it's a proof-of-concept only so isn't nearly…

No more Dr Nice Guy

[I wrote this back in April, at a point when my time at Kent was drawing to a close and the overload factor had been high for a long time. My current situation at King's is radically different! Whether that will last is less clear.] As a graph theorist might put it, my in-degree is too high. My time and (especially) head-space are scarce resources. Access to me needs to be limited. Ironically, it…

Role again

Sorry for the pun. Yes, it's supposed to be about rolling the dice. I've recently(-ish) handed in my notice here at the University of Kent. In July I'll be starting a new job (the same job, but) at King's College London. The reasons for the move are primarily personal. Of course, that doesn't mean they are unrelated to work... in academic jobs especially, work is personal. The move is not a…

Career thoughts on academia, industry and points in between

In early 2018 I was at a crossroads in my career: academia, industrial research, or somehow go it alone? I was a postdoctoral researcher at the University of Cambridge, but feeling some pressures to move on. This post is a (somewhat edited) time capsule containing some notes-to-self I made about that decision. What happened is &ldquo;history&rdquo;, of course: I became an academic at the…

Chain loading, not preloading: the dynamic linker as a virtualization vector

Suppose you want to run a pre-existing binary program but in some kind of instrumented or modified form. On ELF-based systems, people often do this with LD_PRELOAD: you preload a library that interferes with some C library calls or somehow tweaks the process state at startup (say to install a signal handler). The program itself is (hopefully) oblivious to what you've done, but its behaviour is…

Building a simple toolchain extension, the subversive way

I recently ran into a nasty problem, arguably a bug , in GCC. I decided to write a little tool to help me detect when I'm triggering this bug. This post is about how I did that, using some simple but handy helper scripts I've been growing for a while. The bug is to do with &ldquo;constructor&rdquo; functions in GNU C (not to be confused with C++ constructors!). I'll quote from my bug report,…

Mission and marketing in computer science degrees

At lunch with colleagues some months ago (remember those days?), I provocatively suggested that our course offering would be improved if we eliminated marketing terms from the names and specifications of our taught programmes and modules . Depending on exactly what counts as a marketing term, this might mean doing away with &ldquo;cybersecurity&rdquo;, &ldquo;Internet of things&rdquo;,…