Re: [PHP-DEV] backtrace From: Sascha Schumann (sascha <email protected>)
Date: 08/31/00

> That's silly (c).
>
> "A pointer cannot be freed multiple times."
>
> Would you consider this sentence incorrect? Incomplete?

    That depends on the context.

    We were talking about the behaviour of something under very
    specific circumstances. The part you omitted was an essential
    part of these circumstances.

> > Please refer to my other email on why assignments don't work
> > well in this context.
>
> Can you forward me your Email? My understanding is that if it compiles,
> it should work.

    Well, it works under some conditions, as does Win2000.

> (the older code worked, even though it didn't compile well
> for some very odd reason, probably a compiler bug;

    The type of va_list is implementation-dependent. Not
    supporting GCC's copy-struct-by-assignment C extension is
    hardly a bug.

> @@ -366,7 +366,6 @@
> /* get include file name */
> if (PG(log_errors) || PG(display_errors) || (!module_initialized
)) {
> size = vsnprintf(buffer, sizeof(buffer) - 1, format, ori
g_args);
> - va_end(orig_args);
>
> buffer[sizeof(buffer) - 1] = 0;
>
> @@ -442,7 +441,6 @@
> pval *tmp;
>
> size = vsnprintf(buffer, sizeof(buffer) - 1, format, orig_args);
> - va_end(orig_args);
>
> buffer[sizeof(buffer) - 1] = 0;

    While this change might fix things on some platforms, it is
    incorrect.

    If we are going to use orig_args twice, we need (*1) to
    reinitialize it. Since this is not possible in a portable
    way (*2), I suggest to use it only once. I.e. set a flag
    after vsnprintf'ing buffer for the first time.

    1.: "The object ap may be passed as an argument to another
          function; if that function invokes the va_arg macro
          with parameter ap, the value of ap in the calling
          function is indeterminate and shall be passed to the
          va_end macro prior to any further reference to ap.

    2.: There are two ways to reinitialize a va_list. Old
         implementations don't support va_copy. va_start cannot
         be used in a function with a fixed number of arguments.

    - Sascha

-- 
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>