Bug 110616

Summary: log-file option not working correctly when program forks some children
Product: [Developer tools] valgrind Reporter: Joachim Bauernberger <joachim.bauernberger.ext>
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal CC: njn
Priority: NOR    
Version: 3.0.0   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: fork a cople of processes to demonstrate valgrind behaviour

Description Tom Hughes 2005-08-12 21:18:55 UTC
No details provided.
Comment 1 Joachim Bauernberger 2005-08-17 17:08:49 UTC
I have posted this to the valgrind-users mailing list along with a sample program which demonstrates the problem. this bug tracking system does not allow uploads so which details would you like?
Comment 2 Tom Hughes 2005-08-17 17:16:50 UTC
You certainly can upload things - use the "Create a New Attachment" link.

What we really need is not a test case though (although that may help) but a description of what you think is wrong - what you are doing, what is happening and what you think should happen.

The fact that you may have posted those details on the mailing list at some point is helpful, but it will be far easier if they are here than if we have to go searching the mailing list to find them.
Comment 3 Joachim Bauernberger 2005-08-17 17:46:35 UTC
Created attachment 12250 [details]
fork a cople of processes to demonstrate valgrind behaviour
Comment 4 Joachim Bauernberger 2005-08-17 17:47:25 UTC
Hi,

we have some very large apps which load massive amount of shared libs. After trying valgrind on one of them (app has around 10-20 child processes) I noticed that the logfile for the child does not get written. Instead I have all messages appear in the parents log (the PID does get appended to the file). 

Also I just tried running some sample code that forks 5 children does some stuff and exits (see attached file).
I ran this then using:
valgrind --trace-children=yes --log-file=foo ./fork

I would have expected valgrind to make an individual logfile for every child.

I checked the NEWS file (and archives) on that. 

The NEWS file says
- Small changes in control log file naming which make it easier to
  use valgrind for debugging MPI-based programs.  The relevant
  new flags are --log-file-exactly= and --log-file-qualifier=.

what are those 2 new flags for?


The man page says to the --log-file= option:
... the file name used is created  by  concatenating  the  text filename, ".pid" and the process ID, so as
to create a file per process. 

should this still apply?


thanks & best regards,
joachim
Comment 5 Tom Hughes 2005-08-17 18:15:48 UTC
Sections 2.3 and 2.6.2 of the valgrind manual describe what --log-file-exactly and --log-file-qualifier do.

As far as your other problem goes, the logging stream for a single instance of valgrind always goes to a single place established when that instance starts, and forking does not create a new instance of valgrind. If one of those children were to exec a new process (and --trace-children was set) then the command line arguments would be re-evaluated and new log file would be opened based on the new PID value.

It would certainly be possible to establish a new logging stream on fork, but it is a non-trivial change.
Comment 6 Nicholas Nethercote 2009-07-01 09:31:06 UTC

*** This bug has been marked as a duplicate of bug 162848 ***