„Lazy Evaluation“ in POSIX-C, using sigaction(2)

Mi, 31 Mär 2010 23:32:16 +0200

It amazes me time and again how flexible POSIX (and other lowlevel-stuff in common unix-like environments in general) is. Surprising enough that fork(3)-ing doesnt result in a doubled memory-consumption in general, because the Pages are mapped Copy-On-Write – which is a nice thing, but still done by the kernel – it even gives the userspace-processes a lot of control about paging. So I wonder why most of the programmers just use malloc(3) – maybe because its the most portable non-gc-possibility to organize memory. I know that SBCL uses libsigsegv to optimize its memory management.

For a long time now I had the idea of implementing lazy evaluation with pure C using libsigsegv. The plan was to allocate some address-space and mprotect(2) it, and then, as soon as someone accesses it, a sigsegv is thrown, and the handler calculates the contents of the accessed memory block, unprotects it, and saves the calculated value, and then returns back, so the calculated value can be accessed from this point on. Ok, this is not quite lazy evaluation – for example you cannot (at least not trivially) create infinite lists with this, but it goes into that direction, its like „calculating on demand“.

So I wrote a program doing this using libsigsegv, but unfortunately, I couldnt work recursively with libsigsegv, i.e. if I accessed a protected part of the memory during the sigsegv-handler, the program would exit. But libsigsegv is only a wrapper, probably around sigagtion(2). Sigaction itself allows recursive handling of signals, when using the flag SA_NODEFER. So I wrote the below Program. It calculates the fibonacci-sequence „blockwise“ – an array fib is allocated, and – on an x86-processor – split into 1024-wise arrays of integers. It also prints out the registers of the context of the error (that is, it produces a lot of output – be carefull when compiling it). And – well, I only tested it on x86 linux 2.6.26 and x86_64 linux 2.6.32, in the latter case, it doesnt work, it traps in an infinite loop.

#include <sys/mman.h>
#include <sys/user.h>
#include <malloc.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <ucontext.h>
#define __USE_GNU
#include <sys/ucontext.h>
#include <signal.h>

int * fib;
int * fib_e;

#define PAGE_FIBNUM (PAGE_SIZE / sizeof(int))

void sa_sigac (int sig, siginfo_t * siginfo, void* vcontext) {
 struct ucontext* context = (struct ucontext*) vcontext;

 size_t regs_size = sizeof(context->uc_mcontext.gregs);
 char format_hex[(3*regs_size)+10], format_dec[(3*regs_size)+9];
 memcpy (&format_hex, (void*) "Regshex:", 8);
 memcpy (&format_dec, (void*) "Regsdec:", 8);
 format_hex[(3*regs_size)+8] = format_dec[(3*regs_size)+8] = '\n';
 format_hex[(3*regs_size)+9] = format_dec[(3*regs_size)+9] = '';
 int i;
 for (i=8; i < (3*regs_size)+8; i+=3) {
 format_hex[i] = format_dec[i] = ' ';
 format_hex[i+1] = format_dec[i+1] ='%';
 format_hex[i+2] = 'x';
 format_dec[i+2] = 'u';
 }

 printf(format_hex, context->uc_mcontext.gregs);
 printf(format_dec, context->uc_mcontext.gregs); 

 void* failt_address = siginfo->si_addr;
 int number = ((int)failt_address - (int)fib) / sizeof(int);
 printf("Accessed: %d\n", number);
 int firstcalc = number - (number % PAGE_FIBNUM);
 int lastcalc = firstcalc + PAGE_FIBNUM;
 printf("Calculating Fibonacci-Sequence from %d to %d\n",
 firstcalc, lastcalc);
 mprotect(fib+firstcalc, PAGE_SIZE*sizeof(int), PROT_READ | PROT_WRITE);

 if (firstcalc == 0) {
 /* initial elements of fibonacci sequence */
 *(fib+firstcalc) = 0;
 *(fib+firstcalc+1) = 1;
 } else {
 *(fib+firstcalc) = *(fib+firstcalc-1) + *(fib+firstcalc-2);
 *(fib+firstcalc+1) = *(fib+firstcalc) + *(fib+firstcalc-1);
 }

 int * ccalc;

 for (ccalc = fib+firstcalc+2; ccalc < fib+lastcalc; ccalc++) {
 *ccalc = *(ccalc-1) + *(ccalc-2);
 }
}

int main (int argc, char* argv[]) {

 int fnum;

 if (argc == 1) {
 printf ("Please supply a number.\n");
 return -1;
 } else {
 sscanf(argv[1], "%d", &fnum);
 if (fnum > 20*PAGE_SIZE) {
 printf ("The number must not be greater than %u.\n",
 20*PAGE_SIZE);
 return -1;}
 }

 struct sigaction myaction;
 myaction.sa_sigaction = &sa_sigac;
 bzero(&myaction.sa_mask, sizeof(sigset_t));
 myaction.sa_flags = SA_NODEFER | SA_SIGINFO;
 myaction.sa_restorer = NULL;

 sigaction(SIGSEGV, &myaction, NULL);

 int fib_begin[24*PAGE_SIZE];
 int fb = (int) (&fib_begin);
 fib = (int*) ((fb - (fb % PAGE_SIZE)) + PAGE_SIZE);
 fib_e = fib + PAGE_SIZE;
 int e = mprotect (fib, 20*PAGE_SIZE*sizeof(int), PROT_NONE);
 perror("");
 printf("fib(%d) %% %u := %u\n", fnum, -1, fib[fnum]);
 return 0;

}

There are a few flaws in this source: It doesnt work under x86_64, even though I dont really see which part is not independent of the bus-width. Of course, handling it that way is highly unportable, but most unix-derivates should be able to do at least something like that.

The major flaw I dont like is that I am bound to calculating a whole block at once, and not being able to mprotect this block again afterwards. In theory, it should be possible to find out in which register the value should have been read and then manipulating the context and setjmp(3)-ing to it, so it doesnt try to read it again afterwards. But I myself cannot even access the registers directly by their name, though in sys/ucontext.h there is an enumeration with defined index-names, but they seem not to be defined when I am trying to use them. I dont know why. I just print them all out in the hope that I see some structure inside them, but so far, I didnt see much. I guess one has to know a lot of lowlevel-stuff about x86 to understand whats actually going on, which I dont have.

Anyway, I think this is very interesting. It may not be usefull at all, but its a nice thing.


Alternative Star Trek-Zeitlinie

Di, 30 Mär 2010 18:35:25 +0200

Bei Star Trek wurden öfters Aussagen zu Zeitpunkten in der Zukunft getroffen, die inzwischen jedoch schon in der Vergangenheit liegen. Viele sind allerdings durch den Lauf der Geschichte widerlegt worden (bei einigen zum Glück), zB. die eugenischen Kriege von 1992-1996. Auch der Bau des Millenium-Gates von 2000-2012 wurde noch nicht begonnen und 2002 ist Nomad auch nicht gestartet. Nun gibt es bei Star Trek allerdings auch Zeitreisen, wobei in Star Trek bei Zeitreisen auch alternative Zeitlinien entstehen können, in denen die Geschichte anders abgelaufen ist/abläuft/ablaufen wird (gramatikalisch korrekt formuliere ich bei Zeitreisen schon seit Jahren nicht mehr ;) ).

Irgendwie fände ich es jetzt witzig, wenn ein Star Trek-Film oder eine Serie jetzt von einer Zeitreise handeln würde, welche Veränderungen in der Erdvergangenheit verursacht, so daß gerade die Zeitlinie der Realität hervorkommt (zumindestens so weit, wie sie zum Drehzeitpunkt bekannt ist). Möglicherweise wird bei einer Zeitreise versehentlich die Geburt von Stavos Keniclius verhindert, oder sowas in der Art. Vielleicht passiert noch mehr, um die Zeitlinie in unsere Richtung zu beeinflussen. Eigentlich bin ich mir aber sicher, daß so etwas nicht gedreht werden wird.


