# Bug when throwing an Exception in a constructor

- Thread: https://externals.io/message/35936
- Original archive: https://news-web.php.net/php.internals/35936
- Started by Arnold Daniels on 2008-03-04T00:23:38+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #35936 — Arnold Daniels — 2008-03-04T00:23:38+00:00

URL: https://externals.io/message/35936#35936

Hi,

I'm running into a bug when throwing an Exception in a constructor. I 
sometimes get the message "Exception thrown without a stack frame in 
Unknown on line 0" and sometimes a message like seen below.

Unfortunately I'm not a create a simple example which causes the same 
exception, so reporting a bug wouldn't be useful. The error is constant 
within my current project though. This time I'm using reflection, but 
that doesn't seem to have to much to do with it. I'm running 5.2.5 now, 
but I had the same with 5.3.

Does this sound familiar to anyone?

Arnold

------------------------


arnold@arnold-laptop:~/projects/php-projects/qdb/Demo$ php sshrpc.php
host: ssh.example.com
username:
password:
[Tue Mar 4 01:15:18 2008] Script: 'sshrpc.php'
---------------------------------------
/usr/src/php5/php-5.2.5/Zend/zend_exceptions.c(406) : Block 0x089a1104 
status:
Beginning: OK (allocated on 
/usr/src/php5/php-5.2.5/Zend/zend_exceptions.c:403, 78 bytes)
Start: OK
End: Overflown (magic=0x0000003A instead of 0xEAB4EE29)
3 byte(s) overflown
---------------------------------------

Fatal error: Uncaught Q_Exception: Could not create SSH connection for 
'ssh.example.com': Server requires some form of authentication for user 
'arnold'. in 
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ on line 146
#0 
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)���ZO�5$Y(146): 
Q_RPCClient_SSH->makeConnection('ssh.example.com', Array)
#1 [internal function]: Q_RPCClient_SSH->__construct(Array)
#2 /home/arnold/projects/php-projects/qdb/src/Q/RPCClient.php(93): 
ReflectionClass->newInstanceArgs(Array)
#3 [internal function]: Q_RPCClient::connect('ssh', Array)
#4 /home/arnold/projects/php-projects/qdb/src/Q/RPCClient.php(110): 
call_user_func_array(Array, Array)
#5 /home/arnold/projects/php-projects/qdb/Demo/sshrpc.php(8): 
Q_RPCClient::remote('ssh', Array)
#6 {main}
thrown in /home/arnold/projects/php-projects/qdb/src/Q/RPCClient/SSH.php 
on line 200

Warning: String is not zero-terminated 
(ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)���ZO�5) 
(source: /usr/src/php5/php-5.2.5/Zend/zend_variables.h:35) in Unknown on 
line 0
[Tue Mar 4 01:15:18 2008] Script: 'sshrpc.php'
---------------------------------------
/usr/src/php5/php-5.2.5/Zend/zend_variables.h(35) : Block 0x089a6e4c status:
/usr/src/php5/php-5.2.5/Zend/zend_variables.c(36) : Actual location 
(location was relayed)
Beginning: Cached
Freed (invalid)
Start: OK
End: OK
---------------------------------------

arnold@arnold-laptop:~/projects/php-projects/qdb/Demo$ php -v
PHP 5.2.5 (cli) (built: Mar 3 2008 22:20:58) (DEBUG)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

---

## #35938 — Felipe Pena — 2008-03-04T01:51:22+00:00

URL: https://externals.io/message/35936#35938 · In reply to: #35936

Hello.


Index: Zend/zend_exceptions.c
===================================================================
RCS file: /repository/ZendEngine2/zend_exceptions.c,v
retrieving revision 1.79.2.6.2.9.2.4
diff -u -p -r1.79.2.6.2.9.2.4 zend_exceptions.c
--- Zend/zend_exceptions.c      21 Jan 2008 19:39:55 -0000
1.79.2.6.2.9.2.4
+++ Zend/zend_exceptions.c      4 Mar 2008 01:47:35 -0000
@@ -734,6 +734,7 @@ ZEND_API void zend_throw_exception_objec
                zend_error(E_ERROR, "Exceptions must be valid objects
derived from the Exception base class");
        }
        zend_throw_exception_internal(exception TSRMLS_CC);
+       zend_clear_exception(TSRMLS_C);
 }
 /* }}} */
 

This looks good enough?


