DragonBox / u3d

U3d is a cross-platform set of tools to interact with Unity3D from command line.
MIT License
361 stars 33 forks source link

Segmentation Fault with Win32API #414

Closed enes-oerdek closed 2 years ago

enes-oerdek commented 3 years ago

Issue Checklist

Issue Description

Hey folks! First of all, great project. I'm astonished how easy it is to install unity and it's modules with this application. Unfortunately I face an issue. I hope you can help me with this.

I am using u3d on windows server 2019, since I want to use u3d in a build pipeline with windows build artifacts. Installing one Unity Version works fine. After trying to install another Unity Version or list versions, I get the following log:

u3d list
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/installation.rb:354: warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/win32api-0.1.0/lib/Win32API.rb:42: [BUG] Segmentation fault
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0021 p:---- s:0132 e:000131 CFUNC  :call
c:0020 p:0025 s:0125 e:000124 METHOD C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/win32api-0.1.0/lib/Win32API.rb:42
c:0019 p:0306 s:0118 e:000117 METHOD C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/installation.rb:382
c:0018 p:0015 s:0096 e:000095 METHOD C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/installation.rb:350
c:0017 p:0003 s:0092 e:000091 METHOD C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/installation.rb:330
c:0016 p:0005 s:0086 e:000085 METHOD C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/installation.rb:393
c:0015 p:0029 s:0079 e:000077 BLOCK  C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/u3d-1.2.3/lib/u3d/commands.rb:56 [FINISH]

Here Iattached the full log: u3d-issue-fulllog.txt

It seems to be an issue with the syscall on win32api. Since other syscalls work fine, probably some particular syscalls have some errors. Unfortunately I only have shallow experience in this regard. I hope you can help me with this.

justonia commented 3 years ago

Having the same issue in Win10 x64.

DrFritzi commented 3 years ago

I solved this by installing ruby 2.7.2. Every newer version of ruby causes this problem.

ghost commented 2 years ago

Perhaps the installation remarks can be updated to include this requirement for older-Ruby-version?

lacostej commented 2 years ago

I missed this. I guess we need to implement support with fiddle in ruby > 2.7.

I don't usually use Windows. I could need some help to test a few things.

Anyone wants to give a hand?

ghost commented 2 years ago

I'd be thrilled to help test

lacostej commented 2 years ago

you could try the following

  1. download u3d's git source code
  2. git checkout features/win32/ruby3
  3. bundle install
  4. bundle console
U3d::Utils.windows_local_appdata
  1. report results.

That's just a start...

lacostej commented 2 years ago

@crowder-pw I've made a few changes, but they probably don't even compile. I'll try to get hold of a windows computer. If you end up having some time, you can try the branch I pushed and start with the instructions above. In the case this works, you might want to play with

U3d::WindowsInstallationHelper.new(path_to_an_unity_exe).version

Code might need a few fixes.

ghost commented 2 years ago
c:\u3d>bundle console
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
[DEPRECATED] bundle console will be replaced by `bin/console` generated by `bundle gem <name>`
c:/u3d/lib/u3d/unity_license.rb:23:in `require': cannot load such file -- rexml/document (LoadError)
    from c:/u3d/lib/u3d/unity_license.rb:23:in `<top (required)>'
    from c:/u3d/lib/u3d.rb:40:in `require'
    from c:/u3d/lib/u3d.rb:40:in `<top (required)>'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:60:in `require'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:55:in `each'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:55:in `block in require'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:44:in `each'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/runtime.rb:44:in `require'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler.rb:175:in `require'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/cli/console.rb:15:in `run'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/cli.rb:508:in `console'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/cli.rb:31:in `dispatch'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/cli.rb:25:in `start'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/exe/bundle:49:in `block in <top (required)>'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
    from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.2.30/exe/bundle:37:in `<top (required)>'
    from C:/Ruby31-x64/bin/bundle:25:in `load'
    from C:/Ruby31-x64/bin/bundle:25:in `<main>'
lacostej commented 2 years ago

@crowder-pw could you try again after pulling the latest from the branch? I've fixed ruby 3.0 and 3.1 windows compatibility.

ghost commented 2 years ago
c:\u3d>bundle console
[DEPRECATED] bundle console will be replaced by `bin/console` generated by `bundle gem <name>`
irb(main):001:0> U3d::Utils.windows_local_appdata
=> "C:/Users/crowd/AppData/Local"
irb(main):002:0>
ghost commented 2 years ago

Should I open a separate bug for this:

irb(main):009:0> U3d::WindowsInstallationHelper.new("C:/Program Files/Unity/Hub/Editor/2020.3.4f1/Editor/Unity.exe").version
c:/u3d/lib/u3d/utils.rb:266: [BUG] Segmentation fault
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x64-mingw-ucrt]

-- Control frame information -----------------------------------------------
c:0035 p:---- s:0214 e:000213 CFUNC  :call
c:0034 p:0558 s:0207 e:000206 METHOD c:/u3d/lib/u3d/utils.rb:266
c:0033 p:0027 s:0182 e:000181 METHOD c:/u3d/lib/u3d/installation.rb:368
c:0032 p:0003 s:0178 e:000177 METHOD c:/u3d/lib/u3d/installation.rb:348
c:0031 p:0019 s:0172 e:000171 EVAL   (irb):9 [FINISH]
c:0030 p:---- s:0169 e:000168 CFUNC  :eval
c:0029 p:0020 s:0161 e:000160 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb/workspace.rb:119
c:0028 p:0054 s:0153 e:000151 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb/context.rb:476
c:0027 p:0161 s:0144 e:000143 BLOCK  C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:577
c:0026 p:0024 s:0139 e:000138 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:770
c:0025 p:0007 s:0133 e:000132 BLOCK  C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:558
c:0024 p:0123 s:0128 e:000127 BLOCK  C:/Ruby31-x64/lib/ruby/3.1.0/irb/ruby-lex.rb:268 [FINISH]
c:0023 p:---- s:0124 e:000123 CFUNC  :loop
c:0022 p:0005 s:0120 e:000119 BLOCK  C:/Ruby31-x64/lib/ruby/3.1.0/irb/ruby-lex.rb:250 [FINISH]
c:0021 p:---- s:0117 e:000116 CFUNC  :catch
c:0020 p:0010 s:0112 e:000111 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb/ruby-lex.rb:249
c:0019 p:0047 s:0108 E:002448 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:557
c:0018 p:0003 s:0103 e:000102 BLOCK  C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:491 [FINISH]
c:0017 p:---- s:0100 e:000099 CFUNC  :catch
c:0016 p:0057 s:0095 E:000940 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:490
c:0015 p:0104 s:0089 e:000088 METHOD C:/Ruby31-x64/lib/ruby/3.1.0/irb.rb:419
c:0014 p:0109 s:0083 e:000082 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/cli/console.rb:19c:0013 p:0027 s:0078 e:000077 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/cli.rb:513
c:0012 p:0054 s:0073 e:000072 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/command.rb:27
c:0011 p:0040 s:0065 e:000064 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/invocation.rb:127
c:0010 p:0239 s:0058 e:000057 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor.rb:392
c:0009 p:0008 s:0045 e:000044 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/cli.rb:31
c:0008 p:0066 s:0040 e:000039 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/vendor/thor/lib/thor/base.rb:485
c:0007 p:0008 s:0033 e:000032 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/cli.rb:25
c:0006 p:0108 s:0028 e:000027 BLOCK  C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/exe/bundle:48
c:0005 p:0014 s:0022 e:000021 METHOD C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/lib/bundler/friendly_errors.rb:103
c:0004 p:0272 s:0017 E:000618 TOP    C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.11/exe/bundle:36 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC  :load
c:0002 p:0127 s:0008 E:001b00 EVAL   C:/Ruby31-x64/bin/bundle:25 [FINISH]
c:0001 p:0000 s:0003 E:000e60 (none) [FINISH]

?

lwangwangl commented 2 years ago

ruby 3.1.2 ,still the same error

lacostej commented 2 years ago

@lwangwangl @crowder-pw thanks. I've now setup circle ci builds and some unit tests so I can see that the implementation isn't doing what it should. It's much easier to experiment directly with a windows computer though!

lacostej commented 2 years ago

I think the latest version should work good enough for now. Could you try the same code from the master branch?

ghost commented 2 years ago

Huzzah!

irb(main):003:0> U3d::WindowsInstallationHelper.new("C:/Program Files/Unity/Hub/Editor/2020.3.4f1/Editor/Unity.exe").version
=> "2020.3.4f1"
lacostej commented 2 years ago

Fixed with #417 417