Feiertagsvorschlag: Dunkelnacht

Do, 25 Mär 2010 00:48:11 +0200

Ich hab mir kürzlich über die Lichtverschutzung Gedanken gemacht und kam dabei auf folgende Idee: Man könnte einen Feiertag einführen, an dem man eine Lichtsauberkeit zumindestens mal erleben könnte. An diesem würde man in einer bestimmten Zeit (nachts) großflächig für einige Stunden jegliches Licht abschalten. Das hätte den Effekt, daß alle Menschen zumindestens einmal im Jahr einen klaren unverschutzten Sternenhimmel sehen könnten. Vielleicht würde so eine Maßnahme auch das Interesse der Menschen an dem Universum etwas stärken. Aber so ein Tag ist bestimmt eh nicht bei uns umsetzbar. Nett wäre er trotzdem.


Randomly Found Software: Xpra

Sa, 20 Mär 2010 17:16:53 +0200

One thing I really liked about Windows 7 was its excellent terminal-server-facilities. I could detach a running local session and reattach it again remotely. I could even tunnel it through ssh with ordinary ssh-x-forwarding by installing rdesktop on cygwin. It supported changing the size of the desktop and logging in without being visible on the physical screen.

X11 under Linux never worked that good, let alone Mac OS X, which is sort of the worst of all, with the worst VNC-Implementation I know so far.

Something none of the solutions knew were suspendable rootless GUIs. I dont know for how long I wished there was something like screen for X11-Applications. Well, there it is: Xpra.

It is a surprisingly small set of software, written in python, and though well done. The installation procedure is unusual but well documented, and for Arch Linux, there is an AUR-Package, which is why I love Arch Linux so much more than Debian – there are a lot more buildscripts available.

Having it installed, it can simply be started using

xpra start :1927

This will start a Server listening on Display 1927. To start an application running on this X-Server, we have to set its $DISPLAY to this, or supply it as an argument. I mostly start an XTerm, from which I then can start the rest.

nohup xterm -display :1927 &

If anything works,  the XTerm can be attached to the current server by running

xpra attach :1337

inside another X-Server. It also works remotely, through SSH X-Forwarding. Killing this process via C-c (or – if it is remote – by just pulling the network cable) the XTerm will disappear. But it can be attached again by simply doing the same command as soon as the connection is there again. Like one would do with screen.

When trying to attach a server inside itself, then the connection gets lost, but – surprisingly – I can attach the server afterwards. It doesnt crash. Now if that isnt solid!

There is no Tray-Bar-Integration (yet – I am sure this is possible), so when using tray applications, I use trayer for that.

Of course, it doesnt always work perfectly. I sometimes have to run

setxkbmap de

multiple times. And I heard of some issues with CapsLock. Sometimes I have to give a window the focus twice (i.e. clicking on its titlebar twice) before it actually gets focus. But well, it hasnt even reached version 1.0, and already made my life a little easier. I think its already worth using, and definitely worth being developed (and hopefully integrated into the default package trees of the major distributions).


Oooh ist der süß …

Fr, 19 Mär 2010 21:18:26 +0200

Und wer räumt jetzt den Müll weg?


Gedankenlesen …

Do, 18 Mär 2010 12:54:26 +0200

… geht momentan zwar noch nicht nachweislich, aber ich halte es für keine Utopie, dass die Hirnforschung irgendwann soweit kommen kann, Gedanken zu lesen und gezielt zu verändern. Lügendetektoren gibt es zum Beispiel schon lange. Und momentan experimentiert man mit der Steuerung von Bedienelementen durch Hirnströme.

Auf dieses Thema komme ich grade übrigens durch dieses Video, das ich zufällig entdeckt habe. Dort spielt jemand Pinball mit seinen Gedanken.

So faszinierend diese Techniken auch sein mögen, und so sehr ich auch normalerweise modernen Entwicklungen gegenüber positiv eingestellt bin, und zum Beispiel mit Gentechnik und Robotik höchstens moralische Probleme habe, so sehr erfüllt mich die Technologie die in die Richtung Gedankenkontrolle geht doch mit einer gewissen Angst.

