[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02965] Re: Messages: [BUG] Segmentation Fault

From: "David Douthitt" <DDouthitt@...>
Date: 2000-05-24 14:29:03 UTC
List: ruby-talk #2965
The script isn't too small.... but....

I didn't change the script.  The first time I received a SegFault was under HP-UX 10.20, but it went away as I kept developing the code.

The second appeared in this environment (listed below) in this same code, but went away.  It was not at the same place listed below.

Some of these appear to start showing up, then disappear spontaneously.

The program runs as a cron job, and all three invokations listed below generate the same error at the same place.

# ruby -v
ruby 1.4.3 (1999-12-08) [i586-linux-gnu]
# uname -a
Linux system-xyz.ournet.wherever 2.2.9-27mdk #1 Mon Jun 14 16:44:05 CEST 1999 i586 unknown
# crontab -l
[...snip...]
9,19,29,39,39,49,59 * * * Mon-Fri /usr/local/bin/logs2web -n ccdserv appserv devserv stat1 stat2 sysadm dbserv1 "172.16.3.71" "172.16.3.72" "172.16.3.73"
4,14,24,34,44,54 * * * Mon-Fri /usr/local/bin/logs2web -sn xntpd named oracle syslog syslogd vmunix unix kernel ftpd telnetd hosts.allow
5,15,25,35,45,55 * * * Mon-Fri /usr/local/bin/logs2web -sh hosts.allow
[...snip...]
# rpm -qi ruby
Name        : ruby                         Relocations: /usr
Version     : 1.4.3                             Vendor: MandrakeSoft
Release     : 3mdk                          Build Date: Tue Feb 15 19:47:28 2000
Install date: Thu Mar  2 17:00:27 2000      Build Host: kenobi.mandrakesoft.com
Group       : Development/Languages         Source RPM: ruby-1.4.3-3mdk.src.rpm
Size        : 2313282                          License: GPL
Packager    : Atsushi Yamagata <yamagata@plathome.co.jp>
URL         : http://www.netlab.co.jp/ruby/jp/
Summary     : Object Oriented Script Language
Description :
Ruby is the interpreted scripting language for quick and
easy object-oriented programming.  It has many features to
process text files and to do system management tasks (as in
Perl).  It is simple, straight-forward, and extensible.

The message:
/usr/local/bin/logs2web:2: [BUG] Segmentation fault

The script:
#!/usr/bin/env ruby

require("getopts")

#----------------------------------
#  CLASSES
#----------------------------------

class File
   def File.any_exist? (*files)

#     the flatten is necessary for
#     cases where the argument is an array -
#     instead of strings.
#
#     any_exist("fooe", "foo2") ===> files == [ "fooe", "foo2" ]
#     any_exist(ary)            ===> files == [[ "fooe", "foo2" ]]

      return (files.flatten.find { |file|
         File.exist?(file)
         }) != nil
   end

   def File.zap_existing (*files)
      files.flatten.select { |file|
         File.exist?(file)
      }.each { |file|
         File.unlink(file)
#        File.unlink(file + ".html") if File.exist?(file + ".html")
         }
   end
end

class MessageWork < File
   @message_work = "message." + $$.to_s
   @lines = 5000

   def MessageWork.create
      system "/usr/bin/tail -#{@lines} /var/log/messages > #{@message_work}" 
   end

   def MessageWork.split
      $*.each { |sys|
         next if sys == "others"
         if ($subsystems)
            system "egrep ':.. [^ ]* (in\.|)#{sys}' #{@message_work} > #{sys}"
         else
            system "grep ':.. #{sys} ' #{@message_work} > #{sys}"
         end
         }
   end

   def MessageWork.others
      system "cat " + $*.join(" ") + " #{@message_work} | sort | uniq -u > others"
   end

   def MessageWork.erase
      unlink(@message_work) unless $keep
   end
end

class WebPage
   def initialize (name)
      @page_name = name + ".html"
      @log_name = name
      @web_page = "/home/httpd/html/it/unix/logs/" + @page_name
   end

   def install
      File.rename(@page_name, @web_page)
   end

   def create
      opts = ""
      opts += "-n" if $no_color
      opts += "-h" if $host_file

#     system "/usr/bin/time -f \"real %e, user %U, sys %S\" nice /usr/local/bin/log2html #{opts} #{@log_name} > #{@page_name}"
      system "/usr/local/bin/log2html #{opts} #{@log_name} > #{@page_name}"
      File.unlink(@log_name)
   end
end

#----------------------------------
#  MAIN PROGRAMME
#----------------------------------

getopts("skznh")

$subsystems = $OPT_s
$host_file = $OPT_h
$keep = $OPT_k
$no_color = $OPT_n
$zap_old_files = $OPT_z

Dir.chdir("/tmp/log2html")

if File.any_exist?($*)
   if $zap_old_files
      File.zap_existing($*)
   else
      exit 1
   end
end

MessageWork.create
MessageWork.split

if ! $subsystems
   MessageWork.others
   $*.push "others"
end

MessageWork.erase

$*.each { |sys|
   page = WebPage.new(sys)
   page.create
   page.install
   }



>>> matz@netlab.co.jp 5/23/00 10:15p >>>
Hi,

In message "[ruby-talk:02955] Messages: [BUG] Segmentation Fault"
    on 00/05/23, "David Douthitt" <DDouthitt@cuna.com> writes:

|What causes these?  I got several under HP-UX 10.20 first week I used Ruby; now I'm getting them under Linux Mandrake with kernel 2.2.9-27mdk.
|
|They are popping up in a cron job, and no changes have been made to the code or to the system.

Could you show me detailed information?

Ruby version, platform, error reproducing script (preferably small),
input, output, etc.

							matz.

In This Thread

Prev Next