icy-arctic-fox / spectator

Feature-rich testing framework for Crystal inspired by RSpec.
https://gitlab.com/arctic-fox/spectator
MIT License
101 stars 4 forks source link

Segfault with nilable substring method call #54

Closed Blacksmoke16 closed 11 months ago

Blacksmoke16 commented 11 months ago
require "spectator"

Spectator.describe Test do
  subject { ".jpg"[1, 3]? }

  context "with extension" do
    it { is_expected.to eq "jpg" }
  end
end

Removing the ? from [1, 3]? allows it to work. Otherwise you get:

Invalid memory access (signal 11) at address 0x0
[0x55cab0cf18e6] *Exception::CallStack::print_backtrace:Nil +118 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0cdad56] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil) +310 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x7f55aa6ae710] ?? +140005908080400 in /usr/lib/libc.so.6
[0x55cab0d066cd] *String#==<String>:Bool +45 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e5154c] *Spectator::Matchers::EqualityMatcher(String) +76 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e513dd] *Spectator::Matchers::EqualityMatcher(String) +45 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e5107d] *Spectator::Expectation::Target(String | Nil) +45 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e51047] *Spectator::Expectation::Target(String | Nil) +39 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e50b5b] *SpectatorTestContext::Group__temp_61::Group__temp_65#__temp_69:Nil +219 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0cdeddc] ~procProc(Spectator::Example, Nil) +44 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e14ac5] *Spectator::Example#run_internal:Nil +613 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0cdeab9] ~procProc(Nil) +9 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e22781] *Spectator::Example::Procsy#call:Nil +49 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e141ff] *Spectator::Example#run:Spectator::Result+ +2591 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e1e568] *Spectator::Runner#run_example<Spectator::Example>:Spectator::Result+ +72 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e1e467] *Spectator::Runner#run_examples:Nil +87 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e1e135] *Spectator::Runner#run:Bool +149 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e1a63a] *Spectator::Spec#run:Bool +298 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0dd43db] *Spectator +75 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0cdb4b6] ~procProc(Int32, (Exception | Nil), Nil) +38 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0d8f6a9] *Crystal::AtExitHandlers::run<Int32, (Exception+ | Nil)>:Int32 +153 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e56873] *Crystal::exit<Int32, (Exception+ | Nil)>:Int32 +35 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0e567e9] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +105 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x55cab0cd1766] main +6 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x7f55aa697cd0] ?? +140005907987664 in /usr/lib/libc.so.6
[0x7f55aa697d8a] __libc_start_main +138 in /usr/lib/libc.so.6
[0x55cab0cc37e5] _start +37 in /home/george/.cache/crystal/crystal-run-spec.tmp
[0x0] ???

ref: https://github.com/crimson-knight/gemma/commit/89a69a07c099bd811715034ee8f4944efdccc1ee#diff-ffba37829e0893c95e33ae6d0a862121341aca7775f0a6b7f6d9b624d9dd129eL66-R83

Blacksmoke16 commented 11 months ago

Seems to have been resolved via https://github.com/icy-arctic-fox/spectator/commit/9cbb5d2cf74410b5ac2f408a75b46be5708ee4fc.

icy-arctic-fox commented 11 months ago

Cut a release with this fix - v0.11.7.