ruby-numo / numo-narray

Ruby/Numo::NArray - New NArray class library
http://ruby-numo.github.io/narray/
BSD 3-Clause "New" or "Revised" License
418 stars 42 forks source link

segmentation fault when empty NArray calls flatten. #55

Closed tamuratak closed 7 years ago

tamuratak commented 7 years ago

Hi, Segmentation fault occurs in the following code.

require "numo/narray"
Numo::SFloat[].flatten

Crash Report

$ ruby2.3 t.rb
t.rb:3: [BUG] na_flaten_dim: start_dim (0) out of range
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin13]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.
Don't forget to include the above Crash Report log file in bug reports.

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0007 e:000006 CFUNC  :flatten
c:0002 p:0026 s:0004 E:000d40 EVAL   t.rb:3 [FINISH]
c:0001 p:0000 s:0002 E:000370 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
t.rb:3:in `<main>'
t.rb:3:in `flatten'

-- C level backtrace information -------------------------------------------
0   libruby.2.3.0.dylib                 0x0000000106cfedca rb_print_backtrace + 29
1   libruby.2.3.0.dylib                 0x0000000106cfefa5 rb_vm_bugreport + 368
2   libruby.2.3.0.dylib                 0x0000000106be26ce rb_bug + 207
3   narray.bundle                       0x0000000106f65d96 na_flatten + 0
4   libruby.2.3.0.dylib                 0x0000000106cfd16c vm_call_cfunc + 345
5   libruby.2.3.0.dylib                 0x0000000106cfc82a vm_call_method_each_type + 104
6   libruby.2.3.0.dylib                 0x0000000106cfe198 vm_call_general + 240
7   libruby.2.3.0.dylib                 0x0000000106ce6d87 vm_exec_core + 9368
8   libruby.2.3.0.dylib                 0x0000000106cf2a68 vm_exec + 122
9   libruby.2.3.0.dylib                 0x0000000106be7772 ruby_exec_internal + 148
10  libruby.2.3.0.dylib                 0x0000000106be76af ruby_run_node + 78
11  ruby2.3                             0x0000000106babf26 main + 79

Versions of ruby and numo::narray are

$ gem2.3 list --local numo-narray

*** LOCAL GEMS ***

numo-narray (0.9.0.4)
$ ruby2.3 -v  
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin13]

Regards.

masa16 commented 7 years ago

fixed. thank you.

tamuratak commented 7 years ago

Thank you too.