[OT] This feels wrong (pthreads question)

Michael Halcrow mike at halcrow.us
Mon Jan 29 07:55:57 MST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

On Sun, Jan 28, 2007 at 08:01:44PM -0700, Levi Pearson wrote:
> Well, it feels pretty wrong to me, too, but just about every
> combination of C/C++ and pthreads feels wrong to me.  Casting to and
> from void isn't particularly dangerous if you always know exactly
> what you're casting, and it certainly doesn't add any overhead.  It
> looks ugly, but considering the lousy type system C has, it's
> sometimes necessary.

Casting to void may violate C pointer aliasing constraints. For
instance, here is one nasty violation that is still in OpenSSL:

- ---
        DSO_FUNC_TYPE sym, *tsym = &sym;
...
        *(void **)(tsym) = dlsym(ptr, symname);
- ---

This code may happen to work sometimes, but it falls flat on its face
when compiled with gcc -O2 on the s390x architecture (and it's not
gcc's fault).

Mike
.___________________________________________________________________.
                         Michael A. Halcrow                          
       Security Software Engineer, IBM Linux Technology Center       
GnuPG Fingerprint: 419C 5B1E 948A FA73 A54C  20F5 DB40 8531 6DCA 8769

Always remember you're unique, just like everyone else.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iQEVAwUBRb4K5ttAhTFtyodpAQMyVAf/ZKXA0y6MAmO0psgPKFvLzwd1B5kJZoMe
RYa1hIBIZc/oEyB7a70PtzJrBlFm+f7KVxfFrIdGI0Es2EjdGjXV6xZ/26j/Xc5S
2OzOPJjeZQJ7hVDkhNC2BtJG3a1ysYM+Gkr7b8wJG8cOXll5Lw/tm1XwJHDmxWCc
iSTcCq15+kY6f/gLXnoidqwNEfGmV3Q8zZYHXWAgf6wpqtIaOZ7dgRBSCq7AmCl7
suizVbbT/9GhnHBwiIbWP56ePCjZYZFdCdS2+3UevrAD7ypeqeftFgeFtJtg2YJD
TXHlzJxPTs+KXoK3V+InKeKd2RRrvKnEzL+9VwkXA3BVPQBEuyVdEw==
=eSDJ
-----END PGP SIGNATURE-----



More information about the PLUG mailing list