Gentechnik führt dazu, dass Tiere zu Produktionsstätten degradiert werden, und dass sich Pflanzen verbreiten, deren langfristige Auswirkungen auf die Umwelt nicht absehbar sind – doch das sind moralische Bedenken. Ich selbst kann mich stets dafür einsetzen, dass man mit dem erlangten Wissen vorsichtig umgeht. Und bisher hat man das wenigstens nach ein paar millionen Toten dann letzten Endes immer getan.

Auch Robotik finde ich eher interessant – klar, man wird Menschen nach und nach ersetzen, und es ist durchaus denkbar, dass irgendwann ein Diktator sich eine Roboterarmee leisten kann (schon heute nutzt man kleine Roboter um an schwer zugängliche Stellen zu kommen) – aber auch hier kann man eine Opposition bilden, die notfalls ihre eigenen Roboter baut.

Doch wenn man die Gedanken eines Menschen kontrollieren kann, fällt jede Möglichkeit des Widerstandes weg. Denn sobald es möglich ist, einen Menschen neural so zu scannen, dass man bestimmte Gedanken und Verhaltensmuster erkennt, wird sicher irgendwer dies ebenfalls tun. Und wenn ich mir ansehe mit wie wenig Widerstand technische Entwicklungen wie Nacktscanner herapplaudiert werden, glaube ich auch kaum, dass sich rechtzeitig ein hinreichender Widerstand finden wird.

Nur um das mal zu veranschaulichen: Man stelle sich vor, morgen käme ein Bericht heraus, dass man eine Technik entwickelt hat, mit der man eindeutig die gesellschaftliche Gesinnung und die Persönlichkeit feststellen kann, und diese Technik ließe sich schön in einem Kasten verpacken, ohne großen Aufwandt – dann würde es mich übermorgen nicht wundern, wenn irgendein Politiker diese Technik an Flughäfen fordert, um festzustellen, welche Passagiere möglicherweise nicht Konform sind und daher zu Terroristen werden könnten. Immigranten würden grundsätzlich auf ihre Verfassungstreue überprüft. Auch die Forderung, die Sexualität von Lehrern zu überprüfen, würde wohl kommen. Es würde wohl früher oder später eine Diskussion losbrechen, ob man diese Technik zur Strafverfolgung verwenden darf, und ob sie als einziges Beweismittel ausreicht, und ob man präventiv jeden Mitbürger gezielt nach betreffenden Gedanken durchsuchen kann, um ihm gegebenenfalls psychologische Hilfe zu geben. Alles für unsere Sicherheit.

Es fiele eine weitere Konstante, auf die unser moralisches System sich so lange stützte, weg: Die Gedanken sind Frei.

Sobald man Gedanken kontrollieren kann, kann man alles kontrollieren – man kann jeden Freidenker eliminieren, bevor Dieser irgendetwas unternehmen kann, was einem schaden könnte.

Ich halte es für töricht, davon auszugehen, dass das niemals funktionieren wird – möglicherweise wird es niemals möglich sein, aber bisher deutet nichts darauf hin. Ich bezweifle aber auch, dass dies in Ansätzen nicht in den nächsten fünfzig Jahren möglich sein wird, ich glaube nicht, dass sich dieses Problem in die Zukunft verschieben lässt, die uns nicht mehr zu interessieren hat.

Eine solche Technik würde uns große und sinnvolle Möglichkeiten bieten. Vom Steuern komplexer Maschinen mittels Gedanken, bis hin zur Möglichkeit, gelähmten Menschen eine Möglichkeit zu geben sich wieder in der Welt zu bewegen, und selbst das Feststellen und Heilen bestimmter Gehirnkrankheiten würde ich mir davon erwarten. Umso wichtiger ist es, sich rechtzeitig Gedanken zu machen, wie die Gesellschaft damit umgehen sollte. In der Hand einer Gesellschaft wie der unsrigen will ich eine solche Technologie aber wirklich nicht sehen.


