# Bug # 21533 NOT SOLVED! (Trouble building PHP w/ GD and including ImageTTFxxx functions)

- Thread: https://externals.io/message/1032
- Original archive: https://news-web.php.net/php.internals/1032
- Started by Michael Loftis on 2003-04-24T22:08:19+00:00
- Messages: 5
- 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

---

## #1033 — Jani Taskinen — 2003-04-24T21:17:12+00:00

URL: https://externals.io/message/1032#1033 · In reply to: #1032

Try the latest stable snapshot from http://snaps.php.net
    first..
    
    --Jani
    



>I've made a note/comment in the bug itself but figured I should post it 
>here too.
>
>This bug is NOT yet fixed.
>
>In 4.3.1 the code can and still does produce bogus code that doesn't set 
>error.
>
>my main/php_config.h generates with this area (not verbatim):
>
>/*   */
>/* #undef HAVE_GD_STRINGTTF */
>
>/*   */
>/* #undef HAVE_GD_STRINGFT */
>
>/*   */
>/* #undef HAVE_GD_STRINGFTEX */
>
>/*   */
>#define USE_GD_IMGSTRTTF 1
>
>/*   */
>#define USE_GD_IMGSTRTTF 1
>
>
>Notice we have neither FT nor the FTEX, nor TTF!
>
>So why in the world does USE_GD_IMGSTRTTF get 1?  TAke a look at gd.c:2937
>
>In this case error still ends up undefined as we never execute any of the 
>four functions!!!!  I traced the calls back up, the bt is included below 
>along with a print error to point out the fact.
>
>GDB OUTPUT:
>
>#0  0x080c114b in xbuf_format_converter (xbuf=0xbfffd1a0, fmt=0x40357707 
>"s",
>    ap=0xbfffd260) at /usr/src/webserver/php-4.3.1/main/spprintf.c:438
>#1  0x080c1601 in vspprintf (pbuf=0xbfffd208, max_len=0,
>    format=0x40357706 "%s", ap=0xbfffd25c)
>    at /usr/src/webserver/php-4.3.1/main/spprintf.c:622
>#2  0x080be757 in php_verror (docref=0x0, params=0x80f92af "", type=2,
>    format=0x40357706 "%s", args=0xbfffd25c)
>    at /usr/src/webserver/php-4.3.1/main/main.c:423
>#3  0x080bea1d in php_error_docref0 (docref=0x0, type=2,
>    format=0x40357706 "%s") at /usr/src/webserver/php-4.3.1/main/main.c:508
>#4  0x403489f6 in php_imagettftext_common (ht=8, return_value=0x817e304,
>    this_ptr=0x0, return_value_used=0, mode=0, extended=0)
>    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2957
>#5  0x4034861b in zif_imagettftext (ht=8, return_value=0x817e304,
>    this_ptr=0x0, return_value_used=0)
>    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2835
>#6  0x402fb542 in zend_assign_to_variable_reference ()
>   from /usr/local/libexec/php-4.3.1/ZendOptimizer.so
>#7  0x40304a02 in zend_oe () from 
>/usr/local/libexec/php-4.3.1/ZendOptimizer.so
>#8  0x080c02cb in php_execute_script (primary_file=0xbffffcb0)
>    at /usr/src/webserver/php-4.3.1/main/main.c:1576
>#9  0x080f8d84 in main (argc=2, argv=0xbffffd54)
>    at /usr/src/webserver/php-4.3.1/sapi/cgi/cgi_main.c:1424
><MORE BUT WE'RE ONLY REALLY INTERESTED IN FRAMES 4->0>
>
>(gdb) up
>#4  0x403489f6 in php_imagettftext_common (ht=8, return_value=0x817e304,
>    this_ptr=0x0, return_value_used=0, mode=0, extended=0)
>    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2957
>2957    /usr/src/webserver/php-4.3.1/ext/gd/gd.c: No such file or directory.
>        in /usr/src/webserver/php-4.3.1/ext/gd/gd.c
>(gdb) print error
>$2 = 0x20 <Address 0x20 out of bounds>
>(gdb)
>
>
>And the PHP script that will reproduce this every time::
>
>mloftis@modwest:/htdocs/www/gd/431$ cat ttf.php
>#!/usr/local/bin/php-4.3.1-4
><?php
>            header ("Content-type: image/png");
>            $im = imagecreate (400, 30);
>            $black = imagecolorallocate ($im, 0, 0, 0);
>            $white = imagecolorallocate ($im, 255, 255, 255);
>            imagettftext ($im, 20, 0, 10, 20, -$white,
>                     "/usr/share/fonts/default/TrueType/arib____.ttf", "Ich 
>will muss");
>            imagepng ($im);
>            imagedestroy ($im);
>            exit;
>       ?>
>
>
>And our ./configure statment.
>
>./configure  --disable-debug --disable-rpath 
>--with-pear=/usr/local/lib/php-4.3.1 --with-config-file-path=/etc 
>--prefix=/usr/local --libexecdir=/usr/local/libexec/php-4.3.1 
>--enable-shared=yes --enable-track-vars --enable-magic-quotes 
>--enable-trans-sid --with-kerberos --enable-all=shared --without-cyrus 
>--without-fbsql --without-fdftk --without-fribidi --without-hwapi 
>--without-informix --without-ingres --without-interbase --without-ircg 
>--without-java --without-mcve --without-msession --without-oracle 
>--without-oci8 --without-ovrimos --without-qtdom --without-readline 
>--without-libedit --without-sybase --without-sybase-ct --without-msql 
>--without-mssql --with-imap-ssl --with-openssl --enable-session 
>--with-sablot-js=/usr --with-xslt-sablot=/usr --with-gdbm=shared,/usr 
>--with-ndbm=shared,/usr --with-db2=shared,/usr --with-db3=shared,/usr 
>--with-unixODBC=shared,/usr --disable-calendar --enable-overload 
>--without-ncurses --disable-mime-magic --with-zlib --with-pcre-regex 
>--disable-yp --disable-path-info-check --enable-discard-path 
>--enable-mw-php-ini --enable-mw-deprecated-extension --with-jpeg-dir=/usr 
>--enable-gd-native-ttf --with-ttf=/usr --with-png-dir=/usr
>
>
>Relevant output around the GD extension config:
>
>checking for FDF support... no
>checking whether to enable the bundled filePro support... yes, shared
>checking for FriBidi support... no
>checking whether to enable FTP support... yes, shared
>checking for GD support... yes, shared
>checking for the location of libjpeg... yes, shared
>checking for the location of libpng... yes, shared
>checking for the location of libXpm... yes, shared
>checking for FreeType 1.x support... yes, shared
>checking for FreeType 2... yes, shared
>checking for T1lib support... yes, shared
>checking whether to enable truetype string function in GD... yes, shared
>checking for fabsf... yes
>checking for floorf... yes
>checking for jpeg_read_header in -ljpeg... yes
>checking for png_write_image in -lpng... yes
>If configure fails try --with-xpm-dir=<DIR>
>If configure fails try --with-freetype-dir=<DIR>
>checking for GNU gettext support... yes, shared
>checking for bindtextdomain in -lintl... no
>checking for bindtextdomain in -lc... yes
>
>
>Need anything else?
>
>
>
>
>--
>Michael Loftis
>Modwest Sr. Systems Administrator
>Powerful, Affordable Web Hosting
>
>

-- 
<- For Sale!

---

## #1032 — Michael Loftis — 2003-04-24T22:08:19+00:00

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

I've made a note/comment in the bug itself but figured I should post it 
here too.

This bug is NOT yet fixed.

In 4.3.1 the code can and still does produce bogus code that doesn't set 
error.

my main/php_config.h generates with this area (not verbatim):

/*   */
/* #undef HAVE_GD_STRINGTTF */

/*   */
/* #undef HAVE_GD_STRINGFT */

/*   */
/* #undef HAVE_GD_STRINGFTEX */

/*   */
#define USE_GD_IMGSTRTTF 1

/*   */
#define USE_GD_IMGSTRTTF 1


Notice we have neither FT nor the FTEX, nor TTF!

So why in the world does USE_GD_IMGSTRTTF get 1?  TAke a look at gd.c:2937

In this case error still ends up undefined as we never execute any of the 
four functions!!!!  I traced the calls back up, the bt is included below 
along with a print error to point out the fact.

GDB OUTPUT:

#0  0x080c114b in xbuf_format_converter (xbuf=0xbfffd1a0, fmt=0x40357707 
"s",
    ap=0xbfffd260) at /usr/src/webserver/php-4.3.1/main/spprintf.c:438
