From: Martijn van Duren Subject: gotd: received unexpected privsep message To: gameoftrees@openbsd.org Date: Sun, 01 Jun 2025 21:44:23 +0200 Hello all, After upgrading my gotd machine to 7.7 I noticed that I couldn't delete branches anymore. The weird part is that the problems disappear when running in extra verbose mode (-vv), either daemonized, or foreground. This could be triggered with both `got send -d `, and `git push origin --delete `. The "unexpected privsep message" seems to originate from lib/serve.c inside serve_write(), where inside the while (curstate != STATE_PACKFILE_RECEIVED) { loop a GOTD_IMSG_PACKFILE_STATUS is received. Adding the GOTD_IMSG_PACKFILE_STATUS case from the while (curstate != STATE_REFS_UPDATED && err == NULL) { loop seems to make gotd behave as expected. Note that I consider this diff only as a starting point in a deeper analysis, since it doesn't explain why this case doesn't seem to be hit while running in verbose mode. I am not familiar enough with the g{o,i}t internals to say which messages are allowed at what point during the transaction, and the whole thing reeks of something racy. As seen below, the diff has been tested on top of 6f02d0a77cf43f47eebfc9af8ebcfcd0241e6729, which is 0.110 commit id. I've tried to bisect to see if I could find the culprit commit, but unfortunately I couldn't go prior to the new imsg API (commit fd9f46f196aef97157fc2532b99e727b72ea32b2). There's a couple of commits on/after this commit do remove the branch, but there seems to be some crash inside gotd during this time, so I'm not sure if that allows the gotd to get past the unexpected privsep message point. Hopefully someone with more knowledge of gotd than me can have a stab at this. martijn@ diff /home/martijn/src/got path + /home/martijn/src/got commit - 6f02d0a77cf43f47eebfc9af8ebcfcd0241e6729 blob - bf8e3261ba0241ac634ea7756c6793870799a9ed file + lib/serve.c --- lib/serve.c +++ lib/serve.c @@ -1343,6 +1343,11 @@ serve_write(int infd, int outfd, int gotd_sock, const } curstate = STATE_PACKFILE_RECEIVED; break; + case GOTD_IMSG_PACKFILE_STATUS: + if (!report_status) + break; + err = report_unpack_status(&imsg, outfd, chattygot); + break; default: err = got_error(GOT_ERR_PRIVSEP_MSG); break;