Bug 181250 - graphics/gd: gdFontSmall definition is missed
Summary: graphics/gd: gdFontSmall definition is missed
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-13 08:10 UTC by Alexey Markov
Modified: 2013-08-15 20:27 UTC (History)
0 users

See Also:


Attachments
cyr-font.tgz (20.67 KB, application/octet-stream)
2013-08-14 07:27 UTC, Alexey Markov
no flags Details
patch.txt (709 bytes, text/plain; format=flowed)
2013-08-15 13:40 UTC, Alexey Markov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Markov 2013-08-13 08:10:00 UTC
After upgrading gd-2.0.35_9,1 to the libgd-2.1.0,1 a definition of internal GD structure gdFontSmall is missed, and as a consequence some applications now gets a segmentation fault (e.g. MRTG).

How-To-Repeat: Just a little demo for this bug:

#include <gd.h>
#include <gdfonts.h>

int main()
{
    printf("gdFontSmall: %p\n", gdFontSmall);
    printf("gdFontSmall-w: %d\n", gdFontSmall->w);
    return 0;
}

For gd-2.0.35_9,1 it print:

gdFontSmall: 0x80076af80
gdFontSmall-w: 6

For libgd-2.1.0,1 it print:

gdFontSmall: 0x0
Segmentation fault(core dumped)
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-08-13 08:10:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dinoex

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Dirk Meyer freebsd_committer freebsd_triage 2013-08-14 06:19:05 UTC
State Changed
From-To: open->feedback


I can not reproduce your problem. 

Please deinstall libgd. 
and rebuild gd and all apps depending on it. 

clean jail: 
# pkg_add /usr/ports/packages9-amd64/All/libgd-2.1.0,1.tbz 

# pkg_version -v 
expat-2.1.0                         =   up-to-date with port 
fontconfig-2.10.93,1                =   up-to-date with port 
freetype2-2.4.12_1                  =   up-to-date with port 
jbigkit-1.6                         =   up-to-date with port 
jpeg-8_4                            =   up-to-date with port 
libgd-2.1.0,1                       =   up-to-date with port 
png-1.5.17                          =   up-to-date with port 
tiff-4.0.3                          =   up-to-date with port 

# make bug-gd CFLAGS=-I/usr/local/include LDFLAGS="-L/usr/local/lib -lgd" 

# ldd ./bug-gd 
./bug-gd: 
libgd.so.5 => /usr/local/lib/libgd.so.5 (0x80081a000) 
libc.so.7 => /lib/libc.so.7 (0x800a7c000) 
libjpeg.so.11 => /usr/local/lib/libjpeg.so.11 (0x800dda000) 
libz.so.6 => /lib/libz.so.6 (0x801011000) 
libm.so.5 => /lib/libm.so.5 (0x801225000) 
libpng15.so.15 => /usr/local/lib/libpng15.so.15 (0x801447000) 
libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x801675000) 
libfontconfig.so.1 => /usr/local/lib/libfontconfig.so.1 (0x801904000) 
libtiff.so.4 => /usr/local/lib/libtiff.so.4 (0x801b3d000) 
libthr.so.3 => /lib/libthr.so.3 (0x801dad000) 
libbz2.so.4 => /usr/lib/libbz2.so.4 (0x801fd1000) 
libexpat.so.6 => /usr/local/lib/libexpat.so.6 (0x8021e1000) 
liblzma.so.5 => /usr/lib/liblzma.so.5 (0x802405000) 
libjbig.so.1 => /usr/local/lib/libjbig.so.1 (0x802629000) 

# ./bug-gd  
gdFontSmall: 0x800a779e0 
gdFontSmall-w: 6
Comment 3 Alexey Markov 2013-08-14 07:27:35 UTC
Hello!

I found a cause of a problem, it's a GD_FONTS variable
set in my make.conf. If it set, bug-gd get segfaulted;
if it commented out, bug-gd runs successfully.

Can you confirm this bug by setting GD_FONTS in your
building environment? I attached file with font I use
to this letter.

I'm using russian BDF font with GD lib for many years,
so I hope this bug can be solved without renunciation
of GD_FONTS variable.

-- 
WBR, Alexey Markov.
Comment 4 Alexey Markov 2013-08-14 08:37:28 UTC
BTW, the same problem exists for russian/gd and ukrainian/gd
ports which uses x11-fonts/geminifonts.

-- 
WBR, Alexey Markov.
Comment 5 Alexey Markov 2013-08-15 08:26:45 UTC
Probably I have found a hint to solve this problem.

