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

make std_spec fails on b8a24e7d9 #14174

Closed
femto opened this issue Jan 6, 2024 · 7 comments
Closed

make std_spec fails on b8a24e7d9 #14174

femto opened this issue Jan 6, 2024 · 7 comments

Comments

@femto
Copy link
Contributor

femto commented Jan 6, 2024

Bug Report

....................................................................................................................................................................................Invalid memory access (signal 11) at address 0x(???)
[0x10b026e1b] *Exception::CallStack::print_backtrace:Nil +107 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a59eddd] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil)@src/crystal/system/unix/signal.cr:131 +285 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x7ff80e2c6dfd] _sigtramp +29 in /usr/lib/system/libsystem_platform.dylib
make: *** [std_spec] Error 11

not sure whether this relevant:

Using /usr/local/opt/llvm/bin/llvm-config [version= 17.0.6]
CRYSTAL_CONFIG_BUILD_COMMIT="b8a24e7d9" CRYSTAL_CONFIG_PATH='$ORIGIN/../share/crystal/src' SOURCE_DATE_EPOCH="1704452537"  CRYSTAL_CONFIG_LIBRARY_PATH='$ORIGIN/../lib/crystal' ./bin/crystal build -D strict_multi_assign -D preview_overload_order -Dwithout_interpreter  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib -D use_pcre2
Using compiled compiler at .build/crystal
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
Using /usr/local/opt/llvm/bin/llvm-config [version= 17.0.6]
./bin/crystal build -D strict_multi_assign -D preview_overload_order -Dwithout_interpreter  --exclude-warnings spec/std --exclude-warnings spec/compiler --exclude-warnings spec/primitives -o .build/std_spec spec/std_spec.cr
Using compiled compiler at .build/crystal
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
ld: warning: dylib (/usr/local/Cellar/llvm/17.0.6/lib/libunwind.dylib) was built for newer macOS version (12.6) than being linked (12.0)
.build/std_spec --order=random   
0.2.5

it outputs twice uses ... and gives ld warning

@Sija
Copy link
Contributor

Sija commented Jan 6, 2024

@femto What macOS version are you using?

@femto
Copy link
Contributor Author

femto commented Jan 7, 2024

mac 12.4

@femto
Copy link
Contributor Author

femto commented Jan 9, 2024

is it possible to isolate the testcase that causes the failure?

today running:

.....................................................................................................*...................................................................................................................Invalid memory access (signal 11) at address 0x(???)
[0x10a28ff8b] *Exception::CallStack::print_backtrace:Nil +107 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x109807eed] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil)@src/crystal/system/unix/signal.cr:131 +285 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x7ff8105c0dfd] _sigtramp +29 in /usr/lib/system/libsystem_platform.dylib
[0x7ff817d7fa7b] xmlFindCharEncodingHandler +175 in /usr/lib/libxml2.2.dylib
[0x7ff817de82b1] xmlNewSaveCtxt +103 in /usr/lib/libxml2.2.dylib
[0x7ff817de8490] xmlSaveToIO +31 in /usr/lib/libxml2.2.dylib
[0x10adc0e61] *XML::Node#to_xml<String::Builder>:String::Builder +513 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10adc0c59] *XML::Node#to_s<String::Builder>:Nil +9 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10aeff99e] *XML::NodeSet@Enumerable(T)#join<String::Builder, Char>:Nil +158 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10aeff8fe] *XML::NodeSet#to_s<String::Builder>:Nil +14 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10aeff8d2] *XML::NodeSet@Object#to_s:String +66 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a1f9a0d] ~procProc(Nil)@spec/std/xml/xpath_spec.cr:210 +141 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a7c91a0] *Spec::Example#internal_run<Time::Span, Proc(Nil)>:(Array(Spec::Result) | Nil) +224 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a7c9092] *Spec::Example#run:Nil +1234 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a7cc64a] *Spec::ExampleGroup@Spec::Context#internal_run:Nil +122 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a7cc4f7] *Spec::ExampleGroup#run:Nil +359 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a69ed84] *Spec::RootContext+@Spec::Context#internal_run:Nil +164 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a69ecda] *Spec::RootContext+@Spec::RootContext#run:Nil +26 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a657cc0] *Spec::execute_examples:Nil +32 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10984d380] ~procProc(Int32, (Exception | Nil), Nil)@src/spec/dsl.cr:208 +64 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a5d97fe] *Crystal::AtExitHandlers::run<Int32, (Exception+ | Nil)>:Int32 +142 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a8823e1] *Crystal::exit<Int32, (Exception+ | Nil)>:Int32 +33 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x10a882361] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +97 in /Users/femtozheng/c-project/crystal/.build/std_spec
[0x1097896e9] main +9 in /Users/femtozheng/c-project/crystal/.build/std_spec
make: *** [std_spec] Error 11

also why is uses ... outputs twice,
and what does ld gives that warning mean?

@Blacksmoke16
Copy link
Member

Blacksmoke16 commented Jan 9, 2024

I'm able to reproduce on Mac 14.2 as well. Seems related to libxml2 as the error comes from xpath_spec, however I haven't been able to narrow down a more minimal reproducible example just yet. Based on the trace, something with turning an XML::NodeSet into a string?

@Blacksmoke16
Copy link
Member

Blacksmoke16 commented Jan 9, 2024

Somewhat minimal example:

  • Only reproduces when ran in spec context
  • Only reproduces when all it blocks are present
    • Removing any 1 will cause it not to happen
Example Code
require "spec"
require "xml"

private def doc
  XML.parse(%(\
    <?xml version='1.0' encoding='UTF-8'?>
    <people>
      <person id="1">
        <name>John</name>
      </person>
      <person id="2">
        <name>Peter</name>
      </person>
    </people>
    ))
end

it "finds with variable binding (bool)" do
  doc = XML.parse(%(\
        <?xml version="1.0" encoding="UTF-8"?>
        <feed>
          <person id="1"/>
          <person id="2"/>
        </feed>
        ))
  result = doc.xpath_bool("count(//feed/person[@id=$value]) = 1", variables: {"value" => 2})
  result.should be_true
end

it "finds with variable binding (float)" do
  doc = XML.parse(%(\
        <?xml version="1.0" encoding="UTF-8"?>
        <feed>
          <person id="1"/>
          <person id="2"/>
        </feed>
        ))
  result = doc.xpath_float("count(//feed/person[@id=$value])", variables: {"value" => 2})
  result.should eq(1.0)
end

it "finds with variable binding (nodes)" do
  doc = XML.parse(%(\
        <?xml version="1.0" encoding="UTF-8"?>
        <feed>
          <person id="1"/>
          <person id="2"/>
        </feed>
        ))
  nodes = doc.xpath_nodes("//feed/person[@id=$value]", variables: {"value" => 2})
  nodes.size.should eq(1)
  nodes[0]["id"].should eq("2")
end

it "finds with variable binding (node)" do
  doc = XML.parse(%(\
        <?xml version="1.0" encoding="UTF-8"?>
        <feed>
          <person id="1"/>
          <person id="2"/>
        </feed>
        ))
  node = doc.xpath_node("//feed/person[@id=$value]", variables: {"value" => 2}).not_nil!
  node["id"].should eq("2")
end

it "finds with variable binding (string)" do
  doc = XML.parse(%(\
        <?xml version="1.0" encoding="UTF-8"?>
        <feed>
          <person id="1"/>
          <person id="2"/>
        </feed>
        ))
  result = doc.xpath_string("string(//feed/person[@id=$value]/@id)", variables: {"value" => 2})
  result.should eq("2")
end

it "NodeSet#to_s" do
  doc = doc()
  doc.xpath("//people/person").to_s
end

@beta-ziliani
Copy link
Member

beta-ziliani commented Jan 9, 2024

Ah, we had that before, it's likely using the lib from the OS that is broken. The solution is here.

@femto can you try and tell us if that fixes it?

@Blacksmoke16
Copy link
Member

In my case brew had libxml2 installed at /usr/local/opt/libxml2. But can confirm adding those ENV vars resolved the error. Going to close in favor of #10365.

@Blacksmoke16 Blacksmoke16 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants