Skip to content

XQuery: Internal crash on has-children() result comparison #2213

@Twilight-Shuxin

Description

@Twilight-Shuxin

Description of the Problem

Given this XML document:

<T2 id="1">a</T2>

and XPath Query

//*[@id="1"]/has-children() != false()

BaseX Server crashed internally:

Exception in thread "Thread-4" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at org.basex.query.expr.Cmp.optBoolean(Cmp.java:240)
	at org.basex.query.expr.Cmp.opt(Cmp.java:132)
	at org.basex.query.expr.CmpG.optimize(CmpG.java:206)
	at org.basex.query.expr.Arr.compile(Arr.java:50)
	at org.basex.query.scope.MainModule.compile(MainModule.java:33)
	at org.basex.query.QueryCompiler.compile(QueryCompiler.java:99)
	at org.basex.query.QueryContext.compile(QueryContext.java:336)
	at org.basex.query.QueryContext.lambda$compile$2(QueryContext.java:286)
	at org.basex.query.QueryContext.run(QueryContext.java:766)
	at org.basex.query.QueryContext.compile(QueryContext.java:272)
	at org.basex.query.QueryProcessor.compile(QueryProcessor.java:75)
	at org.basex.core.cmd.AQuery.init(AQuery.java:201)
	at org.basex.core.cmd.AQuery.updating(AQuery.java:150)
	at org.basex.core.Command.execute(Command.java:87)
	at org.basex.server.ClientListener.run(ClientListener.java:141)

Expected Behavior

Should return true as eXist & Saxon.

Steps to Reproduce the Behavior

  1. Create database create database test
  2. Insert XML file into database put test.xml path/to/file
  3. Execute XPath query xquery //*[@id="1"]/has-children() != false()

Do you have an idea how to solve the issue?

No response

What is your configuration?

BaseX version: BaseX 10.7 beta latest commit 081fb4d on Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions