On Fri, Jun 23, 2006 at 01:27:18AM +0200, Fr??d??ric Bothamy wrote:
> * Justin Pryzby <[EMAIL PROTECTED]> [2006-06-21 08:47] :
> > On Wed, Jun 21, 2006 at 02:25:31AM +0200, Fr??d??ric Bothamy wrote:
> 
> [...]
> 
> > > pn  openoffice.org2-core             <n?ant>                         
> > > (aucune description n'est disponible)                                     
> > >            
> > > /usr/bin/dlocate: line 55: 26638 Done                    egrep "$1" 
> > > $DPKGLIST
> > >      26639 Erreur de segmentation  | while read stat name ver descr; do
> > >     printf "%-2s  %-${fieldw}.${fieldw}s %-${fieldw}.${fieldw}s 
> > > %-${fieldd}.${fieldd}s\\n" "$stat" "$name" "$ver" "$descr";
> > > done
> > > 
> > > Program exited normally.
> > > (gdb)
> > > 
> > > Do you have another idea?
> > Is egrep the one segfaulting?  You can do the same as before to build
> > a "grep" deb with debugging symbols, then just dpkg -i
> > ../grep_....deb.  apt-get {--re,}install grep later if you wish.
> > 
> > It isn't completely clear to me how gdb would handle debugging the
> > grep; you might have to change the shell script to use
> > 
> >   'gdb egrep "$1" $DPKGLIST'
> > 
> > instead, or just dump "$1" and $DPKGLIST to a file to fiddle with it
> > manually.
> 
> Hello Justin,
> 
> Thanks for your help.
> 
> I have tried to see if this was a problem with egrep and I have replaced
> the egrep in the dlocate script with a simple "cat $DPKGLIST". The
> segfault also occurs. But it does not occur if I use a "head $DPKGLIST".
What is the contents of $DPKGLIST?  you should
echo "$DPKGLIST" >/tmp/testgrep

The quotes are important.  It occurs to me that, without quotes, you
could end up with $DPKGLIST being its own command, eg. if it contains
any of: ;`& or such characters..  But this is perhaps also intentional
(and ` is still evaluated within "" quotes).

> I have found that the problem only occurs if I send 276 lines (or more)
> of text to the "| while ...".
Interesting..

> If I try to execute the dlocate script with "sh -x" at the beginning
> of the script, I need 373 lines to get the segmentation error.
> 
> If I execute the lines of the script at the command prompt, I get an
> error with 22504. Here is the exact command that I used:
22504 is the number of lines of input, the line number, or a PID?

> $ echo $COLUMNS
> 150
> $ ((fieldw=(COLUMNS-24)/4))
> $ ((fieldd=COLUMNS-fieldw*2-6))
> $ cat dpkg-list_fr | while read stat name ver descr; do printf "%-2s 
> %-${fieldw}.${fieldw}s %-${fieldw}.${fieldw}s %-${fieldd}.${fieldd}s\\n"
> "$stat" "$name" "$ver" "$descr"; done
Does this crash cat, printf, or what?  You can get rid of the cat by
rewriting as:

  while read .. .. .. ..; do ..; done <dpkg-list_fr

I suspect this is a bash problem with wide characters or such.

Justin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to