Em Ter, 2008-03-04 às 01:23 +0100, Arnold Daniels escreveu:
> Hi,
> 
> I'm running into a bug when throwing an Exception in a constructor. I 
> sometimes get the message "Exception thrown without a stack frame in 
> Unknown on line 0" and sometimes a message like seen below.
> 
> Unfortunately I'm not a create a simple example which causes the same 
> exception, so reporting a bug wouldn't be useful. The error is constant 
> within my current project though. This time I'm using reflection, but 
> that doesn't seem to have to much to do with it. I'm running 5.2.5 now, 
> but I had the same with 5.3.
> 
> Does this sound familiar to anyone?
> 
> Arnold
> 
> ------------------------
> 
> 
> arnold@arnold-laptop:~/projects/php-projects/qdb/Demo$ php sshrpc.php
> host: ssh.example.com
> username:
> password:
> [Tue Mar 4 01:15:18 2008] Script: 'sshrpc.php'
> ---------------------------------------
> /usr/src/php5/php-5.2.5/Zend/zend_exceptions.c(406) : Block 0x089a1104 
> status:
> Beginning: OK (allocated on 
> /usr/src/php5/php-5.2.5/Zend/zend_exceptions.c:403, 78 bytes)
> Start: OK
> End: Overflown (magic=0x0000003A instead of 0xEAB4EE29)
> 3 byte(s) overflown
> ---------------------------------------
> 
> Fatal error: Uncaught Q_Exception: Could not create SSH connection for 
> 'ssh.example.com': Server requires some form of authentication for user 
> 'arnold'. in 
> ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ on line 146
> #0 
> ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)���ZO�5$Y(146): 
> Q_RPCClient_SSH->makeConnection('ssh.example.com', Array)
> #1 [internal function]: Q_RPCClient_SSH->__construct(Array)
> #2 /home/arnold/projects/php-projects/qdb/src/Q/RPCClient.php(93): 
> ReflectionClass->newInstanceArgs(Array)
> #3 [internal function]: Q_RPCClient::connect('ssh', Array)
> #4 /home/arnold/projects/php-projects/qdb/src/Q/RPCClient.php(110): 
> call_user_func_array(Array, Array)
> #5 /home/arnold/projects/php-projects/qdb/Demo/sshrpc.php(8): 
> Q_RPCClient::remote('ssh', Array)
> #6 {main}
> thrown in /home/arnold/projects/php-projects/qdb/src/Q/RPCClient/SSH.php 
> on line 200
> 
> Warning: String is not zero-terminated 
> (ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ)���ZO�5) 
> (source: /usr/src/php5/php-5.2.5/Zend/zend_variables.h:35) in Unknown on 
> line 0
> [Tue Mar 4 01:15:18 2008] Script: 'sshrpc.php'
> ---------------------------------------
> /usr/src/php5/php-5.2.5/Zend/zend_variables.h(35) : Block 0x089a6e4c status:
> /usr/src/php5/php-5.2.5/Zend/zend_variables.c(36) : Actual location 
> (location was relayed)
> Beginning: Cached
> Freed (invalid)
> Start: OK
> End: OK
> ---------------------------------------
> 
> arnold@arnold-laptop:~/projects/php-projects/qdb/Demo$ php -v
> PHP 5.2.5 (cli) (built: Mar 3 2008 22:20:58) (DEBUG)
> Copyright (c) 1997-2007 The PHP Group
> Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
> 
> 
-- 
Regards,
Felipe Pena.

---

## #35939 — Felipe Pena — 2008-03-04T02:31:18+00:00

URL: https://externals.io/message/35936#35939 · In reply to: #35938

Em Seg, 2008-03-03 às 22:51 -0300, Felipe Pena escreveu:
> Hello.
> 
> 
> Index: Zend/zend_exceptions.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_exceptions.c,v
> retrieving revision 1.79.2.6.2.9.2.4
> diff -u -p -r1.79.2.6.2.9.2.4 zend_exceptions.c
> --- Zend/zend_exceptions.c      21 Jan 2008 19:39:55 -0000
> 1.79.2.6.2.9.2.4
> +++ Zend/zend_exceptions.c      4 Mar 2008 01:47:35 -0000
> @@ -734,6 +734,7 @@ ZEND_API void zend_throw_exception_objec
>                 zend_error(E_ERROR, "Exceptions must be valid objects
> derived from the Exception base class");
>         }
>         zend_throw_exception_internal(exception TSRMLS_CC);
> +       zend_clear_exception(TSRMLS_C);
>  }
>  /* }}} */
>  
> 
> This looks good enough?
> 

Oh, no... In fact leaks doesn't occur with the zend_clear_exception
call. However, this breaks *several* tests...

-- 
Regards,
Felipe Pena.
