Skip to content

Missing negative array size check in Slice#allocate #170

@kasiafi

Description

@kasiafi

This is a public method. Experience would be better if negative array size produced a user-friendly message, similar to the one we get for too large size.

https://github.com/airlift/slice/blob/master/src/main/java/io/airlift/slice/Slices.java#L83:L92

On negative size, throws

java.lang.NegativeArraySizeException: -2147483636
	at io.airlift.slice.Slices.allocate(Slices.java:91)
	at io.trino.execution.buffer.PageSerializer$WriteBuffer.<init>(PageSerializer.java:626)
	at io.trino.execution.buffer.PageSerializer$SerializedPageOutput.startPage(PageSerializer.java:154)
	at io.trino.execution.buffer.PageSerializer.serialize(PageSerializer.java:83)
	at io.trino.spiller.FileSingleStreamSpiller.writePages(FileSingleStreamSpiller.java:157)
	at io.trino.spiller.FileSingleStreamSpiller.lambda$spill$0(FileSingleStreamSpiller.java:123)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions