ii8 / havoc

minimal terminal emulator for wayland
Other
103 stars 17 forks source link

valgrind: ioctl has no size/direction hints #35

Closed matu3ba closed 2 years ago

matu3ba commented 2 years ago

Taken from memcheck in valgrind:

==350889== Warning: noted but unhandled ioctl 0x5441 with no size/direction hints.
==350889==    This could cause spurious value errors to appear.
==350889==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.

What I find really weird is that it shows up 0x5441, when I have in /usr/include/asm-generic/ioctls.h

#define TIOCSWINSZ  0x5414

At least thats where clangd leads me to on goto symbol definition.

This looks like a valgrind bug.

ii8 commented 2 years ago

I'm not a valgrind pro to be honest, what does it mean? The ioctl call in the code looks fine to me at first glance.

Is this perhaps complaining about the libc wrapper for the ioctl systemcall?

matu3ba commented 2 years ago

I'm not a valgrind pro to be honest, what does it mean?

Valdgrind

What are syscall/ioctl wrappers?  What do they do?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Valgrind does what it does, in part, by keeping track of everything your
program does.  When a system call happens, for example a request to read
part of a file, control passes to the Linux kernel, which fulfills the
request, and returns control to your program.  The problem is that the
kernel will often change the status of some part of your program's memory
as a result, and tools (instrumentation plug-ins) may need to know about
this.

Syscall and ioctl wrappers have two jobs: 

1. Tell a tool what's about to happen, before the syscall takes place.  A
   tool could perform checks beforehand, eg. if memory about to be written
   is actually writeable.  This part is useful, but not strictly
   essential.

2. Tell a tool what just happened, after a syscall takes place.  This is
   so it can update its view of the program's state, eg. that memory has
   just been written to.  This step is essential.

The "happenings" mostly involve reading/writing of memory. 
So, let's look at an example of a wrapper for a system call which
should be familiar to many Unix programmers.

Valgrind does not properly work without knowledge what syscalls do with memory. However in this case, it looks like something fishy is going on as the syscall number should be available to valgrind.

ii8 commented 2 years ago

Looks like this ioctl request is not implemented in valgrind.

I don't see any sort of problem with havoc here so I'll close this.