http://bugs.winehq.org/show_bug.cgi?id=28857
--- Comment #21 from Charles Davis cdavis@mymail.mines.edu 2011-10-23 17:14:46 CDT --- (In reply to comment #19)
That's useful to know. When I compiled my test program as 32-bit, it stepped beyond the end in the same way Wine does now. And I think I know why.
On 64-bit FreeBSD, a struct xinpgen is 32 bytes long. But in 32-bit FreeBSD, a struct xinpgen is only 16 bytes long. Because the kernel is LP64, it is returning 32-byte xinpgen structures, which is bigger than the 16 bytes the loop was expecting. Because of this, the loop does not terminate like it should.
Unfortunately, I don't know how to fix this yet. Juan, any ideas?
Actually, it just occurred to me that we might not want to fix this on the Wine side. If struct xinpgen is the wrong size, other structures probably are, too.
The kernel should be well aware of when it's dealing with a 32-bit process, and should return 32-bit structures accordingly. (That's what the Mac OS kernel does.) At the very least, the 32-bit libc should be converting 64-bit structures into their 32-bit equivalents. In any case, it's time to file a FreeBSD bug.
(Note: I don't have permission to close the bug upstream, but that's normally what I would do at this point.)