BaseXdb / basex

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

Update, replace nodes: AIOOB #2208

Closed ChristianGruen closed 1 year ago

ChristianGruen commented 1 year ago
XQUERY db:create('db', <a xmlns:x='x'>{ (1 to 4095) ! <b/> }</a>, 'a.xml')
XQUERY db:open('db') update { replace node /a with ( <c>{ (1 to 4096) ! <d/> }</c> )}
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk@mailman.uni-konstanz.de
Version: BaseX 10.7 beta
Java: Eclipse Adoptium, 20
OS: Windows 11, amd64
Stack Trace:
java.lang.ArrayIndexOutOfBoundsException: Index 8192 out of bounds for length 8192
  at org.basex.io.random.TableMemBlock.value(TableMemBlock.java:87)
  at org.basex.io.random.TableMemAccess.copy(TableMemAccess.java:101)
  at org.basex.io.random.TableMemAccess.insert(TableMemAccess.java:161)
  at org.basex.data.Data.insert(Data.java:933)
  at org.basex.data.Data.insert(Data.java:824)
  at org.basex.query.up.atomic.Replace.apply(Replace.java:61)
  at org.basex.query.up.atomic.AtomicUpdateCache.applyUpdates(AtomicUpdateCache.java:291)
  at org.basex.query.up.atomic.AtomicUpdateCache.execute(AtomicUpdateCache.java:275)
  at org.basex.query.up.DataUpdates.apply(DataUpdates.java:167)
  at org.basex.query.up.ContextModifier.apply(ContextModifier.java:120)
  at org.basex.query.up.Updates.apply(Updates.java:179)
  at org.basex.query.up.expr.TransformWith.value(TransformWith.java:76)
brandes-pq commented 1 year ago

No database is required for reproduction:

document {<a xmlns:x='x'>{ (1 to 4095) ! <b/> }</a>}
update { replace node /a with ( <c>{ (1 to 4096) ! <d/> }</c> )}

yields the same error. The placement of the namespace declaration does not seem to matter, the same behaviour is also shown by

document {<a>{ (1 to 4095) ! <b/> }</a>}
update { replace node /a with (<c>{ (1 to 4096) ! <d xmlns:x='x'/> }</c> )}
ChristianGruen commented 1 year ago

No database is required for reproduction:

…true. The good thing is that it’s not reproducible for instances on disk. This one runs fine:

XQUERY db:create('db', <a xmlns:x='x'>{ (1 to 4095) ! <b/> }</a>, 'a.xml')
XQUERY db:open('db') ! (replace node /a with ( <c>{ (1 to 4096) ! <d/> }</c> ))
ChristianGruen commented 1 year ago

…a needle-in-the-haystack bug, I’m optimistic it’s fixed.