I
Iñaki Baz Castillo
Hi, my C extension uses rb_define_alloc_func(cResolver,
Resolver_alloc) to initialite the C library. If something goes wrong
in that initialization I want to raise an exception but using
rb_raise() within Resolver_alloc() produces a segmentfault.
The function is very easy:
-------------------------------------------------------------------
VALUE Resolver_alloc(VALUE klass)
{
struct dns_ctx *dns_context;
VALUE obj;
if (dns_init(NULL, 0) < 0)
rb_raise(rb_eStandardError, "udns dns_init failed");
if (!(dns_context =3D dns_new(NULL)))
rb_raise(rb_eStandardError, "udns dns_new failed");
obj =3D Data_Wrap_Struct(klass, NULL, Resolver_free, dns_context);
return obj;
}
-------------------------------------------------------------------
In order to force the error I change the dns_init line as follows:
if (dns_init(NULL, 0) =3D=3D 0)
and get a segmentfault. Is not allowed to raise an exception in the
alloc function of a class?
Thanks.
--=20
I=C3=B1aki Baz Castillo
<[email protected]>
Resolver_alloc) to initialite the C library. If something goes wrong
in that initialization I want to raise an exception but using
rb_raise() within Resolver_alloc() produces a segmentfault.
The function is very easy:
-------------------------------------------------------------------
VALUE Resolver_alloc(VALUE klass)
{
struct dns_ctx *dns_context;
VALUE obj;
if (dns_init(NULL, 0) < 0)
rb_raise(rb_eStandardError, "udns dns_init failed");
if (!(dns_context =3D dns_new(NULL)))
rb_raise(rb_eStandardError, "udns dns_new failed");
obj =3D Data_Wrap_Struct(klass, NULL, Resolver_free, dns_context);
return obj;
}
-------------------------------------------------------------------
In order to force the error I change the dns_init line as follows:
if (dns_init(NULL, 0) =3D=3D 0)
and get a segmentfault. Is not allowed to raise an exception in the
alloc function of a class?
Thanks.
--=20
I=C3=B1aki Baz Castillo
<[email protected]>