Project

General

Profile

Bug #12994

Embedded ruby vs2015 build crashes

Added by fjilderd (Freddy Jilderda) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.4.0dev (2016-11-07 v2_4_0_preview2 56129) [i386-mswin32_140]
[ruby-core:78444]

Description

When an embedded ruby engine in a vs2015 application is initialised using ruby_init the function set_pioinfo_extra in win32.c is not called.
This results in a crash when ruby_init is called and it is trying to derefence the __pioinfo pointer in the _pioinfo function in win32.c

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Status changed from Open to Feedback

I don't know what is "an ruby embedded engine".
But I can say that you have to call rb_w32_sysinit before calling ruby_init on Windows.

Updated by fjilderd (Freddy Jilderda) over 3 years ago

I'm sorry I was not clear, what I mean is I'm updating a C++ application from VS2010 to VS2015. This application embeds a ruby engine (version 1.8.6), so that users of the application can uses ruby scripting to add custom functionality to the application.
I'm updating ruby from 1.8.6 to 2.4.0 as this will be the version that can be build using VS2015.
The code for initialising the ruby engine (that I know of) is:
-call ruby_init () to initialise the ruby vm
-call ruby_init_loadpath ()to make loading of modules possible (see for instance: http://stackoverflow.com/questions/626333/embedding-a-ruby-interpreter-in-a-c-app).

Also the function ruby_sysinit in ruby.c (which is the one calling rb_w32_sysinit) mentions in the header comment that this function should not be called by programs embedding the CRuby interpreter.

Updated by fjilderd (Freddy Jilderda) over 3 years ago

As a workaround I copy/pasted this code to the start of the _pioinfo function in win32.c (line 2462):

#if RUBY_MSVCRT_VERSION >= 140
    if (!__pioinfo) {
        set_pioinfo_extra ();
    }
#endif

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

Freddy Jilderda wrote:

Also the function ruby_sysinit in ruby.c (which is the one calling rb_w32_sysinit) mentions in the header comment that this function should not be called by programs embedding the CRuby interpreter.

Not to call ruby_sysinit doesn't mean not to call rb_w32_sysinit.

Updated by fjilderd (Freddy Jilderda) over 3 years ago

Ok, but the rb_w32_sysinit function is not declared in a header file.

Updated by naruse (Yui NARUSE) over 3 years ago

  • Target version set to 2.4
  • Assignee set to usa (Usaku NAKAMURA)
  • Status changed from Feedback to Assigned
#7

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Status changed from Assigned to Closed

Applied in changeset r57072.


declare rb_w32_sysinit in header.

  • include/ruby/win32.h (rb_w32_sysinit): declare.
    [ruby-core:78444] [Bug #12994]

  • ruby.c (ruby_sysinit): follow above change.

Also available in: Atom PDF