BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
695 stars 264 forks source link

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

Closed Twilight-Shuxin closed 1 year ago

Twilight-Shuxin commented 1 year ago

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