天天看點

ijsgutenprint出現segment fault

      ijsgutenprint移植到Android出現的問題,在一般的嵌入式linux上沒有問題,對比差異的過程中在Google出了答案(開始會以為檔案系統差異導緻的呢,因為Android的沒有/tmp目錄),如果這個問題不Google也能找出答案,這次的經驗教訓是寫代碼不能太不可思議了,出現的錯誤和問題表面上都看不出關聯來,還是在一個05年發的文章中找到了答案,糾結了一下午。以下轉載:http://sourceforge.net/p/gimp-print/bugs/406/

I have RPMized the snapshot for Mandriva Linux in the

last days, because the beta4 had some Foomatic bugs

which prevented print queues from working.

On some machines Gutenprint then worked perfectly

(tested by me and others with the Stylus Photo 950,

Stylus C84, and Stylus C86). On another machine I got a

core dump with the Stylus Photo 950, but the core dump

even persisted when choosing another device (C84) or a

non-existing device (entering gibberish as

"-sDeviceModel=..." argument). Strangely enough one set

of RPM packages, built on the Mandriva compilation

cluster, worked on the first box and had

ijsgutenprint.5.0 coredumping on the second machine.

ESP GhostScript was also from the same RPM on the two

machines and both were set to french locale.

Fortunately, the behaviour did not change when

rebuilding the RPM with "--enable-debug" added to the

"./configure ..." line and the stripping by RPM being

turned off. So I could run the core file through gdb:

------------------------------------------------------------------------------------------

[[email protected] g]# cat

/usr/share/cups/data/testprint.ps | gs -q

-dPARANOIDSAFER -dNOPAUSE -dBATCH -sDEVICE=ijs

-sIjsServer=/usr/bin/ijsgutenprint.5.0 -dIjsUseOutputFD

-sDeviceManufacturer=Epson -sDeviceModel=escp2-950

-dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792

-r360x360 -sProcessColorModel=DeviceRGB -sOutputFile=-

- > x

DEBUG: ESP Ghostscript 815.01: Can't start ijs server

"/usr/bin/ijsgutenprint.5.0"

[[email protected] g]#

[[email protected] g]#

[[email protected] g]#

[[email protected] g]# ll core.15257

-rw------- 1 root root 376832 ao 25 22:52 core.15257

[[email protected] g]# gdb -c core.15257 

/usr/bin/ijsgutenprint.5.0

GNU gdb 6.3-5mdk (Mandriva Linux release 2006.0)

Copyright 2004 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public

License, and you are

welcome to change it and/or distribute copies of it

under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB. Type "show

warranty" for details.

This GDB was configured as

"i586-mandriva-linux-gnu"...Using host libthread_db

library "/lib/tls/libthread_db.so.1".

warning: core file may not match specified executable file.

Reading symbols from shared object read from target

memory...done.

Loaded system supplied DSO at 0xffffe000

Core was generated by `/usr/bin/ijsgutenprint.5.0'.

Program terminated with signal 11, Segmentation fault.

warning: svr4_current_sos: Can't read pathname for load

map: Input/output error

Reading symbols from /usr/lib/libgutenprint.so.2...done.

Loaded symbols for /usr/lib/libgutenprint.so.2

Reading symbols from /lib/tls/libm.so.6...done.

Loaded symbols for /lib/tls/libm.so.6

Reading symbols from /usr/lib/libijs.so.1...done.

Loaded symbols for /usr/lib/libijs.so.1

Reading symbols from /lib/tls/libc.so.6...done.

Loaded symbols for /lib/tls/libc.so.6

Reading symbols from /lib/ld-linux.so.2...done.

Loaded symbols for /lib/ld-linux.so.2

#0 0xb7f40b97 in stpi_get_printfuncs (printer=0x0) at

printers.c:174

174 printers.c: No such file or directory.

in printers.c

(gdb) bt

#0 0xb7f40b97 in stpi_get_printfuncs (printer=0x0) at

printers.c:174

#1 0xb7f40b7b in stp_printer_list_parameters

(v=0x8053da0) at printers.c:247

#2 0xb7f38b86 in stp_get_parameter_list (v=0x8053da0)

at print-util.c:607

#3 0x0804d74a in stp_dbg (msg=0x80502a4

"ijsgutenprint: about to start\n",

v=0x8053da0) at ijsgutenprint.c:972

#4 0x0804e869 in main (argc=1, argv=0xbfbcf614) at

ijsgutenprint.c:1210

(gdb) quit

[[email protected] g]#

------------------------------------------------------------------------------------------

Here is the ".configure" command line which I have used:

------------------------------------------------------------------------------------------

configure --enable-shared --disable-rpath

--disable-libgutenprintui --enable-libgutenprintui2

--without-gimp --with-gimp2 --with-cups --with-ijs

--with-foomatic --with-foomatic3

--enable-cups-level3-ppds --disable-translated-ppds

--disable-cups-level3-ps --disable-static-genppd

------------------------------------------------------------------------------------------

RPM has added following optimization flags: -O2

-fomit-frame-pointer -pipe -march=i586 -mtune=pentiumpro

In the debug mode build "-O2" was replaced by -g.

Logged In: YES 

user_id=47862

I have found the cause of the problem: the printers.xml file

was missing on the machine where the core dump occured and

it was present on the other box. After installing it, the

printer printed correctly. The missing printers.xml was

caused by a missing dependency in my RPMs. So it was not a

bug of Gutenprint.

看發帖這個哥們愣是調試出來了,我調試用的是strace,結果什麼都看不出來。應該向人家學習學習。