[tex-k] tex/pdftex -recorder works incorrectly on parrallel TeX runs (race, breaks make -j)

Norbert Preining preining at logic.at
Sun Mar 28 23:18:35 CEST 2010


forwarded 575731 tex-k at tug.org
thanks

Dear Karl, dear all @tex-k

here a quite detailed bug report about parallel calls to pdftex and 
-recorder.

Any comments?

On Mo, 29 Mär 2010, Kirill Smelkov wrote:
> Package: texlive-binaries
> Version: 2009-5
> Severity: normal
> File: /usr/bin/pdftex
> 
> Hello,
> 
> I use -recorder option in my TeX makefile in order to automatically
> generate TeX dependencies (a-la gcc -MD) and discovered that -recorder
> does not work correctly for parallel TeX runs. Look e.g. here:
> 
>     $ cat 1.tex
>     Hello World
>     \end
> 
>     $ strace tex -recorder 1.tex 2>&1 | grep fls
>     open("tex.fls", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>     rename("tex.fls", "1.fls")              = 0
> 
>     $ strace pdftex -recorder 1.tex 2>&1 | grep fls
>     open("pdftex.fls", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>     rename("pdftex.fls", "1.fls")           = 0
> 
> 
> As can bee seen both tex/pdftex first use intermediate temporary file
> (tex.fls / pdftex.fls) and only then rename it to $(jobname).fls
> 
> So the problem here is that when I try to compile both 1.tex and 2.tex
> _simultaneously_ (e.g. through make -j2) there is a good chance that
> both tex runs will open the same pdftex.fls and then oops, resulting
> .fls will be wrong.
> 
> texk/web2c/lib/openclose.c suggests mkstemp would be a better option
> instead of using intermediate <program>.fls :
> 
>     /* Helpers for the filename recorder... */
>     /* Start the recorder */
>     static void
>     recorder_start(void)
>     {
>         /* Alas, while we might want to use mkstemp it is not portable.
>            So we have to be content with using a default name... */
>         string cwd;
>     
>         recorder_name = (string)xmalloc(strlen(kpse_program_name)+5);
>         strcpy(recorder_name, kpse_program_name);
>         strcat(recorder_name, ".fls");
> 
>     ...
> 
> 
>     /* Change the name of the recorder file. */
>     void
>     recorder_change_filename (string new_name)
>     {
>        if (!recorder_file)
>          return;
>        rename(recorder_name, new_name);
>        free(recorder_name);
>        recorder_name = xstrdup(new_name);
>     }
> 
> 
> but I wonder, why use intermediate file for recorder at all? Why not to
> open $(jobname).fls in the first place?
> 
> 
> Thanks,
> Kirill

Best wishes

Norbert
------------------------------------------------------------------------
Norbert Preining            preining@{jaist.ac.jp, logic.at, debian.org}
JAIST, Japan            TU Wien, Austria           Debian TeX Task Force
DSA: 0x09C5B094   fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
------------------------------------------------------------------------
GLORORUM (n.)
One who takes pleasure in informing others about their bowel
movements.
			--- Douglas Adams, The Meaning of Liff


More information about the tex-k mailing list