Software that should exist #5: Suspendable Processes

Di, 16 Mär 2010 00:44:41 +0200

So far, most OSes support Suspend to Disk. That is, I can take a snapshot of the current state of my computer and restore it later. Thats a good thing, when having opened a lot of programs, which would have to be started again otherwise.

Some Software allows the suspension of itself, too. SBCL and many other Common Lisp Implementations have Coredumps which can be reloaded (in fact, under SBCL, this is the default way of creating an executable). But it would be nice to have this feature inside the OS itself, working for (mostly) all processes.

That is, I would like to be able to suspend a process and all its subprocesses while keeping anything else running, but also being able to shutdown my computer meanwhile.

This – of course – produces several problems. An application could have mmapped or opened some files. So, if the program has opened a file exclusively, i.e. doesnt expect the file to change, then the OS would have to notice that and keep the file locked, even through shutdowns. Of course, this shouldnt really become a problem, and if something fails – well, there can always be IO-Errors anyway.

Same for sockets and other IPC-Stuff. But on the other hand, when changing something on a whole suspended disk-image, then the problem is equal – except that then you can make your whole kernel crash.

That is – of course, the user isnt allowed to break the security mechanisms of the OS – and if he does, then its his fault.

Of course, you can already do something similar – namely use usermode linux or some light virtualization. But having this for all processes would be better and easier.

Update: I seem not to be the only person thinking this. There is a project called CryoPID. Thank you for your comment, Leslie.


Proceeding with Arch Linux – btrfs, s2disk, umtsmon

Mo, 15 Mär 2010 00:49:11 +0200

Just a little Info of how it goes on with Arch Linux on my MacBook.

I switchen my Home-Partition to btrfs. It is experimental – that is, I know that I shouldnt save anything of value only on this – as you should never save anything of value only in one place. But the snapshotting-facilities are extremely useful, especially when experimenting with software. In the long term I want to switch my root-partition completely to it. At the moment, I will keep it that way – there will certainly come a time when I completely damage my system and have to reinstall it, and then I can redesign it.

Then – as you might notice from my former rant about KDE – I switched to gnome. Its nice, it works, it didnt crash so far, and I could customize it in a way I like. Meanwhile, Networking, also Wifi, works. Thats nice. Also the german keyboard layout and my customized settings for the touchpad work under Gnome. What doesnt work is compiz – but I can live without it for now.

Then for my GSM-Stick I used umtsmon. It uses ppp, but the default version of ppp doesnt support removing the default route. Therefore, one needs the package ppp-rdr in the AUR directory – which had a bug in the PKGBUILD-File (the file doesnt state correctly that it does provide ppp), so you have to fix that yourself. I am sure they already fixed it.

I had to write an udev-rule for to allow a user to access /dev/ttyUSB0. Though, still, I have to use umtsmon as root, since somehow ppp doesnt allow the -noauth-Option without being root. Therefore, I use sux to switch. I will have to investigate on this. Maybe, since now NetworkManager seems to work, I can connect through it, instead of umtsmon.

A problem with umtsmon was resolv.conf – it doesnt set it properly. I just added 8.8.8.8 (the google-nameserver) to it, then it worked. Sort of. Well, mobile internet is a pain – but thats not umtsmon’s fault.

For suspending to disk I use s2disk – I couldnt manage to make the Suspend-Facilities of Gnome and KDE work, but s2disk works. So I wrote an own script and added an application launcher to my panel. The content of the script is:

#! /bin/bash

kquitapp konversation;
purple-remote setstatus?status=offline;
gnome-screensaver-command -l && sleep 5 && sudo s2disk

