# Segfault in CVS : Namespace related.

- Thread: https://externals.io/message/1761
- Original archive: https://news-web.php.net/php.internals/1761
- Started by l0t3k on 2003-05-20T06:20:32+00:00
- Messages: 2
- 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

---

## #1761 — l0t3k — 2003-05-20T06:20:32+00:00

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

im sorry i dont have a diff (my build environment is sensitive at the
moment), but there is a segfault initializing an internal namespace.
simplest reproducing C code is :

<code>
#define MODULE_NAMESPACE "I18N"
zend_namespace *i18n_ns = NULL;

void php_I18N_register_namespace(TSRMLS_DC)
{
 zend_namespace temp_ns;
 temp_ns.name = MODULE_NAMESPACE;
 temp_ns.name_length = strlen(MODULE_NAMESPACE);
 i18n_ns = zend_register_internal_namespace(&temp_ns TSRMLS_CC);
}
</code>

the problem is that the ns->builtin_functions table is not properly
initialized in zend_init_namespace, so a subsequent call to
<code>
 if (ns->builtin_functions) {
  zend_register_functions(ns, ns->builtin_functions, &ns->function_table,
MODULE_PERSISTENT TSRMLS_CC);
 }
</code>

causes the code to crash.

l0t3k

---

## #1764 — marcus.boerger@t-online.de — 2003-05-20T06:54:54+00:00

URL: https://externals.io/message/1761#1764 · In reply to: #1761

At 08:20 20.05.2003, l0t3k wrote:
>the problem is that the ns->builtin_functions table is not properly

NO, the problem is on your side. Look at the following code snippet from SPL:

         void spl_register_namespace(zend_namespace ** ppns, char * 
namespace_name TSRMLS_DC)
         {
                 zend_namespace ns;

                 INIT_NAMESPACE(ns, namespace_name);
                 *ppns = zend_register_internal_namespace(&ns TSRMLS_CC);
         }

As you can see the macro INIT_NAMESPACE is needed.

regards
marcus
