Bug 420682 - io_pgetevents is not supported
Summary: io_pgetevents is not supported
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-27 21:20 UTC by rafael
Modified: 2025-03-29 08:07 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
initial patch (6.71 KB, patch)
2025-03-25 21:03 UTC, Paul Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rafael 2020-04-27 21:20:12 UTC
I have tried running seastar's tests (http://seastar.io/) with valgrind, but some of the tests fail when they try to use io_pgetevents (syscall number 333 on x86_64) which is not implemented yet.
Comment 1 David Sloan 2025-03-24 20:27:43 UTC
I have hit the same bug on Ubuntu 24.04 running valgrind version 3.22.0, and did not see a fix in git.

Steps to reproduce:
missing-syscall.c
```C
#include <assert.h>
#include <fcntl.h>
#include <libaio.h>
#include <unistd.h>

int main()
{
	
	const char *msg = "hello world\n";
	struct iocb iocb = {};
	struct io_event event;
	io_context_t ctx = 0;
	struct iocb *iocbp;
	int rc, fd;
	
	rc = io_setup(1, &ctx);
	assert(rc == 0);
	
	fd = open("test.txt", O_CREAT | O_RDWR, 0666);
	assert(fd >= 0);

	io_prep_pwrite(&iocb, fd, (void *)msg, 12, 0);
	iocbp = &iocb;

	rc = io_submit(ctx, 1, &iocbp);
	assert(rc == 1);

	rc = io_getevents(ctx, 1, 1, &event, NULL);
	assert(rc = 1);

	close(fd);

	io_destroy(ctx);
}
```

```
gcc -g -Og missing-syscall.c -o test-valgrind -laio
valgrind ./test-valgrind
```

output:
```
==39192== Memcheck, a memory error detector
==39192== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==39192== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==39192== Command: ./test-valgrind
==39192== 
--39192-- WARNING: unhandled amd64-linux syscall: 333
--39192-- You may be able to write your own handler.
--39192-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--39192-- Nevertheless we consider this a bug.  Please report
--39192-- it at http://valgrind.org/support/bug_reports.html.
==39192== 
==39192== HEAP SUMMARY:
==39192==     in use at exit: 0 bytes in 0 blocks
==39192==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==39192== 
==39192== All heap blocks were freed -- no leaks are possible
==39192== 
==39192== For lists of detected and suppressed errors, rerun with: -s
==39192== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```
Comment 2 Paul Floyd 2025-03-25 07:12:16 UTC
(In reply to David Sloan from comment #1)
> I have hit the same bug on Ubuntu 24.04 running valgrind version 3.22.0, and
> did not see a fix in git.

It works for me on Fedora 41. But that's using sys_io_getevents rather than sys_io_pgetevents

SYSCALL[5989,1](208) sys_io_getevents ( 139871270969344, 1, 1, 0x1ffefff850, 0x0 ) --> [async] ... 
SYSCALL[5989,1](208) ... [async] --> Success(0x1) 

It looks like the same interface but with an extra const struct __aio_sigset* usig argument.
Comment 3 Paul Floyd 2025-03-25 21:03:36 UTC
Created attachment 179731 [details]
initial patch

I haven't tested it yet properly, but could you try this patch?
Comment 4 David Sloan 2025-03-25 23:14:40 UTC
(In reply to Paul Floyd from comment #3)
> Created attachment 179731 [details]
> initial patch
> 
> I haven't tested it yet properly, but could you try this patch?

This works on my system, thanks!
Tested on valgrind: commit f697142e15c44c2d3e3910ae436a6597e8782aea (HEAD -> master, origin/master, origin/HEAD)
Comment 5 Paul Floyd 2025-03-28 21:02:19 UTC
I've written a test for this and cleaned up the error messages a bit - there were a few errors in the untested code.

Buildbot says I need to improve the configure.ac test the the syscall. There is only the amd64 wrapper for the moment.
Comment 6 Paul Floyd 2025-03-29 08:07:46 UTC
I couldn't see the syscall number for ppc. The value was wrong for arm64, now corrected. Added x86 s390 mips32, mips64 and riscv64 as well as amd64.

commit 19c00de89e0fa21c62a5c0c0d1b1cc081f4ce00a (HEAD -> master, origin/master, origin/HEAD, bug420682)
Author: Paul Floyd <pjfloyd@wanadoo.fr>
Date:   Fri Mar 28 21:45:15 2025 +0100

    Bug 420682 - io_pgetevents is not supported