Thread View: muc.lists.netbsd.tech.userlevel
6 messages
6 total messages
Started by Greg Troxel
Thu, 08 Oct 2026 12:54
intptr_t, kqueue: history/rationale of type change
Author: Greg Troxel
Date: Thu, 08 Oct 2026 12:54
Date: Thu, 08 Oct 2026 12:54
48 lines
3325 bytes
3325 bytes
This message is about type definitions (this list) and kqueue
(tech-kern) but I'm sending it just here.
While updating matrix-synapse to 1.162.0, a rust create "mio" failed to
build with type errors:
Compiling mio v1.0.4
error[E0308]: mismatched types
--> /tmp/work/chat/matrix-synapse/work/vendor/mio-1.0.4/src/sys/unix/selector/kqueue.rs:60:20
|
60 | udata: $data as UData,
| ^^^^^^^^^^^^^^ expected `*mut c_void`, found `isize`
...
132 | let kevent = kevent!(fd, libc::EVFILT_WRITE, flags, token.0);
| ----------------------------------------------- in this macro invocation
mio had not been bumped in synapse for over a year. Long story short:
mio has ifdefs by OS ("#cfg" in rust) to set the type of the udata
parameter, void* in most places, and intptr_t on NetBSD.
mio uses the libc create to get the underlying types (seems linuxy to
have types in libc, but that's how it is :-).
The libc crate changed from 0.2.174 to 0.2.189 in synapse 1.162.0.
NetBSD changed kevent.udata type from intptr_t to void* in 2019.
intptr_t, which I expect to be "int *", isn't. It is "long" and
amd64 and "int" on i386.
If I change mio to expect void* for NetBSD, things build.
I now think that intptr_t is "pointer stored in an int", not a pointer
to an int.
I speculate that in the libc crate, intptr_t used to be the
obvious-but-wrong int*, and they fixed it, and that exposed the latent
bug in mio of not keeping up with our 2019 change. But really mio just
needs fixing.
I am curious if the assembled group of esteemed C/POSIX pontificators
think my analysis seems right.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: intptr_t, kqueue: history/rationale of type change
Author: Jason Thorpe
Date: Thu, 08 Oct 2026 13:01
Date: Thu, 08 Oct 2026 13:01
18 lines
4891 bytes
4891 bytes
> On Oct 8, 2026, at 5:54 AM, Greg Troxel <gdt@lexort.com> wrote: > > I now think that intptr_t is "pointer stored in an int", not a pointer > to an int. The formal definition is "a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer”. -- thorpej -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: intptr_t, kqueue: history/rationale of type change
Author: Martin Husemann
Date: Thu, 08 Oct 2026 13:03
Date: Thu, 08 Oct 2026 13:03
16 lines
1736 bytes
1736 bytes
On Thu, Oct 08, 2026 at 08:54:08AM -0400, Greg Troxel wrote: > I now think that intptr_t is "pointer stored in an int", not a pointer > to an int. intptr_t is a signed integer type that can hold the value of a "void*" without data loss. The C standard says you can convert the value of a void * to intptr_t, convert that back to void* and compare the result with the original void* and the comparision is required to come up equal. uintptr_t is an unsigned integer type with the same property. Martin -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: intptr_t, kqueue: history/rationale of type change
Author: Mouse
Date: Thu, 08 Oct 2026 13:14
Date: Thu, 08 Oct 2026 13:14
35 lines
2600 bytes
2600 bytes
> I now think that intptr_t is "pointer stored in an int", not a
> pointer to an int.
Yes. As C99 puts it:
7.18.1.4 Integer types capable of holding object pointers
[#1] The following type designates a signed integer type
with the property that any valid pointer to void can be
converted to this type, then converted back to pointer to
void, and the result will compare equal to the original
pointer:
intptr_t
The following type designates an unsigned integer type with
the property that any valid pointer to void can be converted
to this type, then converted back to pointer to void, and
the result will compare equal to the original pointer:
uintptr_t
These types are optional.
As for the rust of it, I am not competent to hold an opinion; my
interactions with rust have been mutually antagonistic.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: intptr_t, kqueue: history/rationale of type change
Author: Thomas Klausner
Date: Thu, 08 Oct 2026 13:21
Date: Thu, 08 Oct 2026 13:21
26 lines
2824 bytes
2824 bytes
On Thu, Oct 08, 2026 at 08:54:08AM +0100, Greg Troxel wrote: > While updating matrix-synapse to 1.162.0, a rust create "mio" failed to > build with type errors: > > Compiling mio v1.0.4 > error[E0308]: mismatched types > --> /tmp/work/chat/matrix-synapse/work/vendor/mio-1.0.4/src/sys/unix/selector/kqueue.rs:60:20 > | > 60 | udata: $data as UData, > | ^^^^^^^^^^^^^^ expected `*mut c_void`, found `isize` > ... > 132 | let kevent = kevent!(fd, libc::EVFILT_WRITE, flags, token.0); > | ----------------------------------------------- in this macro invocation You can use e.g. devel/py-ruff/patches/patch-.._vendor_mio-1.0.4_src_sys_unix_selector_kqueue.rs to fix this. The problem with the crate ecosystem is that, even when we fix bugs upstream, it takes a long while until the fixed versions are propagated to the packages we're interested in... Thomas -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: intptr_t, kqueue: history/rationale of type change
Author: Greg Troxel
Date: Thu, 08 Oct 2026 14:17
Date: Thu, 08 Oct 2026 14:17
12 lines
2089 bytes
2089 bytes
Thanks all for intptr_t wisdom. I am guessing the libc crate had a fix to that I have added a patch to the mio crate in synapse and it's ok now. It turns out mio had fixed this a long time ago, and as wiz points out due the nature of rust/crates, it's still broken in many places. I've reported "mio is old" to synapse. -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads