Out of curiosity I finally tracked down the problem (though I still don't know why it happens). For some reason, after logging out, the comment_form_* options all get set to 0, even though they are 1 when logged in. Now time to try to find where these options get changed...
Edit: the comment_form_* options are changed because comment_form_members_only is enabled which turns them off after logout. However, it looks like switching these off will simply have the printCommentForm() function return instead of printing the comment form with comments disabled.