cygipc (and PostgreSQL) XP problem resolved!

Charles Wilson cwilson@ece.gatech.edu
Sat May 10 17:15:00 GMT 2003


Corinna Vinschen wrote:

> 
> Is there actually a need to convert key_t to 64 bit?
> 
> Corinna
>

with old 32bit key_t, cygipc uses this to create a key for a given 
filepath and id#:

   key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
          | ((id & 0xff) << 24));

Given the sizes of the various fields of st, there are obvious problems 
with aliasing here.

cygdaemon (and cygipc) with 64bit key_t uses:

   /* dev_t is short for cygwin
    * ino_t is long for cygwin
    * and we need 8 bits for the id.
    * thus key_t is long long.
    */
   return ((long long) statbuf.st_dev << (5*8)) |
           (statbuf.st_ino << (8) ) |
           (id & 0x00ff);

Currently, the above code is in winsup/cygwin/ipc.cc -- but if key_t is 
32 bits, the (long long) cast gets recast down to 32bits by the 'return' 
statement.  Which means that the ftok() function currently exported by 
cygwin is more or less broken -- fortunately nothing uses that except 
cygdaemon.

--Chuck



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list