PC Review


Reply
Thread Tools Rate Thread

how to debug shell execution processes?

 
 
Wilfried
Guest
Posts: n/a
 
      18th Nov 2009
Hello all,
I contribute to the latex2rtf converter project by compiling the DOS /
Windows port.

I'd like to get a hint how to debug the following problem (or, even
better, to solve it).

The program is written in C with command line interface and works as
intended under Mac OSX, Linux, cygwin and Windows (MinGW compiler).

I only have problems when a lot of equations are to be converted to
bitmaps.
The process is as follows:
- latex2rt.exe writes a LaTeX snippet to a disk file
- latex2rt.exe issues a SYSTEM call which starts bash
(from http://sourceforge.net/projects/win-bash/ )
- - which runs the shell script latex2png
- - which
- - - runs some shell utilities from
http://sourceforge.net/projects/gnuwin32/
- - - calls LaTeX (MikTeX) to convert .tex to .dvi
- - - calls dvips (MikTeX) to convert .dvi to .eps
- - - calls ImageMagick (Windows version) to convert .eps to .png
- - - calls ImageMagick to crop the .png
- latex2rt.exe reads the .png file and includes it in the rtf output.

The processing stops under XP
- when invoked from a freshly opened command prompt, after converting at
most about 600 equations (sufficient for most documents),
- but when some other commands were run in the command prompt before
invoking latex2rtf, it stops after about 100 equations.
- If the command prompt is opened from the windows GUI (l2rshell.exe),
it also stops after fewer equations.
- If additional debug output is written to stderr (i.e. the command
prompt), it stops after about 8 equations.

Under Vista, the number of successfully converted equations is generally
lower than under XP.
Interestingly, when running in cygwin under Vista, an error message is
issued: "... bash.exe: *** fatal error - couldn't allocate heap ..."

I read
http://wikis.sun.com/display/OpenJdk...Build+Problems
(scroll down to "Windows CYGWIN Problems")
and also looked at
http://cygwin.com/faq/faq.using.html#faq.using.bloda
so I tried with (temporarily) uninstalling the virus scanner, but this
didn't help.

The Windows port (including installer) and the source (platform
independent) are on
http://sourceforge.net/projects/latex2rtf/
latex2rtf-win package, version 1.9.20, pre-release

Many thanks for any hint how to debug this.

--
Wilfried Hennings
please reply in the newsgroup, the e-mail address is invalid
 
Reply With Quote
 
 
 
 
foxidrive
Guest
Posts: n/a
 
      18th Nov 2009
On Wed, 18 Nov 2009 11:28:45 +0100, Wilfried <(E-Mail Removed)>
wrote:

>The processing stops under XP
>- when invoked from a freshly opened command prompt, after converting at
>most about 600 equations (sufficient for most documents),
>- but when some other commands were run in the command prompt before
>invoking latex2rtf, it stops after about 100 equations.


What is an example of the other commands?

>- If the command prompt is opened from the windows GUI (l2rshell.exe),
>it also stops after fewer equations.
>- If additional debug output is written to stderr (i.e. the command
>prompt), it stops after about 8 equations.


How does the process stop? With an error message? Lockup?
Exit normally?

Re the process: is a single equation a single pass through the script?

 
Reply With Quote
 
Wilfried
Guest
Posts: n/a
 
      18th Nov 2009
foxidrive <(E-Mail Removed)> wrote:

> On Wed, 18 Nov 2009 11:28:45 +0100, Wilfried <(E-Mail Removed)>
> wrote:
>
> >The processing stops under XP
> >- when invoked from a freshly opened command prompt, after converting at
> >most about 600 equations (sufficient for most documents),
> >- but when some other commands were run in the command prompt before
> >invoking latex2rtf, it stops after about 100 equations.

>
> What is an example of the other commands?


E.g. calling "l2r.bat" which in turn
sets some environment variables
calls latex2rt.exe
and ends.
The batch file completes normally and returns to the original command
prompt, but some resources seem to be irreversibly consumed.

Calling latex2rt.exe from a freshly opened command prompt under XP, it
stopped after about 310 equations.
I then started latex2rt.exe again from the same command prompt, and it
stopped after 167 equations.
I again started latex2rt.exe from the same command prompt, and it
stopped after 119 equations.

-> I'll have to investigate whether all opened files are correctly
closed.

> >- If the command prompt is opened from the windows GUI (l2rshell.exe),
> >it also stops after fewer equations.
> >- If additional debug output is written to stderr (i.e. the command
> >prompt), it stops after about 8 equations.

>
> How does the process stop? With an error message? Lockup?
> Exit normally?


Depends.

Under XP, just stops after processing an equation and returns to the
command prompt without error message, but the generated rtf file is
incomplete. The shellscript was successfully executed on the (n)th tex
file (temporary files were deleted) but the (n+1)th tex file isn't
written to disk.
That reminds me of a thing. The program tests whether the tex file can
be opened for writing. It seems that after successfully writing n tex
files to disk, the "open for writing" of the n+1 file fails and
therefore the program exits.

Under Vista, mostly crash: "latex2rt has stopped working ... looking for
solution". It seems that the "open for writing" does not return the
correct state under Vista.

> Re the process: is a single equation a single pass through the script?


Yes.

Thanks for your reply.
Wilfried
 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      19th Nov 2009
On Wed, 18 Nov 2009 17:18:31 +0100, Wilfried <(E-Mail Removed)>
wrote:

>foxidrive <(E-Mail Removed)> wrote:
>
>> On Wed, 18 Nov 2009 11:28:45 +0100, Wilfried <(E-Mail Removed)>
>> wrote:
>>
>> >The processing stops under XP
>> >- when invoked from a freshly opened command prompt, after converting at
>> >most about 600 equations (sufficient for most documents),
>> >- but when some other commands were run in the command prompt before
>> >invoking latex2rtf, it stops after about 100 equations.

>>
>> What is an example of the other commands?

>
>E.g. calling "l2r.bat" which in turn
>sets some environment variables
>calls latex2rt.exe
>and ends.
>The batch file completes normally and returns to the original command
>prompt, but some resources seem to be irreversibly consumed.
>
>>
>> How does the process stop? With an error message? Lockup?
>> Exit normally?

>
>Depends.
>
>Under XP, just stops after processing an equation and returns to the
>command prompt without error message, but the generated rtf file is
>incomplete. The shellscript was successfully executed on the (n)th tex
>file (temporary files were deleted) but the (n+1)th tex file isn't
>written to disk.
>That reminds me of a thing. The program tests whether the tex file can
>be opened for writing. It seems that after successfully writing n tex
>files to disk, the "open for writing" of the n+1 file fails and
>therefore the program exits.


This could be central to the issue - maybe something to do with shared temp
files, or too many temp files open.

Have you considered rewriting the script using windows commands to see if
that changes the behaviour?

 
Reply With Quote
 
Wilfried
Guest
Posts: n/a
 
      20th Nov 2009
On Thu, 19 Nov 2009 15:05:03 +1100, foxidrive <(E-Mail Removed)>
wrote:

>On Wed, 18 Nov 2009 17:18:31 +0100, Wilfried <(E-Mail Removed)>
>wrote:
>
>>foxidrive <(E-Mail Removed)> wrote:
>>
>>> On Wed, 18 Nov 2009 11:28:45 +0100, Wilfried <(E-Mail Removed)>
>>> wrote:
>>>
>>> >The processing stops under XP
>>> >- when invoked from a freshly opened command prompt, after converting at
>>> >most about 600 equations (sufficient for most documents),
>>> >- but when some other commands were run in the command prompt before
>>> >invoking latex2rtf, it stops after about 100 equations.
>>>
>>> What is an example of the other commands?

>>
>>E.g. calling "l2r.bat" which in turn
>>sets some environment variables
>>calls latex2rt.exe
>>and ends.
>>The batch file completes normally and returns to the original command
>>prompt, but some resources seem to be irreversibly consumed.
>>
>>>
>>> How does the process stop? With an error message? Lockup?
>>> Exit normally?

>>
>>Depends.
>>
>>Under XP, just stops after processing an equation and returns to the
>>command prompt without error message, but the generated rtf file is
>>incomplete. The shellscript was successfully executed on the (n)th tex
>>file (temporary files were deleted) but the (n+1)th tex file isn't
>>written to disk.
>>That reminds me of a thing. The program tests whether the tex file can
>>be opened for writing. It seems that after successfully writing n tex
>>files to disk, the "open for writing" of the n+1 file fails and
>>therefore the program exits.

>
>This could be central to the issue - maybe something to do with shared temp
>files, or too many temp files open.
>
>Have you considered rewriting the script using windows commands to see if
>that changes the behaviour?


I rewrote the script but this didn't change anything.

I then stripped down the calling program so that only a (constant)
input file for the script is written and the script is called. This
runs successfully for at least 500 equations. So it is neither the
script nor the programs called by the script.

Finally I modified the calling program so that no system call is
issued and therefore the script is not run. The error still occurs. So
it must be a bug in the calling program (e.g. failing to close a
file).

Thank you for pointing me to the right questions. I think the rest of
the debugging does not belong into this group.

Wilfried
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell command and code execution Ryder Microsoft Excel Programming 1 14th Jan 2010 07:11 PM
Synchronous execution using shell function =?Utf-8?B?Q2hyaXM=?= Microsoft Excel Programming 2 27th Sep 2007 10:49 AM
Delays/Stalls in execution of programs/processes =?Utf-8?B?R3Vz?= Windows XP Performance 0 6th Jan 2006 03:22 PM
Unblock Shell Execution hook =?Utf-8?B?TWl0amE=?= Spyware Discussion 0 13th Dec 2005 01:04 AM
Debugging two processes question/launching two debug processes =?Utf-8?B?bTExNTMz?= Microsoft C# .NET 4 4th Nov 2004 11:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.