Plan9port Acme Crash (in qunlock())
published: [nandalism home] (dark light)
Plan9port Acme Crash
Following a Russ Cox video tutorial (advent of code 2021 day 14) acme crashed.
This bug occurred on plan9port package for Alpine Linux v3.18 (AMD64) musl-libc, [$ apk add plan9port]
I tried building plan9port locally, from the latest sources from 9fans. However, the bug occurred exactly as before.
After the crash the the following message is visible in the terminal, followed by process abort.
acme: qunlock pc=0x56233606bec4 owner=0 self=7f83d7474050 oops aborted
Expected Behavior
The Edit command should have done a live update of the text in the open 'puzzle' file window.
Reproduce Bug
We need a file called 'puzzle' with the contents 'NNCB'.
$ cat puzzle NNCB
Then enter the following acme
Edit command into a new buffer or file.
Edit X/puzzle/ 1x/./ { .,.+#1 { g/CH/ s/./&B/ } }
Open the file 'puzzle' and execute the Edit command above. Acme will crash.
With the file 'puzzle' unopened in acme the above command does nothing. The X/puzzle/ matches on the (opened buffer?) 'puzzle'.
Aside: I am unsure of how to get acme's current version.
GDB stack trace
The normal gdb stacktrace is corrupted. However, manually stepping with gdb I see that the crash stack is something like this:
[wind.c::winsettag1()] winunlock() qunlock() [libthread/thread.c::threadqunlock()] -- explicit test for lock->owner!=0 or else print message above and call abort() -- this is a controlled/checked abort in libthread
The Full Edit Command
The purpose of the edit command is to implement a string replacement language which modifies the original string on each run.
It is possible that I made a transcription error when copying from the video. However, acme shouldn't crash because of that.
Edit X/puzzle/ 1x/./ { .,.+#1 { g/CH/ s/./&B/ g/HH/ s/./&N/ g/CB/ s/./&H/ g/NH/ s/./&C/ g/HB/ s/./&C/ g/HC/ s/./&B/ g/HN/ s/./&C/ g/NN/ s/./&C/ g/BH/ s/./&H/ g/NC/ s/./&B/ g/NB/ s/./&B/ g/BN/ s/./&B/ g/BB/ s/./&N/ g/BC/ s/./&B/ g/CC/ s/./&N/ g/CN/ s/./&C/ } }
Addendum: works in sam
I've translated the Edit to sam (and learned sam) and it works there. Gives valid results as per advent of code.
1x/./ { .,.+#1 { g/CH/ s/./&B/ g/HH/ s/./&N/ g/CB/ s/./&H/ g/NH/ s/./&C/ g/HB/ s/./&C/ g/HC/ s/./&B/ g/HN/ s/./&C/ g/NN/ s/./&C/ g/BH/ s/./&H/ g/NC/ s/./&B/ g/NB/ s/./&B/ g/BN/ s/./&B/ g/BB/ s/./&N/ g/BC/ s/./&B/ g/CC/ s/./&N/ g/CN/ s/./&C/ } }