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, then to do the original clone(), and then return to the original caller (twice, naturally!). Since the...| Rambles around computer science
In 2020, Simon Peyton Jones gave an “Ask Me Anything” session at (virtual) PLDI, in which he made a throwaway remark something like this. “I've recently achieved a life goal: I turned 60 and still have nobody who reports to me!” 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 clear Simon didn't mean that he doesn't like working with people; he's a prolific collaborator. He also didn't me...| Rambles around computer science
Micro-blog and calendar| www.humprog.org
Rambles around computer science| www.humprog.org
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 how sloppy your programming is. Machine-checked proof is nature's way of letting you know how sl...| Rambles around computer science
[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 already! Also, moral support is support too, and is appreciated. :-)] I recently(-ish) spent a while on ...| Rambles around computer science
[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 “fishbowl” common room to read the newspapers there. This was probably 2006 or 2007. I was a green...| Rambles around computer science
[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 significantly more writing and programming—and thinking, more importantly. These are things I've s...| Rambles around computer science
I've found myself using “serious” as a mental shorthand for what I recognise as “things done right” 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 also of wealth and privilege. My current and past departments' achievement of them has been patchy. Failing at some...| Rambles around computer science
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 “slash-slash line”. //usr/bin/[ "$0".bin -nt "$0" ] || cc -g "$0" -o "$0".bin || exit 1; exec "$0".bin "$@"; exit 42 #include <stdio.h> int main(int argc, char **argv) { printf("Hello, world!\n"); ret...| Rambles around computer science
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 for serious use! Of course for a more portable version you can use #!/bin/sh and the self-extractin...| Rambles around computer science
* 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 also assume that our modifications are black-box: we want to do “what the stock compiler was doing...| Rambles around computer science
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 ‘make’ is one of my favourite programming languages. It has persistence and goal-driven incremental execution... so high-level! Although it is string-based, it has much l...| Rambles around computer science
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, 0.74 Tasks: 629 total, 1 running, 543 sleeping, 0 stopped, 4 zombie %Cpu(s): 1.9 us, 0.8 sy, 0.0 ni,...| Rambles around computer science
About four years ago, when I had spent a year at the University of Kent in my first job as a lecturer (or “Assistant Professor” 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 “modules”. One module lasts for a 12-week teaching term, with one reading week, and students typically take four modules at a time. I said that in my view, 1.4 modules h...| Rambles around computer science
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 “no”. 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 think good interoperability ought to mean. My task was writing some code to target a C-style plugin interf...| Rambles around computer science
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 class). inline int foo() { return 42; } // this is C++, not C! The toolchain takes care of the rest. Th...| Rambles around computer science
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 for the GNU BFD or gold linkers that implements, in effect, a command-line option for wrapping th...| Rambles around computer science
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 problems that arise when using this. In this post I'll cover some ways to solve these problems. Some of ...| Rambles around computer science
(I thought about calling this “Never Mind the Bullshit Jobs”... 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 “prosperity”. For me this has become a major red flag. Despite the positive-sounding line that “prosperity” exists as an easily recognised and obviously good thing, it is often invoked by interested parties attempting to whitewash issues that in fact are subtle and...| Rambles around computer science
About two and a half years ago, I submitted a two-page abstract entitled “De-escalating software: counterproductivity versus conviviality” 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 experimentaltalks about it that appeared to be well-received. The idea was to push myself into developing these ideas a bit more, as a waypoint to eventually publishing...| Rambles around computer science
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 “congratulation” I've received. The process is a horrible, contorted mess that makes me sad, angry and anxious. I hate it and it is literally making me ...| Rambles around computer science
[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 “memory image” of the program being loaded. The kernel simply maps the binary into memory, creates an initial thread stack, dumps some useful information onto it (...| Rambles around computer science
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 as good as strace in practice; in particular it can't yet accurately print the arguments to most s...| Rambles around computer science
[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 requires a certain amount of big-headedness to say this. Big-headed it may be, but failing to att...| Rambles around computer science
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 promotion. In terms of accumulating money and status, if anything it will probably slow me down. So, it...| Rambles around computer science
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 “history”, of course: I became an academic at the University of Kent. However, you wouldn't necessarily have predicted that from reading these notes. I'm still not ...| Rambles around computer science
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 modified accordingly. Some years back I saw a nice survey of applications in a presentation by Kevin...| Rambles around computer science
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 “constructor” functions in GNU C (not to be confused with C++ constructors!). I'll quote from my bug report, slightly edited. I was surprised to find that my __attribute__((constructor(101))) on a function was not giving...| Rambles around computer science
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 taughtprogrammes and modules. Depending on exactly what counts as a marketing term, this might mean doing away with “cybersecurity”, “Internet of things”, “cloud computing”, “big data” (thankfully not currently used here at Kent) and ideally also “artificial intelligence...| Rambles around computer science
[This post follows a previous post discussing changes to UK government research funding, which was itself a follow-up to my earlier “Postdoc myths” piece.] In my last post I finished by mentioning Alan Kay's favoured dictum that we should “fund people not projects”, and that this has reached the attention of Dominic Cummings in his plans to create an ARPA-like research agency for the UK. In fact the dictum is itself borrowed from J.C.R. Licklider, an early and influential divisional ...| Rambles around computer science
[I'm on strike again at the moment, just as when I wrote my last higher-ed piece, to which this is a follow-up.] My last higher-ed piece, about postdoc myths was read rather more widely than I expected. (Thanks for reading!) That has left me with a few things to clear up, and a few follow-up thoughts which I didn't get on to last time. Firstly, let me qualify: my take on postdoccing is more than a little UK-centric, and certainly doesn't generalise in all possible directions. However, I do be...| Rambles around computer science
[I'm on strike at the moment, largely in solidarity with my more precariously employed colleagues, whether hourly-paid or fixed-term or never-endingly “at risk of redundancy”. So it seemed a good time finally to finish and publish this post. I wrote most of it during the final couple of years of my seven as a postdoc, which ended in 2018.] Lots of things are said, written and believed about postdoctoral researchers that are simply not true. This matters because real policies, initiatives,...| Rambles around computer science
Like many academics, I travel quite a lot. I'd rather do so in a way that is environmentally sustainable. Most conferences I travel to are sponsored by ACM SIGPLAN, which in recent years has developed a ad-hoc committee on climate issues. It's great that SIGPLAN has taken this issue seriously. I do agree that carbon offsetting, SIGPLAN's current recommended action, can be worth doing. The following is my greatly simplified summary of the committee's argument for recommending this action. (For...| Rambles around computer science
(Those who follow me on Twitter may have a sense of déjà vu about this, but I thought it worth elevating to blog level. I wrote most of it over a year ago... must get better at timely blogging.) Back in September 2017 I attended the UK's inaugural National Postdoc Meeting organised by the Postdocs of Cambridge (PdOC) Society. We were fortunate to receive a flying visit from Borys, a.k.a. Professor Leszek Borysiewicz, at that time the Vice-Chancellor of the University of Cambridge. This was...| Rambles around computer science
A while back I chanced upon yet another “advice for PhD students” article, which cajoled me into finally writing my own. I should mention that I don't really like this sort of article; as a side-effect of this cognitive dissonance, the text below will be somewhat profane. (Just as many such articles contain unacknowledged US-centrism, so mine contains some UK-centrism. I hope you can deal with it.) Figure out how to make yourself work effectively. If you're relatively young when you start...| Rambles around computer science
From December 2015 until October 2017 I served on the University of Cambridge's Board of Scrutiny. This is a high-level governance body that is “the University's chief internal mechanism for ensuring transparency and accountability in all aspects of University operations”. The role of the Board is to “examine the way in which the University is run and to comment on this to the University's governing body, the Regent House”, taking its lead principally (but not necessarily exclusively)...| Rambles around computer science
Dear Bogdan, Thank you for this update on our undergraduate admissions testing, and very well done on what must have been a mammoth effort. Seeing the CSAT happening at the CL, I could see it did succeed in creating a friendly environment, and I was impressed by the organisation effort which had clearly been necessary to put on such a smooth operation over a fairly long period. However, let me also sound a note of alarm. Reading the CSAT web pages, it is (still) not even mentioned that the te...| Rambles around computer science
It was great to get so much positive reaction to my essay “Some were meant for C”, so thanks to everyone concerned. In fact, thanks to everyone who's read it, even if you didn't like it! There were lots of things the essay didn't cover, and a few which it did only on a way that perhaps wasn't very obvious. And there were a few common patterns running through various reactions. All these seemed worth addressing directly in a few paragraphs, which I'll hopefully keep brief. What about C++? ...| Rambles around computer science
I have several project ideas to suggest this year. Any of them I could be available to supervise, for the right student (and not too many!). A caveat: most of these are researchy project ideas. Part II students should read the pink book carefully, and also read my advice about Part II projects from a student's perspective, including the potential dangers of getting too researchy. Nowadays as a researcher, I feel a strong incentive to suggest projects that verge on the over-challenging or over...| Rambles around computer science
A couple of times recently I've found myself wanting to create ELF files with custom program headers. This post explains what that means, why you might want it, why there's a practical difficulty in doing so using a standard linker, and my slightly hacky way of solving it. Program headers are metadata within ELF files. They describe a contiguous chunk of the file's address space. There are several different kinds of program header, of which the most critical is LOAD, signifying that the relev...| Rambles around computer science