[Dev-luatex] os.spawn and AR crash mystery resolved

T T t34www at googlemail.com
Thu Apr 22 17:13:33 CEST 2010


Continuation of thread from:

http://tug.org/pipermail/tex-live/2010-April/025466.html

On 22 April 2010 00:03, Manuel Pégourié-Gonnard <mpg at elzevir.fr> wrote:
> T T a écrit :
>> Yes, I'm quite familiar by now how those things work in texlua and
>> perl.  Still, I'm really baffled how those problems can propagate
>> farther down to child processes.  I started cmd.exe from perl that was
>> spawned from texlua and AR9 just wouldn't run from that cmd.exe no
>> matter what (nor from any other process started from there).
>>
> Yeah, that's really amazing. Maybe something with the environment that would
> propagate differently using spawn/exec vs execute?

Manuel, you've been on the right track all along.  I finally (almost)
got to the bottom of it.

The problem is the same as reported in the past for texdoc:

http://www.ntg.nl/pipermail/dev-luatex/2008-September/001771.html

It comes from kpathsea, which changes \ to / in USERPRIFILE var and
this leads to the dreaded AR crash with "internal error occurred".
I've been unable so far to locate at which point this substitution
happens, but at least there is an easy fix for that, which I will
commit shortly:

  os.setenv("USERPROFILE", os.getenv("USERPROFILE"):gsub('/', '\\'))

But it gets even more interesting.  This change doesn't seem to happen
really in the environment but only in the environ variable exported
from the kpathsea lib.  This explains why os.execute() works (as
reported in the texdoc thread referenced above) and os.spawn()
doesn't. With os.execute() the child process inherits the environment
automatically from its parent, while os.spawn() is implemented using
_spawnvpe() with the environ variable passed for the environment.

What's more, this USERPROFILE manipulation happens only with w32tex
builds.  For my private mingw static build this doesn't happen.  Also,
the same substitution of \ to / happens sometimes for the command line
arguments, which should be fixed too.

Now, I'm not sure if using the environ variable in os.spawn() is
actually intended.  It is certainly not consistent to use it there and
not use it in os.execute().  I would suggest to remove this entirely
with this one line change in luatex:

Index: loslibext.c
===================================================================
--- loslibext.c	(revision 3635)
+++ loslibext.c	(working copy)
@@ -113,7 +113,7 @@

 #ifdef _WIN32
 #  include <process.h>
-#  define spawn_command(a,b,c) _spawnvpe(_P_WAIT,(const char
*)a,(const char* const*)b,(const char* const*)c)
+#  define spawn_command(a,b,c) _spawnvp(_P_WAIT,(const char
*)a,(const char* const*)b)
 #  if DONT_REALLY_EXIT
 #    define exec_command(a,b,c) exit(spawn_command((a),(b),(c)))
 #  else

Cheers,

Tomek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loslibext.c.diff
Type: application/octet-stream
Size: 513 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/dev-luatex/attachments/20100422/080ce12f/attachment.obj>


More information about the dev-luatex mailing list