Bug#575731: tex/pdftex -recorder works incorrectly on parrallel TeX runs (race, breaks make -j)
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
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.32.10-roro (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages texlive-binaries depends on:
ii libc6 2.10.2-6 Embedded GNU C Library: Shared lib
ii libfontconfig1 2.8.0-2 generic font configuration library
ii libfreetype6 2.3.11-1 FreeType 2 font engine, shared lib
ii libgcc1 1:4.4.2-9 GCC support library
ii libkpathsea5 2009-5 TeX Live: path search library for
ii libncurses5 5.7+20100313-1 shared libraries for terminal hand
ii libpng12-0 1.2.43-1 PNG library - runtime
ii libpoppler5 0.12.2-2 PDF rendering library
ii libstdc++6 4.4.2-9 The GNU Standard C++ Library v3
ii libx11-6 2:1.3.3-2 X11 client-side library
ii libxaw7 2:1.0.7-1 X11 Athena Widget library
ii libxmu6 2:1.0.5-1 X11 miscellaneous utility library
ii libxpm4 1:3.5.8-1 X11 pixmap library
ii libxt6 1:1.0.7-1 X11 toolkit intrinsics library
ii tex-common 2.07 common infrastructure for building
ii zlib1g 1:1.2.3.4.dfsg-3 compression library - runtime
texlive-binaries recommends no packages.
texlive-binaries suggests no packages.
-- no debconf information
Reply to: