w is showing the wrong number of logged in users (as in this question), and the answer to that question is that the
utmp file is corrupt. This seems likely, as a custom-built
hello program is also getting the wrong number, and it works by reading
utmp. I've narrowed down the issue to logins from a tty (that is, from someone who is physically at the server logging in using the keyboard attached to it). Essentially, logins from a
tty seem to be recorded, but logouts aren't. What's going on?