moovweb / tritium

Tritium is a magical document modifying language. It's JavaScript-like and simple to learn. Think XSLT without the nightmare. It was designed by Hampton Catlin (@hcatlin), and has been heavily influenced by Aaron Leung (@akhleung).
http://tritium.io
Mozilla Public License 2.0
33 stars 7 forks source link

Shark crash in SearchByCompiledXPath/FetchNodeSet #22

Closed hoisie closed 6 years ago

hoisie commented 12 years ago

This error is causing tritium-tester to crash. Zhigang is working on a new gokogiri, so this may not be relevant in a few days, but I want to track it anyway.

What's happening:

xpath.result is nil, and that's causing FetchNodeSet to segfault.

shark/functions.go, line 270

nodeSet := xpCtx.SearchByCompiledXPath(node, xpath).Slice()

gokogiri/libxml/xpath/XPath.go, line 43 (in SearchByCompiledXPath)

xpath.result = C.xmlXPathCompiledEval(exp.ptr, xpath.context)
return NewNodeSet(unsafe.Pointer(C.FetchNodeSet(xpath.result)), xpath.Doc)

In XPath.go

xmlNodeSet * 
FetchNodeSet(xmlXPathObject *obj) {
  return obj->nodesetval; }

Stack trace

xmlXPathCompOpEval: function ends-with not found
XPath error : Unregistered function
xmlXPathCompiledEval: 3 objects left on the stack.
panic: runtime error: invalid memory address or nil pointer dereference

[signal 0xb code=0x1 addr=0x4 pc=0x813d28a]

runtime.panic+0xa4 /home/mhoisie/.gvm/gos/release.r60.3/src/pkg/runtime/proc.c:1254
        runtime.panic(0x81da2bc, 0x975dd248)
runtime.panicstring+0x95 /home/mhoisie/.gvm/gos/release.r60.3/src/pkg/runtime/runtime.c:125
        runtime.panicstring(0x8383e8b, 0x8383000)
runtime.sigpanic+0x11b /home/mhoisie/.gvm/gos/release.r60.3/src/pkg/runtime/linux/thread.c:307
        runtime.sigpanic()
FetchNodeSet+0x7 /home/mhoisie/.gvm/tmp/1414/gokogiri/src/gokogiri/libxml/xpath/_obj/_cgo_defun.c:-647
        FetchNodeSet()
_cgo_8d8bee60d5f3_Cfunc_FetchNodeSet+0x24 /home/mhoisie/.gvm/tmp/1414/gokogiri/src/gokogiri/libxml/xpath/_obj/_cgo_defun.c:-647
        _cgo_8d8bee60d5f3_Cfunc_FetchNodeSet()

goroutine 2043 [3]:
return /home/mhoisie/.gvm/gos/release.r60.3/src/pkg/runtime/386/asm.s:380
        return()
runtime.cgocall+0x105 /home/mhoisie/.gvm/gos/release.r60.3/src/pkg/runtime/cgocall.c:135
        runtime.cgocall(0x813d2c3, 0x9741d45c, 0x9e20a70)
gokogiri/libxml/xpath._Cfunc_FetchNodeSet+0x32 /home/mhoisie/.gvm/tmp/1414/gokogiri/src/gokogiri/libxml/xpath/_obj/_cgo_defun.c:58
        gokogiri/libxml/xpath._Cfunc_FetchNodeSet(0x0, 0x9e1ff48)
gokogiri/libxml/xpath.(*XPath).SearchByCompiledXPath+0xfd /home/mhoisie/.gvm/tmp/1414/gokogiri/src/gokogiri/libxml/xpath/_obj/Expression.cgo1.go:46
        gokogiri/libxml/xpath.(*XPath).SearchByCompiledXPath(0x975dcd00, 0x973f56c0, 0x975d7f98, 0x975dd240, 0x25, ...)
tritium/src/tritium/shark.(*Ctx).runBuiltIn+0x653d /home/mhoisie/.gvm/tmp/2406/tritium/src/tritium/src/tritium/shark/functions.go:270
        tritium/src/tritium/shark.(*Ctx).runBuiltIn(0x975b7000, 0x975dc750, 0x975dcc60, 0x974f7140, 0x975dd218, ...)
tdesikan commented 12 years ago

can we please put this in manhattan/issues and tag it "tritium"

it's just easier to see all issues in 1 place ...