Re: [PHP-DEV] [PATCH] Fix for bug #19566
I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - -722,9 +722,13 HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; -733,8 +737,8 } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } marcus At 09:52 08.11.2002, Moriyoshi Koizumi wrote: Hi, The attached patch is a probable fix for bug #19566. I guess the bug is that va_list is not properly initialized before each callback function call. I've tested it in PPC linux, and it works fine. Regards, Moriyoshi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Fix for bug #19566
See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } marcus At 09:52 08.11.2002, Moriyoshi Koizumi wrote: Hi, The attached patch is a probable fix for bug #19566. I guess the bug is that va_list is not properly initialized before each callback function call. I've tested it in PPC linux, and it works fine. Regards, Moriyoshi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Fix for bug #19566
Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } marcus At 09:52 08.11.2002, Moriyoshi Koizumi wrote: Hi, The attached patch is a probable fix for bug #19566. I guess the bug is that va_list is not properly initialized before each callback function call. I've tested it in PPC linux, and it works fine. Regards, Moriyoshi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Fix for bug #19566
Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } marcus At 09:52 08.11.2002, Moriyoshi Koizumi wrote: Hi, The attached patch is a probable fix for bug #19566. I guess the bug is that va_list is not properly initialized before each callback function call. I've tested it in PPC linux, and it works fine. Regards, Moriyoshi -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] Fix for bug #19566
Moriyoshi could you make a *.phpt file from the bug? Attached is a new diff tested already. It also fixes a compiler warning. Since i do not have Zend karma someone with karma should commit it or give me karma. marcus cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend\) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 17:25:59 - @@ -722,9 +722,9 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +733,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } @@ -1163,7 +1163,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { - Bucket *p1, *p2; + Bucket *p1, *p2 = NULL /* fixes warning */; int result; void *pData2; At 16:45 08.11.2002, Moriyoshi Koizumi wrote: Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } marcus At 09:52 08.11.2002, Moriyoshi Koizumi wrote: Hi, The attached patch is a probable fix for bug #19566. I guess the bug is that va_list is not properly initialized before each callback function call. I've tested it in PPC linux, and it works fine. Regards, Moriyoshi --
Re: [PHP-DEV] [PATCH] Fix for bug #19566
done. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Moriyoshi could you make a *.phpt file from the bug? Attached is a new diff tested already. It also fixes a compiler warning. Since i do not have Zend karma someone with karma should commit it or give me karma. marcus cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend\) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 17:25:59 - @@ -722,9 +722,9 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +733,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } @@ -1163,7 +1163,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { - Bucket *p1, *p2; + Bucket *p1, *p2 = NULL /* fixes warning */; int result; void *pData2; At 16:45 08.11.2002, Moriyoshi Koizumi wrote: Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht);
Re: [PHP-DEV] [PATCH] Fix for bug #19566
On Fri, 8 Nov 2002, Marcus Börger wrote: Moriyoshi could you make a *.phpt file from the bug? Attached is a new diff tested already. It also fixes a compiler warning. Since i do not have Zend karma someone with karma should commit it or give me karma. I can commit this, after you fix the whitespace :) Derick cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend\) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 17:25:59 - @@ -722,9 +722,9 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +733,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } @@ -1163,7 +1163,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { - Bucket *p1, *p2; + Bucket *p1, *p2 = NULL /* fixes warning */; int result; void *pData2; At 16:45 08.11.2002, Moriyoshi Koizumi wrote: Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +737,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args);
Re: [PHP-DEV] [PATCH] Fix for bug #19566
I haven't followed the thread. What is the problem with the var_args()? Also, please don't commit the second part of the patch. The warning is due to the compiler not understanding the code well enough. Functionality wise there's no reason to NULL that variable. Live with the warning or upgrade to a better compiler. Andi At 07:25 PM 11/8/2002 +0100, Derick Rethans wrote: On Fri, 8 Nov 2002, Marcus Börger wrote: Moriyoshi could you make a *.phpt file from the bug? Attached is a new diff tested already. It also fixes a compiler warning. Since i do not have Zend karma someone with karma should commit it or give me karma. I can commit this, after you fix the whitespace :) Derick cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend\) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 17:25:59 - @@ -722,9 +722,9 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +733,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } @@ -1163,7 +1163,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { - Bucket *p1, *p2; + Bucket *p1, *p2 = NULL /* fixes warning */; int result; void *pData2; At 16:45 08.11.2002, Moriyoshi Koizumi wrote: Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 09:32:48 - @@ -722,9 +722,13 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; + if (p == NULL) { + va_start(args, num_args); + va_end(args); + } while (p != NULL) { + va_start(args, num_args);
Re: [PHP-DEV] [PATCH] Fix for bug #19566
var_args issue doesn't have much to do with the purpose of the patch. We were perhaps just curious about the usage of va_start() and va_end(). And that warning reducer was later added by Marcus, so the first version should look nice. What about it? Moriyoshi Andi Gutmans [EMAIL PROTECTED] wrote: I haven't followed the thread. What is the problem with the var_args()? Also, please don't commit the second part of the patch. The warning is due to the compiler not understanding the code well enough. Functionality wise there's no reason to NULL that variable. Live with the warning or upgrade to a better compiler. Andi At 07:25 PM 11/8/2002 +0100, Derick Rethans wrote: On Fri, 8 Nov 2002, Marcus Börger wrote: Moriyoshi could you make a *.phpt file from the bug? Attached is a new diff tested already. It also fixes a compiler warning. Since i do not have Zend karma someone with karma should commit it or give me karma. I can commit this, after you fix the whitespace :) Derick cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend\) Index: zend_hash.c === RCS file: /repository/ZendEngine2/zend_hash.c,v retrieving revision 1.93 diff -u -r1.93 zend_hash.c --- zend_hash.c 5 Nov 2002 18:22:02 - 1.93 +++ zend_hash.c 8 Nov 2002 17:25:59 - @@ -722,9 +722,9 @@ HASH_PROTECT_RECURSION(ht); - va_start(args, num_args); p = ht-pListHead; while (p != NULL) { + va_start(args, num_args); hash_key.arKey = p-arKey; hash_key.nKeyLength = p-nKeyLength; hash_key.h = p-h; @@ -733,8 +733,8 @@ } else { p = p-pListNext; } + va_end(args); } - va_end(args); HASH_UNPROTECT_RECURSION(ht); } @@ -1163,7 +1163,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { - Bucket *p1, *p2; + Bucket *p1, *p2 = NULL /* fixes warning */; int result; void *pData2; At 16:45 08.11.2002, Moriyoshi Koizumi wrote: Yep, the spec goes right. a corresponding va_end() dtor should be applied to ap once ap has been initialized by a va_start(). IMO no va_end() is needed without a preceding va_start(), and it doesn't matter if ap is used between va_start() and va_end(). BTW, could anyone commit this patch if there seems no problem? Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: Some comments on ISO9899 standard 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined. What ever that means i guess you have to call va_end and that requires va_start. 7.15.1.4-3 Says do not call va_start twice without va_end. marcus ISO/IEC 9899:1999 (E) ©ISO/IEC 7.15.1.3 The va_end macro Synopsis 1 #include stdarg.h void va_end(va_list ap); Description 2 The va_end macro facilitates a normal return from the function whose variable argument list was referred to by the expansion of va_start, or the function containing the expansion of va_copy, that initialized the va_list ap. The va_end macro may modify ap so that it is no longer usable (without an intervening invocation of va_start or va_copy). If there is no corresponding invocation of the va_start or va_copy macro, or if the va_end macro is not invoked before the return, the behavior is undefined. Returns 3 The va_end macro returns no value. 7.15.1.4 The va_start macro Synopsis 1 #include stdarg.h void va_start(va_list ap, parmN); Description 2 The va_start macro shall be invoked before any access to the unnamed arguments. 3 The va_start macro initializes ap for subsequent use by va_arg and va_end. va_start (or va_copy) shall not be invoked again for the same ap without an intervening invocation of va_end for the same ap. (...) At 10:47 08.11.2002, Moriyoshi Koizumi wrote: See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html This appears to imply that va_start() can be used more than twice. And I don't think va_start() always has to be invoked. Moriyoshi [EMAIL PROTECTED] (Marcus Börger) wrote: I am not sure if va_start can be called twice in a row (rekursive). Manual does not say anything about that. How about: cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend) Index: zend_hash.c ===