[#11822] RCR: Input XML support in the base Ruby — Dave Thomas <Dave@...>

15 messages 2001/03/01

[#11960] Not Ruby, for me, for the moment at least — "Michael Kreuzer" <mkreuzer@... (nospam)>

I wrote on this newsgroup last weekend about how I was considering using

11 messages 2001/03/04

[#12023] French RUG ? — "Jerome" <jeromg@...>

Hi fellow rubyers,

16 messages 2001/03/05

[#12103] disassembling and reassembling a hash — raja@... (Raja S.)

Given a hash, h1, will the following always hold?

20 messages 2001/03/06

[#12204] FEATURE REQUEST: 'my' local variables — Leo Razoumov <see_signature@127.0.0.1>

Ruby is, indeed, a very well designed language.

64 messages 2001/03/07
[#12250] Re: FEATURE REQUEST: 'my' local variables — Leo Razoumov <see_signature@127.0.0.1> 2001/03/07

>>>>> "GK" == GOTO Kentaro <gotoken@math.sci.hokudai.ac.jp> writes:

[#12284] Re: FEATURE REQUEST: 'my' local variables — gotoken@... (GOTO Kentaro) 2001/03/08

In message "[ruby-talk:12250] Re: FEATURE REQUEST: 'my' local variables"

[#12289] Re: FEATURE REQUEST: 'my' local variables — matz@... (Yukihiro Matsumoto) 2001/03/08

Hi,

[#12452] Re: FEATURE REQUEST: 'my' local variables — gotoken@... (GOTO Kentaro) 2001/03/12

In message "[ruby-talk:12289] Re: FEATURE REQUEST: 'my' local variables"

[#12553] Re: FEATURE REQUEST: 'my' local variables — Dave Thomas <Dave@...> 2001/03/13

matz@zetabits.com (Yukihiro Matsumoto) writes:

[#12329] Math package — Mathieu Bouchard <matju@...>

18 messages 2001/03/09

[#12330] Haskell goodies, RCR and challenge — Robert Feldt <feldt@...>

Hi,

19 messages 2001/03/09
[#12374] Re: Haskell goodies, RCR and challenge — matz@... (Yukihiro Matsumoto) 2001/03/10

Hi,

[#12349] Can Ruby-GTK display Gif Png or Jpeg files? — Phlip <phlip_cpp@...>

Ruby-san:

20 messages 2001/03/09

[#12444] class variables — Max Ischenko <max@...>

14 messages 2001/03/12

[#12606] Order, chaos, and change requests :) — Dave Thomas <Dave@...>

17 messages 2001/03/14

[#12635] email address regexp — "David Fung" <dfung@...>

i would like to locate probable email addresses in a bunch of text files,

12 messages 2001/03/14

[#12646] police warns you -- Perl is dangerous!! — Leo Razoumov <see_signature@127.0.0.1>

I just read this story on Slashdot

14 messages 2001/03/14
[#12651] Re: police warns you -- Perl is dangerous!! — pete@... (Pete Kernan) 2001/03/14

On 14 Mar 2001 11:46:35 -0800, Leo Razoumov <see_signature@127.0.0.1> wrote:

[#12691] Re: police warns you -- Perl is dangerous!! — "W. Kent Starr" <elderburn@...> 2001/03/15

On Wednesday 14 March 2001 15:40, Pete Kernan wrote:

[#12709] [OFFTOPIC] Re: police warns you -- Perl is dangerous!! — Stephen White <spwhite@...> 2001/03/16

On Fri, 16 Mar 2001, W. Kent Starr wrote:

[#12655] Re: FEATURE REQUEST: 'my' local variables — "Benjamin J. Tilly" <ben_tilly@...>

>===== Original Message From Leo Razoumov <see_signature@127.0.0.1> =====

18 messages 2001/03/14

[#12706] Library packaging — "Nathaniel Talbott" <ntalbott@...>

I have a project that I'm working on that needs to live two different lives,

30 messages 2001/03/16

[#12840] Looking for a decent compression scheme — Dave Thomas <Dave@...>

14 messages 2001/03/19

[#12895] differences between range and array — "Doug Edmunds" <dae_alt3@...>

This code comes from the online code examples for

16 messages 2001/03/20
[#12896] Re: differences between range and array — "Hee-Sob Park" <phasis@...> 2001/03/20

[#12899] Re: differences between range and array — Jim Freeze <jim@...> 2001/03/20

On Tue, 20 Mar 2001, Hee-Sob Park wrote:

[#12960] TextBox ListBox — Ron Jeffries <ronjeffries@...>

Attached is a little Spike that Chet and I are doing. It is a

13 messages 2001/03/20

[#12991] [ANN] Lapidary 0.2.0 — "Nathaniel Talbott" <ntalbott@...>

Well, here's my first major contribution to the Ruby world: Lapidary. It's a

16 messages 2001/03/20

[#13028] mkmf question — Luigi Ballabio <luigi.ballabio@...>

15 messages 2001/03/21

[#13185] Reading a file backwards — "Daniel Berger" <djberg96@...>

Hi all,

21 messages 2001/03/25
[#13197] Re: Reading a file backwards — "Daniel Berger" <djberg96@...> 2001/03/25

> Hi Dan,

[#13203] Re: Reading a file backwards — Mathieu Bouchard <matju@...> 2001/03/25

On Sun, 25 Mar 2001, Daniel Berger wrote:

[#13210] Re: Reading a file backwards — "Daniel Berger" <djberg96@...> 2001/03/25

"Mathieu Bouchard" <matju@sympatico.ca> wrote in message

[#13374] Passing an array to `exec'? — Lloyd Zusman <ljz@...>

I'd like to do the following:

15 messages 2001/03/31

[#13397] Multidimensional arrays and hashes? — Lloyd Zusman <ljz@...>

Is it possible in ruby to make use of constructs that correspond to

14 messages 2001/03/31

[ruby-talk:12540] Strange segmentation fault problem with C++ extension

From: "Paul C" <paul_c@...>
Date: 2001-03-13 04:40:04 UTC
List: ruby-talk #12540
Hi,

I have been beating my head against the monitor for a couple of days with a
repeatable segmentation problem with a C++ extension - I am sure that there
is something obvious that I am missing and would be grateful for any advice.

I am trying to create a Ruby wrapper for the ZIPIOS C++ Zip file reader
library (http://zipios.sourceforge.net). I managed to get this mostly
working however I have been stuck with a deterministic problem with the
extension core dumping in the method to extract a zip file entry under the
following conditions -

- Running under IRB

- Calling the method without a 'begin/rescue' block (ie caught interactively
by IRB)

- (Optional) Call the method with a filename which exists in archive -> OK

- Call the method with a filename which does not exist in the archive ->
Throws an exception

- Call the method with a filename which does exist -> Core Dump

If the failing method call is enclosed in a begin/rescue block the problem
goes away (which would always be the case outside the interactive shell).

If the method is called multiple times with a valid entry or even multiple
times with an invalid entry it works fine - it is just the sequence
invalid/valid which causes the program to crash.

Unfortunately I am not a C++ programmer (and following this experience have
no desire to become one) so I would ask you to excuse the code - however I
wasnt able to find a C Zip file library. I am concerned that there is an
underlying problem in the code somewhere which is causing this but havent
been able to make any progress (I will of course be releasing the module to
the RAA once I get this fixed).

I have instrumented the module and the strange thing is that there is no
apparent difference in the calling sequence between a method that succeeds
and a subsequent method that causes a segmentation fault (after an
intervening request for an non-existant entry).

The source code for the method that is failing is at the end of the
message - if anyone would like the source code to the whole extension please
let me know and I will e-mail it.

The debug trace below is equivalent for the first/third calls (which should
be the same without the failing call between them). The final debug print of
the return VALUE is generated immediately before the method returns and
shows the the VALUE to be returned has been created successfully within the
method. The method segemntation faults when the functio tries to return the
VALUE.

I am at a loss as to why this happens - any suggestions ?

Regards, Paul

PS. I forgot the obligatory thanks to Matz and the Ruby community for a
great language - it is a pleasure to use (and hopefully extend if I can get
this !#$&&*# module working!)

PPS. Versions are - Ruby 1.6.3 / NetBSD 1.5

=========== DEBUG TRACE ===========

# irb --prompt xmp

require 'Zip'
    ==>true

z = Zip::ZipFile.new "test.zip"
    ==>#<Zip::ZipFile:0x816c424 @name="test.zip">

z.entries { |e| print e.path, "\n" }   # Get Zip Directory
extconf.rb
Makefile
    ==>#<Zip::ZipFile:0x816c424 @name="test.zip">

z.entry "extconf.rb"                   # OK
    (zip.cpp:186) MSG: Entering Function #ZipFile_entry
    (zip.cpp:187) VALUE: self -> #<Zip::ZipFile:0x816c424 @name="test.zip">
    (zip.cpp:191) PTR: ZipFile ->135501760
    (zip.cpp:201) MSG: GetEntry OK
    (zip.cpp:203) PTR: ConstEntryPointer ->135870784
    (zip.cpp:205) VALUE: zipLocalEntry -> #<Zip::ZipEntry:0x81545cc
@path="extconf.rb">
    ==>#<Zip::ZipEntry:0x81545cc @path="extconf.rb">

z.entry "zzzzzzz"                      # Invalid Entry
    (zip.cpp:186) MSG: Entering Function #ZipFile_entry
    (zip.cpp:187) VALUE: self -> #<Zip::ZipFile:0x816c424 @name="test.zip">
    (zip.cpp:191) PTR: ZipFile ->135501760
    (zip.cpp:196) MSG: GetEntry Failed
RuntimeError: Entry not found
(irb):10:in `entry'
(irb):10:in `irb_binding'

z.entry "extconf.rb"                   # Should be OK
    (zip.cpp:186) MSG: Entering Function #ZipFile_entry
    (zip.cpp:187) VALUE: self -> #<Zip::ZipFile:0x816c424 @name="test.zip">
    (zip.cpp:191) PTR: ZipFile ->135501760
    (zip.cpp:201) MSG: GetEntry OK
    (zip.cpp:203) PTR: ConstEntryPointer ->136008256
    (zip.cpp:205) VALUE: zipLocalEntry -> #<Zip::ZipEntry:0x814d36c
@path="extconf.rb">
(irb):12: [BUG] Segmentation fault
ruby 1.6.3 (2001-03-07) [i386-netbsd1.5]
Abort (core dumped)

=========== METHOD SOURCE ===========

static VALUE ZipFile_entry ( VALUE self, VALUE name ) {

    VALUE zipLocalEntry = Qnil ;
    ConstEntryPointer entry ;
    ConstEntryPointer *ptr_entry ;
    ZipFile *zf ;

    const string sname = STR2CSTR(name) ;

    DEBUG_MSG("Entering Function #ZipFile_entry") ;
    DEBUG_VALUE("self",self) ;

    Get_ZipFile ( self, zf ) ;

    DEBUG_PTR("ZipFile",zf) ;

    try {
        if ( (entry = zf->getEntry(sname)) == 0 ) {

            DEBUG_MSG("GetEntry Failed") ;
            rb_raise ( rb_eRuntimeError, "Entry not found" ) ;
        }
        else {

            DEBUG_MSG("GetEntry OK") ;
            ptr_entry = new ConstEntryPointer ( entry ) ;
            DEBUG_PTR("ConstEntryPointer",ptr_entry) ;
            zipLocalEntry = ZipLocalEntry_new ( ptr_entry ) ;
            DEBUG_VALUE("zipLocalEntry",zipLocalEntry) ;

            return zipLocalEntry ;
        }
    }
    catch ( exception &excp ) {

        DEBUG_MSG("Exception") ;
        rb_raise ( rb_eRuntimeError, excp.what() ) ;
    }
}






In This Thread

Prev Next