Date: 12/06/00
- Next message: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Previous message: Andre Felipe: "Re: [PHP-DEV] Problem compiling PHP4.0.2 with Openlink ODBC"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Reply: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 09:26 PM 12/6/00 +0100, Sascha Schumann wrote:
>On Wed, 6 Dec 2000, Andi Gutmans wrote:
>
> > I don't quite understand what flaw you are talking about.
> > pDataPtr is a void *. If the size of the data we are receiving is the same
> > size of pDataPtr (sizeof(void *)) we copy it's value to pDataPtr. I don't
> > see why doing it via a cast doesn't work. It should work on all platforms.
> > pDataPtr = *(void **)pData (where pData is the size of void *).
> > What your patch does isn't fixing a flaw (unless I'm missing something) but
> > adding functionality by using pDataPtr even if pData is smaller than
> void *.
> > If I'd know that on all systems memcpy() is as fast as doing it with a cast
> > I wouldn't mind the patch but I am pretty sure it isn't.
>
> It looks like an alignment problem.
>
> While memcpy handles unaligned accesses to memory properly,
> the cast will generate code which assumes that pData is
> properly aligned.
>
> Testcase attached.
>
> $ gcc x.c
> $ ./a.out
> ffbefc60
> ffbefc61
> Bus Error (core dumped)
> $ uname -m
> sun4u
Right. It doesn't work with unaligned data but did you actually bump into
such a case in PHP? I prefer not moving to memcpy() unless this is actually
the case.
Andi
--- Andi Gutmans <andi <email protected>> http://www.zend.com/-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Previous message: Andre Felipe: "Re: [PHP-DEV] Problem compiling PHP4.0.2 with Openlink ODBC"
- Next in thread: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Reply: Sascha Schumann: "Re: [PHP-DEV] zend_hash_add_or_update flaw"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

