Bug 8220

Summary: do_acct_process is not called from do_exit
Product: Process Management Reporter: Lin Tan (tammy000)
Component: OtherAssignee: Olaf Kirch (okir)
Status: RESOLVED PATCH_ALREADY_AVAILABLE    
Severity: high CC: okir
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.20.1 Subsystem:
Regression: --- Bisected commit-id:

Description Lin Tan 2007-03-16 16:08:02 UTC
Distribution: 2.6.20.1
Hardware Environment: All
Software Environment: All

Problem Description:
The comment above the body of do_acct_process() clearly states that it should
only be called from do_exit(). See the code extract below.
415  This function should only be called from
416  *  do_exit().
417  */
418 
419 /*
420  *  do_acct_process does all actual work. Caller holds the reference to file.
421  */
422 static void do_acct_process(struct file *file)

But in the following call chain, it is called from init, but never from do_exit.
do_acct_process <- acct_file_reopen <-	sys_acct <- acct_auto_close <- sys_acct
<- do_umount <- do_remount_sb <- acct_auto_close <- do_umount	<- sys_umount <-
sys_umount <-	handle_initrd <- handle_initrd	<- initrd_load <- initrd_load	<-
prepare_namespace <- prepare_namespace <- init


Steps to reproduce:
I found this bug using a code checking tool.
Comment 1 Olaf Kirch 2007-03-18 10:14:03 UTC
I think the comment is somewhat ambiguous. It should probably say
"This function should only be called from do_exit() or when switching
to a different output file".

Maybe it originally precded acct_process() - and in that case, it would even
be correct.

Is there any specific reason why you think this qualifies as a bug?
Comment 2 Lin Tan 2007-03-18 18:18:22 UTC
Thanks a lot for the explanation!

This was detected by a static checking tool. As the comment and code mismatch,
it is either a bug or the comment is wrong or imprecise.
In this case, as the comment is not correct, it may confuse and mislead
developers and cause new bugs. I've found bugs caused by reading bad comments.
Comment 3 Ingo Molnar 2007-11-17 18:57:39 UTC
ok, i've fixed the comment and have queued up a patch for upstream.