#1  0x080c1601 in vspprintf (pbuf=0xbfffd208, max_len=0,
    format=0x40357706 "%s", ap=0xbfffd25c)
    at /usr/src/webserver/php-4.3.1/main/spprintf.c:622
#2  0x080be757 in php_verror (docref=0x0, params=0x80f92af "", type=2,
    format=0x40357706 "%s", args=0xbfffd25c)
    at /usr/src/webserver/php-4.3.1/main/main.c:423
#3  0x080bea1d in php_error_docref0 (docref=0x0, type=2,
    format=0x40357706 "%s") at /usr/src/webserver/php-4.3.1/main/main.c:508
#4  0x403489f6 in php_imagettftext_common (ht=8, return_value=0x817e304,
    this_ptr=0x0, return_value_used=0, mode=0, extended=0)
    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2957
#5  0x4034861b in zif_imagettftext (ht=8, return_value=0x817e304,
    this_ptr=0x0, return_value_used=0)
    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2835
#6  0x402fb542 in zend_assign_to_variable_reference ()
   from /usr/local/libexec/php-4.3.1/ZendOptimizer.so
#7  0x40304a02 in zend_oe () from 
/usr/local/libexec/php-4.3.1/ZendOptimizer.so
#8  0x080c02cb in php_execute_script (primary_file=0xbffffcb0)
    at /usr/src/webserver/php-4.3.1/main/main.c:1576
#9  0x080f8d84 in main (argc=2, argv=0xbffffd54)
    at /usr/src/webserver/php-4.3.1/sapi/cgi/cgi_main.c:1424
<MORE BUT WE'RE ONLY REALLY INTERESTED IN FRAMES 4->0>

(gdb) up
#4  0x403489f6 in php_imagettftext_common (ht=8, return_value=0x817e304,
    this_ptr=0x0, return_value_used=0, mode=0, extended=0)
    at /usr/src/webserver/php-4.3.1/ext/gd/gd.c:2957
2957    /usr/src/webserver/php-4.3.1/ext/gd/gd.c: No such file or directory.
        in /usr/src/webserver/php-4.3.1/ext/gd/gd.c
(gdb) print error
$2 = 0x20 <Address 0x20 out of bounds>
(gdb)


And the PHP script that will reproduce this every time::

mloftis@modwest:/htdocs/www/gd/431$ cat ttf.php
#!/usr/local/bin/php-4.3.1-4
<?php
            header ("Content-type: image/png");
            $im = imagecreate (400, 30);
            $black = imagecolorallocate ($im, 0, 0, 0);
            $white = imagecolorallocate ($im, 255, 255, 255);
            imagettftext ($im, 20, 0, 10, 20, -$white,
                     "/usr/share/fonts/default/TrueType/arib____.ttf", "Ich 
will muss");
            imagepng ($im);
            imagedestroy ($im);
            exit;
       ?>


And our ./configure statment.

./configure  --disable-debug --disable-rpath 
--with-pear=/usr/local/lib/php-4.3.1 --with-config-file-path=/etc 
--prefix=/usr/local --libexecdir=/usr/local/libexec/php-4.3.1 
--enable-shared=yes --enable-track-vars --enable-magic-quotes 
--enable-trans-sid --with-kerberos --enable-all=shared --without-cyrus 
--without-fbsql --without-fdftk --without-fribidi --without-hwapi 
--without-informix --without-ingres --without-interbase --without-ircg 
--without-java --without-mcve --without-msession --without-oracle 
--without-oci8 --without-ovrimos --without-qtdom --without-readline 
--without-libedit --without-sybase --without-sybase-ct --without-msql 
--without-mssql --with-imap-ssl --with-openssl --enable-session 
--with-sablot-js=/usr --with-xslt-sablot=/usr --with-gdbm=shared,/usr 
--with-ndbm=shared,/usr --with-db2=shared,/usr --with-db3=shared,/usr 
--with-unixODBC=shared,/usr --disable-calendar --enable-overload 
--without-ncurses --disable-mime-magic --with-zlib --with-pcre-regex 
--disable-yp --disable-path-info-check --enable-discard-path 
--enable-mw-php-ini --enable-mw-deprecated-extension --with-jpeg-dir=/usr 
--enable-gd-native-ttf --with-ttf=/usr --with-png-dir=/usr


Relevant output around the GD extension config:

checking for FDF support... no
checking whether to enable the bundled filePro support... yes, shared
checking for FriBidi support... no
checking whether to enable FTP support... yes, shared
checking for GD support... yes, shared
checking for the location of libjpeg... yes, shared
checking for the location of libpng... yes, shared
checking for the location of libXpm... yes, shared
checking for FreeType 1.x support... yes, shared
checking for FreeType 2... yes, shared
checking for T1lib support... yes, shared
checking whether to enable truetype string function in GD... yes, shared
checking for fabsf... yes
checking for floorf... yes
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
If configure fails try --with-freetype-dir=<DIR>
checking for GNU gettext support... yes, shared
checking for bindtextdomain in -lintl... no
checking for bindtextdomain in -lc... yes


Need anything else?




--
Michael Loftis
Modwest Sr. Systems Administrator
Powerful, Affordable Web Hosting

---

## #1035 — Michael Loftis — 2003-04-24T23:22:27+00:00

URL: https://externals.io/message/1032#1035 · In reply to: #1033

WEll...Atleast it doesn't blow up anymore.

Now it just 'skips' the text part.  Haven't looked at the code changes yet 
so not sure what/why.  Really though it's still broken for this case.  I 
have to get to the root of it.  It seems like theres a problem with how 
ext/gd/config.m4 is handling things because the USE_GD_mumble gets defined 
even though none of those three functions are HAVE'd.  In our situation I 
think they should be somehow but I'm not sure why they aren't.

--On Friday, April 25, 2003 00:17 +0300 Jani Taskinen <sniper@iki.fi> wrote:

>
>     Try the latest stable snapshot from http://snaps.php.net
>     first..
>
>     --Jani
>
>
> 
>
> > […]
>
> --
> <- For Sale! ->
>
>



--
Michael Loftis
Modwest Sr. Systems Administrator
Powerful, Affordable Web Hosting

---

## #1036 — Michael Loftis — 2003-04-24T23:27:00+00:00

URL: https://externals.io/message/1032#1036 · In reply to: #1033

Essentially no change, teh problem with the #ifdef's is still there.  Now 
*error is just initialised to `NULL` so it runs, but is effectively a NOP 
because none of the TTF funcs before get called (IE same problem, better 
error condition handling, and therefore different symptoms)

--On Friday, April 25, 2003 00:17 +0300 Jani Taskinen <sniper@iki.fi> wrote:

>
>     Try the latest stable snapshot from http://snaps.php.net
>     first..
>
>     --Jani
>
>
> 
>
> > […]
>
> --
> <- For Sale! ->
>
>



--
Michael Loftis
Modwest Sr. Systems Administrator
Powerful, Affordable Web Hosting

---

## #1037 — Michael Loftis — 2003-04-24T23:50:39+00:00

URL: https://externals.io/message/1032#1037 · In reply to: #1036

--with-ttf=/usr and --with-freetype-dir=/usr added to our ./configure 
forced it to fix itself.

What I don't get is that before it was saying that those were being used 
and detected.  I just explicitly stated that they lived in /usr.

Now our GD functions all seem to work perfectly fine.

Really though the case of not getting any TTF operation at all still needs 
to be resolved.  It's better now that it doesn't blow the entire php binary 
up when it does by following an undefined variable.

--On Thursday, April 24, 2003 16:27 -0700 Michael Loftis 
<mloftis@modwest.com> wrote:

> Essentially no change, teh problem with the #ifdef's is still there.  Now
> *error is just initialised to `NULL` so it runs, but is effectively a NOP
> because none of the TTF funcs before get called (IE same problem, better
> error condition handling, and therefore different symptoms)
>
> --On Friday, April 25, 2003 00:17 +0300 Jani Taskinen <sniper@iki.fi>
> wrote:
>
> > […]
>
>
>
> --
> Michael Loftis
> Modwest Sr. Systems Administrator
> Powerful, Affordable Web Hosting
>
> --
> 
> 
>
>



--
Michael Loftis
Modwest Sr. Systems Administrator
Powerful, Affordable Web Hosting
