# Fwd: Re:  Fwd: zend_std_get_method : Address 0xffffffff is not stack'd, malloc'd or (recently) free'd

- Thread: https://externals.io/message/73512
- Original archive: https://news-web.php.net/php.internals/73512
- Started by Kajetan Dolinar on 2014-04-02T07:42:21+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

---

## #73512 — Kajetan Dolinar — 2014-04-02T07:42:21+00:00

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

Hi Johannes, Stas

Please find the code with the explanation of how to reproduce the fault
on the following link: https://github.com/kdolinar/hypx-zend-bugcase

The main Zend PHP extension logic for the classes is in src/hypx.c.
Much obliged for your opinion. Thanks.

Kajetan

  ==== Some more info ====

On my machine, uname -a says

Linux machine 3.4.6-2.10-desktop #1 SMP PREEMPT Wed Sep 25 08:50:55 CEST
2013 i686 i686 i386 GNU/Linux

cat /etc/os-release says

NAME=openSUSE
VERSION="12.2 (Mantis)"
VERSION_ID="12.2"
PRETTY_NAME="openSUSE 12.2 (Mantis) (i586)"
ID=opensuse
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:opensuse:12.2"

phpize says

PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

and php --version says

PHP 5.3.15 (cli)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

Please come back to me if you need anything more ...

---

## #73522 — Jakub Zelenka — 2014-04-02T15:21:31+00:00

URL: https://externals.io/message/73512#73522 · In reply to: #73512

> Hi Johannes, Stas
>
> Please find the code with the explanation of how to reproduce the fault
> on the following link: https://github.com/kdolinar/hypx-zend-bugcase
>
> The main Zend PHP extension logic for the classes is in src/hypx.c.
> Much obliged for your opinion. Thanks.
>
> Kajetan
>
>  ==== Some more info ====
>
> On my machine, uname -a says
>
> Linux machine 3.4.6-2.10-desktop #1 SMP PREEMPT Wed Sep 25 08:50:55 CEST
> 2013 i686 i686 i386 GNU/Linux
>
> cat /etc/os-release says
>
> NAME=openSUSE
> VERSION="12.2 (Mantis)"
> VERSION_ID="12.2"
> PRETTY_NAME="openSUSE 12.2 (Mantis) (i586)"
> ID=opensuse
> ANSI_COLOR="0;32"
> CPE_NAME="cpe:/o:opensuse:opensuse:12.2"
>
> phpize says
>
> PHP Api Version: 20090626
> Zend Module Api No: 20090626
> Zend Extension Api No: 220090626
>
> and php --version says
>
> PHP 5.3.15 (cli)
> Copyright (c) 1997-2012 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
>
> Please come back to me if you need anything more ...
>
>
> --
> 
> 
>
>
Hi,

fixed: https://gist.github.com/bukka/9936176

The main problem was that you are trying to save return_value to static
variable and then re-use it (
https://github.com/kdolinar/hypx-zend-bugcase/blob/master/src/hypx.c#L302 )

That won't work because of GC (value can be freed in the meantime). There
were also some memory leaks and missing TSRMLS that I fixed. Compare the
the gist file and you will see that. I fixed just this case so the
index.php works. However there might be more similar case that you need to
check...

Jakub

---

## #73551 — Kajetan Dolinar — 2014-04-03T07:29:20+00:00

URL: https://externals.io/message/73512#73551 · In reply to: #73522

> Hi,
> 
> fixed: https://gist.github.com/bukka/9936176 [3]
> 
> The main problem was that you are trying to save return_value to static 
> variable and then re-use it ( 
> https://github.com/kdolinar/hypx-zend-bugcase/blob/master/src/hypx.c#L302 [4] )
> 
> That won't work because of GC (value can be freed in the meantime). 
> There were also some memory leaks and missing TSRMLS that I fixed. 
> Compare the the gist file and you will see that. I fixed just this case 
> so the index.php works. However there might be more similar case that 
> you need to check...
> 
> Jakub

Thanks, Jakub, very much for your insight. Yes, obviously saving a 
return_value into a static property was a bad idea. But how can I then 
create a persistent object and assign it to a static property? Here I'm 
after a typical singleton class where the only instance of the object is 
kept in a private static property.

Kajetan