This quits Konversation if online, sets the Pidgin-Status to offline if it runs, Locks the screen, then waits 5 seconds (this is a hack, because the gnome-screensaver fades out the screen – but it also fades after hibernation, which is annoying (and I couldnt find a gconf-entry to turn off this fading), and then suspends (of course, I had to add s2disk to the /etc/sudoers). There may be more elegant ways to do this, but well, it works that way, and it fits my needs.

And well, I did something epic: I installed debootstrap and bootstrapped a debian-system on an USB-Stick. Bootstrapping Debian from Arch Linux. Isnt it nice? Well, the AUR-Package didnt have a current version which is downloadable, so I had to modify the md5-checksum and the package version to make it work.

I wonder if there is something like debootstrap for arch linux.


Ist es Zeit für eine neue Programmiersprache?

Di, 09 Mär 2010 23:52:12 +0200

Huch, eine gefährliche Sicherheitslücke in Opera erlaubt die Ausführung von beliebigem Code. Schon irgendwie episch, dass sowas heutzutage immernoch passiert. In Zeiten, wo man jedes Bit noch dreimal verwenden musste, kann ich ja verstehen, dass sich hin und wieder Fehler eingeschlichen haben – man musste ziemlich lowlevel programmieren, um zu optimieren.

Nun, spätestens seit DOM und dynamic HTML sollten diese Zeiten aber zumindest für Browser so langsam zu Ende sein. Nun weiß ich freilich nicht, in was Opera genau geschrieben ist, aber ich vermute doch stark einen ziemlich großen C++-Kern, mit ziemlich vielen lowleveligen Aufrufen (ich bin bekanntermaßen kein C++-Freund, aber selbst C++ erlaubt einem  zum Beispiel, Arraygrenzen automatisch prüfen zu lassen, wenn man entsprechende Kapselungen verwendet – diese sind freilich ineffizienter).

Ich persönlich tendiere aber eher zu der Meinung, ein Browser sollte in einer sinnvollen Hochsprache geschrieben sein, mit einer guten Grundengine. Nachdem man von sämtlichen Browsern immer wieder hört, sie hätten Speicherlecks, was mich bei der Notwendigkeit der Behandlung dynamisch wachsender und sich verformender DOM-Bäume nicht wirklich wundert, ist hier vermutlich sogar ein Garbage Collector angebracht – letztendlich wäre nämlich alles, was man erzeugt, um dieses Problem effizient zu lösen, sowieso bereits ein Garbage Collector (zumal JavaScript sowieso einen Garbage Collector voraussetzt). Hochsprachen die das leisten gäbe es genug. Common Lisp und Scheme fielen mir da ein, Perl (ok, sort of) und Python, Haskell, *ml, Java, aber selbst ein konservativer Boehm Weiser GC sollte es bei entsprechender Kapselung in C++ tun. Sicherlich, Runtimes können auch Bugs haben. Aber es ist sinnvoller, auf eine Runtime zu setzen, die – sofern sie korrekt funktioniert – Sicherheit garantiert, und diese ggf. zu patchen, und damit gleich ziemlich viel Software abzusichern.

Wenn man sich nun aber die oben aufgelisteten Sprachen anschaut, fällt recht schnell eines auf: Irgendwie haben alle Sprachen inzwischen ziemlich viele Gemeinsamkeiten. Es mag sein, dass mit Haskell das imperative Programmieren erheblich schwerer ist (aber dank Syntaktischem Zucker im Zusammenhang mit Monaden eben nicht wirklich unmöglich – ja, man kann darüber streiten, ob das wirklich imperative Programmierung ist, aber … es fühlt sich so an, es sieht so aus, also ist es für mich imperativ), während C++ gerade mal Lambda-Konstrukte bekommen hat, die – wie ich C++ einschätze – kaum benutzbar sind. Trotzdem: Im Grunde bekommen momentan die meisten Programmiersprachen die Features von so ziemlich allen anderen. Das liegt wohl wiederum daran, dass die meisten derartigen Features eher kleine Anpassungen voraussetzen.

Wie dem auch sei, was entsteht ist also mehr oder weniger ein Einheitsbrei – zumindest habe ich momentan diesen Eindruck. Alle Programmiersprachen bekommen mehr oder weniger alle existenten Features irgendwie hinzugepfriemelt. Das ist auch nicht wirklich etwas schlechtes – an sich ist es gut, wenn man versucht, verschiedene Features irgendwie ineinander zu integrieren um sie kompatibel zu machen. Nur fehlt es mir persönlich momentan an echten Neuerungen. Ich sehe auf Freshmeat z.B. ständig irgendwelche neuen Interpreter, aber ich sehe selten irgendetwas wirklich neues.

Einen dann doch ganz anderen Weg gehen aber zum Beispiel Logikprogrammiersprachen, wobei ich gestehen muss, bis auf eine Vorlesung und ein wenig Doku über LogTalk wenig bis nichts darüber zu wissen. Logikprogrammierung scheint zwei Aspekte zu kombinieren, die ich mit meinem begrenzten Wissen als Trends prognostiziere: Kontextorientierte Auswertung und Programmverifkation bzw. -extraktion.

Kontextorientierte Auswertung geht in Richtung Lazy Evaluation, und bietet eine ideale Möglichkeit, Berechnungsprocesse zu verteilen –  nachdem Prozessoren jetzt eher dazu tendieren, mehr zu werden, als schneller, sehr sinnvoll. Außerdem lässt sie sich sehr gut in bestehenden Programmcode integrieren, und steht Typsystemen und Verifikation nicht im Weg.

Programmverifikation und Programmextraktion hingegen sind wiederum Techniken, die moderne Softwareprojekte brauchen werden. Spätestens, wenn man wirklich mal relevantes Cloud Computing betreiben will, wird man auf das Problem stoßen, sinnvoll und effizient Berechnungsprozesse eines anderen Rechners ausführen zu müssen, ohne Angst vor Exploits zu haben. Und man wird auf das Problem stoßen, eine fertige Berechnung zu verifizieren, in signifikant kürzerer Zeit als die Berechnung selbst gedauert hat.

Dabei ist Programmverifikation keine Möglichkeit, alle Exploits zu verhindern – das hört spätestens dann auf, wenn die Hardware Fehler macht. Aber es ist eine Möglichkeit, bekannte Sicherheitslücken zu verhindern, indem man Spezifikationen erstellt, die ein Programm erfüllen muss. Somit lassen sich Probleme wie Buffer Overflows effektiv beheben. Programmextraktion wiederum ist eine meiner Meinung nach sehr schöne Möglichkeit, Prototypen für Spezifikationen zu erzeugen, die man später effizienter macht. Ich  vermute, der höhere Aufwandt bei der Erzeugung der Software würde sich bald Amortisieren.

Das sind die Trends, die ich vorhersage. Freilich gibt es das alles schon, aber es führt momentan noch eher ein Nischendasein, während funktionale Konzepte inzwischen ziemlich weitreichend verbreitet sind. Was natürlich auch mit der Jahrzehntelangen Forschung auf diesem Gebiet zu tun hat. Da müssen diese Gebiete noch nachlegen.

Soweit meine Meinung. Andere Meinungen und Ergänzungen dazu würden mich interessieren.


Proceeding with Arch – GRUB works, KDE works, Wifi piddles around

Di, 09 Mär 2010 10:54:20 +0200

So, just giving a little update on my proceedings with Arch Linux. Well, I finally managed to get a proper triple boot system with OS X, Windows and Arch Linux – thanks to Kompottkin btw. The problem is that Windows needs to be the last partition on the disk to boot, and OS X and the EFI Bootloader has the two partitions in the beginning of the disk – i.e., only one Partition remains, until Windows gets confused – but thats just for the MBR Table. In the GPT Table, there can be partitions with a higher number than 4 between the third and the fourth partition. Linux recognizes GPT Disklabels and can handle these – the only problem is that GRUB (in a reasonable simple setup) so far only understands MBR Disklabels, which is why you have to install your /boot-Partition into the third MBR-Partition. But for anything else, it doesnt matter for Linux and Windows. So the basic installation procedure that worked for me was (this is just a compendium, not a guide – dont know if it always works):

  • Perform a fresh install of OS X (this shouldnt be necessary, but well, it prevents from any problems).
  • Use BootCamp-Assistant to partition disks (I gave Windows 32 Gig) but dont install.
  • Use Disk Utility and add an additional partition (This sometimes fails – I actually dont get why. Well, as far as I saw, you have to select the BootCamp-Partition and then press „+“ and add the partition.
  • Install Windows completely
  • Boot OS X, install rEFIt. Run „enable-always.sh“ to make the system always boot into rEFIt.
  • Boot the Arch Linux LiveCD, and use parted to create partitions as shown below.
  • Reboot into rEFIt. Let it Sync your Disklabels (in the partition tool). If you have a QUERTZ-Keyboard, remember to press „z“ instead of „y“. Otherwise, rEFIt wont do anything, since the default is not to change the disk.
  • Reboot again, boot Windows – now Windows should be confused and tells to boot from the Install Disk and run the Disk Repair Utility – well, I have done so. After reboot, Windows booted again.
  • Now boot again from the Arch Linux CD and install Arch. Grub wont install, because the Partition Type of /dev/sda3 is set to something different than 83. Use fdisk (not parted!) to change this. Now anything should be OK and after several reboots you should be able to boot all the 3 Systems.

At least this procedure worked for me. Here are the outputs of fdisk and parted (showing Dos and GPT Disklabel):

# fdisk -cu /dev/sda

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x37ff4f62

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1      409639      204819+  ee  GPT
/dev/sda2          409640    63264575    31427468   af  HFS / HFS+
/dev/sda3   *    63526720    65011712      742496+  83  Linux
/dev/sda4       245778432   312580095    33400832    7  HPFS/NTFS
# parted
GNU Parted 2.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA Hitachi HTS54501 (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name                  Flags
1      20.5kB  210MB   210MB   fat32           EFI System Partition  boot
2      210MB   32.4GB  32.2GB  hfs+            Macintosh HD
3      32.5GB  33.3GB  760MB   ext2            linux-boot
5      33.3GB  41.9GB  8590MB  linux-swap(v1)  linux-swap
6      41.9GB  50.5GB  8590MB  ext4            linux-root
7      50.5GB  126GB   75.4GB  ext3            linux-home
4      126GB   160GB   34.2GB  ntfs            BOOTCAMP

rEFIt claims that /dev/sda3 has a wrong filesystem label in the Dos Table. I dont know why, but I didnt let it resync the partitions, since this seemed not to produce any problems so far – and at least the partition boundaries are equal. So who cares.

For KDE4, there are the kdemod-Packages which are recommended by the Arch Linux Wiki. However, these packages didnt work for me (random crashes of plasma), so I preferred to install the supported packages. These also crashed after adding the NetworkManager-Applet to plasma, but after reconfiguring anything, it didnt crash anymore so far. A problem which remains is that it seems like my xorg.conf is just ignored – at least the XkbLayout-Option, and the options for my synaptics touchpad. I always have to use setxkbmap and synclient manually to set it to proper values as a workaround. But I am sure to be able to find out the reason soon.

Actually, I dont want to use KDE anyway – not that its not a good system, but its … huge. The main reason for using it is that there is basically no equivalent Frontend for NetworkManager, except under Gnome, and I dont like Gnome. Under KDE3, there was KNetworkManager, but they have replaced it by a „Plasma Applet“ now. There is still KNetworkManager in the AUR-Archives, but it fails to compile. And there is cnetworkmanager, but I dont really get how to set up eduroam connections with it. Well, there are other network management tools than networkmanager, and I will try these.

The main problem is not the frontend but the backend: I need the official broadcom-driver for my card, which fails hard! It seems like the Wifi is randomly working perfectly, but randomly just refuses to do anything. This is strange, because on Ubuntu, Wifi worked well, as well as on a similar arch linux installation on a MacBook Pro of some other person. The firmware should be the latest. So I dont really have any clue on how to investigate on this. I think the next thing I will try is ndiswrapper, but I couldnt find any 64 Bit Windows Driver for downloading yet. Well, we’ll see.