# Extension problem with the one-click installer

**URL:** <https://rubytalk.org/t/extension-problem-with-the-one-click-installer/12187>\
**Category:** ruby-talk\
**Created:** [18 June 2004 10:41 UTC](https://rubytalk.org/t/extension-problem-with-the-one-click-installer/12187 "2004-06-18T10:41:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Mitchell](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@Jeff\_Mitchell](https://rubytalk.org/u/Jeff_Mitchell)\
**Post date:** [18 June 2004 10:41 UTC](https://rubytalk.org/t/extension-problem-with-the-one-click-installer/12187/1 "2004-06-18T10:41:43Z")

</div>

Could someone confirm the following segfault for the one-click Windows  
installer (ruby181-13.exe). It occurs for the extension compiled with  
mingw32-gcc and with VC++ 6.0 SP5.

There is no problem for a homebuilt ruby from the 1.8.1 standard  
tarball with either mingw32-gcc or VC++.

> ruby test.rb

test.rb:2: [BUG] Segmentation fault  
ruby 1.8.1 (2003-12-25) [i386-mswin32]

> **···**
>
> -----------------------------------  
> # extconf.rb:  
> require 'mkmf'  
> create\_makefile("myclass")  
> -----------------------------------  
> # test.rb  
> require './myclass.so'  
> loop { MyClass.new }  
> -----------------------------------  
> // myclass.c  
> #include "ruby.h"
> 
> struct MyStruct\_  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;int n ;  
> } ;
> 
> typedef struct MyStruct\_ MyStruct ;
> 
> void myclass\_free(MyStruct\* data)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;free(data) ;  
> }
> 
> VALUE rb\_myclass\_initialize( VALUE self )  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;return Qnil ;  
> }
> 
> static VALUE rb\_myclass\_s\_allocate(VALUE klass)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;MyStruct\* data ;  
> &nbsp;&nbsp;&nbsp;&nbsp;VALUE obj = Data\_Make\_Struct(klass,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStruct,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myclass\_free,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;return obj ;  
> }
> 
> VALUE cMyClass ;
> 
> void Init\_myclass()  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;cMyClass = rb\_define\_class("MyClass", rb\_cObject) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;rb\_define\_alloc\_func(cMyClass, rb\_myclass\_s\_allocate) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;rb\_define\_method(cMyClass, "initialize", rb\_myclass\_initialize, 0) ;  
> }
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Do you Yahoo!?  
> Yahoo! Mail Address AutoComplete - You start. We finish.  
> [http://promotions.yahoo.com/new\_mail](http://promotions.yahoo.com/new_mail)

---

<div class="post-metadata">

**Author:** ![Jeff\_Mitchell](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@Jeff\_Mitchell](https://rubytalk.org/u/Jeff_Mitchell)\
**Post date:** [21 June 2004 18:43 UTC](https://rubytalk.org/t/extension-problem-with-the-one-click-installer/12187/2 "2004-06-21T18:43:12Z")

</div>

To the one-click installer team (or anyone else), have you

(1) Confirmed the bug by compiling the extension with VC++ 6.0 SP5?  
(2) ditto with mingw32?  
(3) what happened when you compiled the extension with VS.NET?  
(4) Try (1)-(3) using ruby compiled with VS.NET without runtime 7.1

Without a VS.NET compiler, I can only confirm (1) and (2), and that  
the bug is not present when the interpreter is built with mingw32 or  
with VC++ 6.0.

But whether or not this bug is related to the 7.1 runtime (it probably  
is), using a different runtime can't be a good thing. Ruby-win32 has  
deliberately chosen the msvcrt.dll runtime -- both the VC++ and  
mingw32 builds use it -- in order to make extensions compatible. But  
the one-click installer is not using it, and (surprise) extensions are  
not compatible.

Could you just use msvcrt.dll, please? If you must use VS.NET, it can  
be configured to create executables which do not depend on msvcrt71.dll.

Jeff

Jeff Mitchell \<quixoticsycophant@yahoo.com\> wrote in message news:\<20040618104140.62332.qmail@web60909.mail.yahoo.com\>...

Could someone confirm the following segfault for the one-click Windows  
installer (ruby181-13.exe). It occurs for the extension compiled with  
mingw32-gcc and with VC++ 6.0 SP5.

There is no problem for a homebuilt ruby from the 1.8.1 standard  
tarball with either mingw32-gcc or VC++.

> ruby test.rb

test.rb:2: [BUG] Segmentation fault  
ruby 1.8.1 (2003-12-25) [i386-mswin32]

> **···**
>
> ---original message---
> 
> -----------------------------------  
> # extconf.rb:  
> require 'mkmf'  
> create\_makefile("myclass")  
> -----------------------------------  
> # test.rb  
> require './myclass.so'  
> loop { MyClass.new }  
> -----------------------------------  
> // myclass.c  
> #include "ruby.h"
> 
> struct MyStruct\_  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;int n ;  
> } ;
> 
> typedef struct MyStruct\_ MyStruct ;
> 
> void myclass\_free(MyStruct\* data)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;free(data) ;  
> }
> 
> VALUE rb\_myclass\_initialize( VALUE self )  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;return Qnil ;  
> }
> 
> static VALUE rb\_myclass\_s\_allocate(VALUE klass)  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;MyStruct\* data ;  
> &nbsp;&nbsp;&nbsp;&nbsp;VALUE obj = Data\_Make\_Struct(klass,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStruct,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myclass\_free,  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;return obj ;  
> }
> 
> VALUE cMyClass ;
> 
> void Init\_myclass()  
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;cMyClass = rb\_define\_class("MyClass", rb\_cObject) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;rb\_define\_alloc\_func(cMyClass, rb\_myclass\_s\_allocate) ;  
> &nbsp;&nbsp;&nbsp;&nbsp;rb\_define\_method(cMyClass, "initialize", rb\_myclass\_initialize, 0) ;  
> }
