Skip to content

Invalid memory address after lot of concurrency #5

@vlourme

Description

@vlourme

Hey, this might not be directly related to rio.

I'm continuing my tests on my HTTP proxy, actually just trying to splice in io_uring, using the new exported Fd().
When doing a lot of splice, I run into a invalid memory address or nil pointer reference:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x642382]

goroutine 31 [running]:
github.com/brickingsoft/rio/pkg/liburing/aio.(*Channel).Complete(0xc004ba2300?, 0x786a59712480?, 0x91d30?, {0x926940?, 0xc009a5ed60?})
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/channel.go:107 +0x22
github.com/brickingsoft/rio/pkg/liburing/aio.(*Poller).prepareSQE(0xc003ae4000, 0xc005484f00)
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/poller.go:738 +0x2b7
github.com/brickingsoft/rio/pkg/liburing/aio.(*Poller).process1(0xc003ae4000)
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/poller.go:563 +0x2b9
github.com/brickingsoft/rio/pkg/liburing/aio.(*Poller).process(0xc003ae4000)
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/poller.go:496 +0xc9
github.com/brickingsoft/rio/pkg/liburing/aio.newPoller.func1({0x0, 0xb100, 0x0, 0x0, 0x0, 0x0, 0x0, {0x0, 0x0, 0x0}, ...}, ...)
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/poller.go:229 +0x7dd
created by github.com/brickingsoft/rio/pkg/liburing/aio.newPoller in goroutine 30
	/root/go/pkg/mod/github.com/vlourme/rio@v0.0.0-20250509065627-533b82f20637/pkg/liburing/aio/poller.go:112 +0x22a
exit status 2

The error can be triggered easily by running multiple connection, each one handled in a single goroutine, and by doing something like conn.WriteTo(dst) or a splice fd.Splice(dest.Fd(), 4096) (from aio)

This will work for maybe 500 connections and later crash. I'm not sure if rio is supposed to be thread-safe, IIRC, io_uring is more like a thread-per-core idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions