Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRuby crashes when compiled with clang-cl #3197

Closed
dutow opened this issue Aug 18, 2016 · 6 comments
Closed

MRuby crashes when compiled with clang-cl #3197

dutow opened this issue Aug 18, 2016 · 6 comments

Comments

@dutow
Copy link

dutow commented Aug 18, 2016

It's easy to build mruby with clang-cl by changing the visual studio toolchain / adding another toolchain named clang_cl:

MRuby::Toolchain.new(:clang_cl) do |conf, _params|
  toolchain :visualcpp

  conf.cc.command = ENV['CC'] || 'clang-cl'
  conf.cxx.command = ENV['CXX'] || 'clang-cl'
end

But when running ruby minirake test or just mrbtest.exe it quickly crashes in an access violation at mrb_obj_respond_to with a long callstack starting with mrb_open, I attached the full callstack.

callstack.txt

@matz
Copy link
Member

matz commented Aug 19, 2016

From call stack list, the direct cause of SEGV is a name error raised before NameError class is initialized. b2fceae will reduce the chance of errors, but I am not sure if it fixes the issue.

@dutow
Copy link
Author

dutow commented Aug 19, 2016

Now it crashes later, but still in mrb_open:

>   mrbtest.exe!mrb_obj_respond_to() Line 1507  Unknown
    mrbtest.exe!mrb_check_convert_type() Line 310   Unknown
    mrbtest.exe!mrb_check_string_type() Line 1743   Unknown
    mrbtest.exe!join_ary() Line 990 Unknown
    mrbtest.exe!mrb_ary_join() Line 1014    Unknown
    mrbtest.exe!mrb_vformat() Line 345  Unknown
    mrbtest.exe!mrb_raisef() Line 369   Unknown
    mrbtest.exe!mrb_get_args() Line 534 Unknown
    mrbtest.exe!mrb_mod_append_features() Line 975  Unknown
    mrbtest.exe!mrb_funcall_with_block() Line 407   Unknown
    mrbtest.exe!mrb_funcall() Line 320  Unknown
    mrbtest.exe!mrb_mod_include() Line 991  Unknown
    mrbtest.exe!mrb_vm_exec() Line 1150 Unknown
    mrbtest.exe!mrb_vm_run() Line 760   Unknown
    mrbtest.exe!mrb_top_run() Line 2434 Unknown
    mrbtest.exe!mrb_load_irep_cxt() Line 638    Unknown
    mrbtest.exe!mrb_load_irep() Line 644    Unknown
    mrbtest.exe!mrb_init_mrblib() Line 10   Unknown
    mrbtest.exe!mrb_init_core() Line 50 Unknown
    mrbtest.exe!mrb_open() Line 114 Unknown
    mrbtest.exe!main() Line 149 Unknown

Unfortunately Visual Studio's debugger isn't too friendly when I try to debug a non-VS project executable with it (for example I can't see the values of variables with it), I'll try to find a better tool for this.

@Asmod4n
Copy link
Contributor

Asmod4n commented Aug 19, 2016

Do you have all debugging options on in mruby?

@dutow
Copy link
Author

dutow commented Aug 19, 2016

I'm testing it with the default build_config.rb which contains enable_debug, only changed the toolchain to the clang-cl one I included in the description.

The problem with the VS debugger is that when I open an executable with it (as I have no usable solution for building mruby), it correctly displays the source files for the methods on the call stack, but treats them as text files, and shows no debug information about the symbols. So I can traverse the call stack and see the current value of the registers but not the values of local variables / parameters in the IDE.

matz added a commit that referenced this issue Aug 19, 2016
To avoid VM nesting with mrb_funcall()
@matz
Copy link
Member

matz commented Aug 19, 2016

If you cannot use the debugger for your program, could you add the following line to the mrb_name_error() function in src/error.c please?

fprintf(stderr, "name_error(%s)\n", mrb_sym2name(mrb, id));

@dutow
Copy link
Author

dutow commented Dec 29, 2016

I tried to retest this with clang-4 (which finally added full msvc-compatble debugging capabilities) and the latest mruby, and I can't reproduce it: mruby compiles and works with clang-cl.

Another thing I just noticed that a new toolchain isn't required, as the vs toolchain uses the standard environment variables (CC,CXX,CFLAGS,CXXFLAGS).

@dutow dutow closed this as completed Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants