[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#518721: advi: Freezes on dvi files with a qtree tree.



Package: advi
Version: 1.6.0-13+b2
Severity: normal

When trying to open the attached .dvi file (generated by processing
the attached tex file with LaTeX) advi freezes (does not answer to
commands, but does not take 100% of the CPU either). xdvi displays it
fine.

The state during the freeze seems to be that advi launches a gs that
waits for input (blocks on "read(0, ...)" while advi itselfs loops on:

  --- SIGALRM (Alarm clock) @ 0 (0) ---
  rt_sigprocmask(SIG_BLOCK, [ALRM], [PIPE ALRM], 8) = 0
  read(3, 0x20326d4, 4096)          = -1 EAGAIN (Resource temporarily unavailable)
  read(3, 0x20326d4, 4096)          = -1 EAGAIN (Resource temporarily unavailable)
  setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 249999}}, {it_interval={0, 0}, it_value={0, 0}}) = 0
  setitimer(ITIMER_REAL, {it_interval={0, 0}, it_value={0, 249938}}, {it_interval={0, 0}, it_value={0, 249940}}) = 0
  rt_sigreturn(0x2)                 = -1 EINTR (Interrupted system call)
  read(6, 0x203ac40, 4096)          = ? ERESTARTSYS (To be restarted)
  --- SIGALRM (Alarm clock) @ 0 (0) ---

Here are the open files:

advi    6936 lionelm    0u   CHR              136,2                4 /dev/pts/2
advi    6936 lionelm    1u   CHR              136,2                4 /dev/pts/2
advi    6936 lionelm    2u   CHR              136,2                4 /dev/pts/2
advi    6936 lionelm    3u  unix 0xffff81001b30b940            93665 socket
advi    6936 lionelm    4r  FIFO                0,6            93667 pipe
advi    6936 lionelm    5w  FIFO                0,6            93667 pipe
advi    6936 lionelm    6r  FIFO                0,6            93668 pipe
advi    6936 lionelm    7w  FIFO                0,6            93668 pipe

gs      6939 lionelm    0r  FIFO                0,6            93667 pipe
gs      6939 lionelm    1w  FIFO                0,6            93668 pipe
gs      6939 lionelm    2u   CHR              136,2                4 /dev/pts/2
gs      6939 lionelm    4u  unix 0xffff81001b381180            93681 socket
gs      6939 lionelm    5w  FIFO                0,6            93667 pipe
gs      6939 lionelm    6r  FIFO                0,6            93668 pipe

(This, by the way, suggests that advi fails to close fd 5 and 6, the
 pipe it has set up to communicate with gs, before exec()'ing gs. This
 in turn leads to gs surviving advi: it does not get SIGPIPE because
 there is a program (itself) that has the same pipe open for writing
 so the kernel has hope that the read(0, ...) may ever return. advi
 probably uses the open_proc / open_process in the OCaml stdlib, which
 if I remember well has this fd leak bug (or lack of feature or
 however you want to call that); I use the following in my own code:

(* Adapted from unix.ml in ocaml stdlib:
 *
 * Copyright 1996 Institut National de Recherche en Informatique et
 *                en Automatique.
 *)

let try_set_close_on_exec fd =
  try Unix.set_close_on_exec fd; true with Invalid_argument _ -> false

let open_proc_sane cmd args (*proc*) input output error toclose =
  let cloexec = List.for_all try_set_close_on_exec toclose in
  match Unix.fork() with
     0 -> Unix.dup2 input  Unix.stdin;  Unix.close input;
          Unix.dup2 output Unix.stdout; Unix.close output;
          Unix.dup2 error  Unix.stderr; Unix.close error;
          if not cloexec then List.iter Unix.close toclose;
          begin try Unix.execvp cmd args
          with _ -> exit 127
          end
  | id -> id;;

let open_process_sane cmd args =
  let (in_read, in_write)   = Unix.pipe() in
  let (out_read, out_write) = Unix.pipe() in
  let (err_read, err_write) = Unix.pipe() in
  let outchan = Unix.out_channel_of_descr in_write  in
  let inchan  = Unix.in_channel_of_descr  out_read  in
  let errchan = Unix.in_channel_of_descr  err_read  in
  let cpid=open_proc_sane cmd args in_read out_write err_write [in_write; out_read; err_read] in
    Unix.close in_read;
    Unix.close out_write;
    Unix.close err_write;
    (cpid, (outchan,in_write), (inchan, out_read), (errchan,err_read));;


)

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_LU.UTF-8, LC_CTYPE=fr_LU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages advi depends on:
ii  ghostscript-x [gs] 8.62.dfsg.1-3.2lenny0 The GPL Ghostscript PostScript/PDF
ii  libc6              2.7-18                GNU C Library: Shared libraries
ii  libfreetype6       2.3.7-2               FreeType 2 font engine, shared lib
ii  libgif4            4.1.6-6               library for GIF images (library)
ii  libice6            2:1.0.4-1             X11 Inter-Client Exchange library
ii  libjpeg62          6b-14                 The Independent JPEG Group's JPEG 
ii  libpng12-0         1.2.27-2              PNG library - runtime
ii  libsm6             2:1.0.3-2             X11 Session Management library
ii  libtiff4           3.8.2-11              Tag Image File Format (TIFF) libra
ii  libx11-6           2:1.1.5-2             X11 client-side library
ii  libxext6           2:1.0.4-1             X11 miscellaneous extension librar
ii  libxinerama1       2:1.0.3-2             X11 Xinerama extension library
ii  libxpm4            1:3.5.7-1             X11 pixmap library
ii  texlive-base       2007.dfsg.1-5         TeX Live: Essential programs and f
ii  texlive-base-bin   2007.dfsg.2-4         TeX Live: Essential binaries
ii  zlib1g             1:1.2.3.3.dfsg-12     compression library - runtime

advi recommends no packages.

Versions of packages advi suggests:
ii  bzip2                     1.0.5-1        high-quality block-sorting file co
ii  ttf-kochi-gothic          1.0.20030809-8 Kochi Subst Gothic Japanese TrueTy
ii  ttf-kochi-mincho          1.0.20030809-8 Kochi Subst Mincho Japanese TrueTy

-- no debconf information
\documentclass{article}
\usepackage{qtree}

\begin{document}

\leaf{a}
\leaf{b}
\branch{2}{c}
\qobitree

\end{document}

Attachment: foo.dvi
Description: TeX dvi file


Reply to: