Forum: Ruby Problems with rb_struct_define and 64 bit Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel B. (Guest)
on 2006-06-08 09:04
(Received via mailing list)
Hi all,

Ruby 1.8.4, 64 bit, built with --enable-pthread - no other special
options
Suse Linux 9.3

It's late and I'm tired, so maybe I'm doing something dumb here, but
this
code segfaults:

/* foo.c */
#include "ruby.h"
VALUE v_my_struct;

void Init_foo(){
   v_my_struct =
      rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",
"gamma", 0);
}

# extconf.rb
require 'mkmf'
create_makefile('foo')

# test.rb
$:.unshift Dir.pwd
require 'foo'

Take away any one member, and it works.  Any more than five and it
segfaults.  What gives?

Thanks,

Dan
ts (Guest)
on 2006-06-08 11:23
(Received via mailing list)
>>>>> "D" == Daniel B. <removed_email_address@domain.invalid> writes:

D>       rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha",
"beta",
D> "gamma", 0);

   ^^^^^^^^^^

   "gamma", NULL);

D> }

  ...



Guy Decoux
Austin Z. (Guest)
on 2006-06-09 01:52
(Received via mailing list)
On 6/8/06, ts <removed_email_address@domain.invalid> wrote:
> >>>>> "D" == Daniel B. <removed_email_address@domain.invalid> writes:
> D>       rb_struct_define("MyStruct", "fee", "fi", "fo", "alpha", "beta",
> D> "gamma", 0);
>
>    ^^^^^^^^^^
>
>    "gamma", NULL);
>
> D> }

Gah. That's one of the things that I absolutely *despise* about C as
opposed to C++. I *like* that I can use 0 as if it were the same thing
as NULL and not (void*)0.

-austin
ts (Guest)
on 2006-06-09 12:00
(Received via mailing list)
>>>>> "A" == Austin Z. <removed_email_address@domain.invalid> writes:

A> Gah. That's one of the things that I absolutely *despise* about C as
A> opposed to C++. I *like* that I can use 0 as if it were the same
thing
A> as NULL and not (void*)0.

 Well, the architecture x86_64 was created to make in sort that C
 programmer understand the difference between (int)0 and (void *)0

 :-)


Guy Decoux
This topic is locked and can not be replied to.