Re: Segmentation Fault when trying to call zend_new_array.

From: Date: Tue, 25 Aug 2020 11:39:24 +0000
Subject: Re: Segmentation Fault when trying to call zend_new_array.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-111683@lists.php.net to get a copy of this message
On Tue, Aug 25, 2020 at 5:31 AM Ivan Zanev <ivanzanev477@gmail.com> wrote: > > Hello, > > I'm trying to learn a bit more about HashTable in PHP internally and how > memory is allocated when generating arrays with various sizes. I created a > simple C script that would call > > HashTable *ht = zend_new_array(15); > > However, when I compile the script with gcc, I get segmentation fault; gdb > tells that the problem is located within _emalloc_56, specifically: > > 2535 if (UNEXPECTED(AG(mm_heap)->use_custom_heap)) { > > That's how I compiled the script: > gcc -I./Zend -I. -I./TSRM -I./main Zend/*.c TSRM/TSRM.c test.c -ldl -lm -g > > For the configuration I used: > ./configure > > Could you please guide me in the right direction? Is there something I > should do before calling zend_new_array? > > Sincerely, > Ivan Does test.c include a main? If so you probably want to use the embed SAPI. If not then you probably want to build it as an extension.

« previous php.internals (#111683) next »