It seems that gdfont[glst].[ch] file format slightly
changed in the 2.1 branch of libgd. After pre-build
stage I have made following changes in that files:

1. Add 'extern ' before 'BGD_EXPORT_DATA_PROT  gdFontPtr'
   in the *.h files of fonts
2. Change BGD_EXPORT_DATA_IMPL to BGD_EXPORT_DATA_PROT
   in the *.c files of fonts
3. Add that three lines:
     #ifdef HAVE_CONFIG_H
     #include "config.h"
     #endif
   in the beginning of the *.c files of fonts

After that libgd successfuly built with custom fonts
and all depended applications (including MRTG) runs
without segfaults.

-- 
WBR, Alexey Markov.
Comment 6 Alexey Markov 2013-08-15 13:40:25 UTC
This is a _partial_ patch for Makefile: I still can't
figure out how to add three lines to the font files by
standard Makefile means.

-- 
WBR, Alexey Markov.
Comment 7 dfilter service freebsd_committer freebsd_triage 2013-08-15 20:12:58 UTC
Author: dinoex
Date: Thu Aug 15 19:12:46 2013
New Revision: 324782
URL: http://svnweb.freebsd.org/changeset/ports/324782

Log:
  - fix option GD_FONTS
  - fix bdftogd and bump PORTREVISION
  PR:		181250

Modified:
  head/graphics/gd/Makefile
  head/graphics/gd/files/patch-bdftogd

Modified: head/graphics/gd/Makefile
==============================================================================
--- head/graphics/gd/Makefile	Thu Aug 15 19:02:34 2013	(r324781)
+++ head/graphics/gd/Makefile	Thu Aug 15 19:12:46 2013	(r324782)
@@ -3,7 +3,7 @@
 
 PORTNAME=	libgd
 PORTVERSION=	2.1.0
-PORTREVISION?=	0
+PORTREVISION?=	1
 PORTEPOCH=	1
 CATEGORIES+=	graphics
 MASTER_SITES=	http://cdn.bitbucket.org/libgd/gd-libgd/downloads/

Modified: head/graphics/gd/files/patch-bdftogd
==============================================================================
--- head/graphics/gd/files/patch-bdftogd	Thu Aug 15 19:02:34 2013	(r324781)
+++ head/graphics/gd/files/patch-bdftogd	Thu Aug 15 19:12:46 2013	(r324782)
@@ -1,5 +1,5 @@
 --- src/bdftogd.orig	2013-06-25 11:58:23.000000000 +0200
-+++ src/bdftogd	2013-08-01 07:06:11.000000000 +0200
++++ src/bdftogd	2013-08-15 21:03:29.000000000 +0200
 @@ -24,6 +24,9 @@
  my $filename = shift;
  $filename = 'gd' . $filename unless $filename =~ /^gd/i;
@@ -10,12 +10,23 @@
  if (-f "$filename.c") { die "File $filename.c already exists, won't overwrite\n"; }
  if (-f "$filename.h") { die "File $filename.h already exists, won't overwrite\n"; }
  
-@@ -177,28 +180,40 @@
+@@ -139,6 +142,10 @@
+ 
+ $info
+ 
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++
+ #include "$filename.h"
+ 
+ char ${gdname}Data[] = {
+@@ -177,28 +184,40 @@
  	${gdname}Data
  };
  
 -gdFontPtr ${gdname} = &${gdname}Rep;
-+BGD_EXPORT_DATA_IMPL gdFontPtr ${gdname} = &${gdname}Rep;
++BGD_EXPORT_DATA_PROT gdFontPtr ${gdname} = &${gdname}Rep;
  
 -/* This file has not been truncated. */
 +BGD_DECLARE(gdFontPtr)
@@ -44,8 +55,8 @@
  #include "gd.h"
  
 -extern gdFontPtr $gdname;
-+   BGD_EXPORT_DATA_PROT  gdFontPtr $gdname;
-+   BGD_DECLARE(gdFontPtr) $gdfunc(void);
++extern BGD_EXPORT_DATA_PROT  gdFontPtr $gdname;
++BGD_DECLARE(gdFontPtr) $gdfunc(void);
  
 +#ifdef __cplusplus
 +}
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 8 Dirk Meyer freebsd_committer freebsd_triage 2013-08-15 20:26:25 UTC
State Changed
From-To: feedback->closed


The patch to bdftogd should fix the problem for all fonts.