Bug 691989

Summary: gp_semaphore is underaligned on sparc32
Product: Ghostscript Reporter: Jonathan Nieder <jrnieder>
Component: PS InterpreterAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 9.00   
Hardware: Sun   
OS: Linux   
Customer: Word Size: ---
Attachments: patch to give gp_semaphore maximal alignment

Description Jonathan Nieder 2011-02-21 00:03:37 UTC
Created attachment 7268 [details]
patch to give gp_semaphore maximal alignment

Analysis by Julien Cristau.  A quick test with the attached patch seems to work.  See http://bugs.debian.org/613642 for details.

Stéphane Glondu wrote:

> ocaml-melt currently FTBFS on sparc [1] because of a bus error
> provoked by ps2pdf. The bus error is easily reproduced by running
> ps2pdf on the file available at [2]. This bug is not present with the
> previous version, 8.71~dfsg2-10.
> 
> [1] https://buildd.debian.org/fetch.cgi?pkg=ocaml-melt&arch=sparc&ver=1.3.0-2&stamp=1297644449&file=log&as=raw
> [2] http://glondu.net/tmp/doc.ps
> 
(gdb) bt
#0  __pthread_cond_init (cond=0x28a8c, cond_attr=0x0) at pthread_cond_init.c:38
#1  0xf760d27c in __pthread_cond_init (cond=0x28a8c, cond_attr=0x0)
    at forward.c:117
#2  0xf78b1ce0 in gp_semaphore_open (sema=0x28a6c) at ./base/gp_psync.c:71
#3  0xf7a633c0 in gx_semaphore_alloc (memory=0x22870) at ./base/gxsync.c:59
#4  0xf786d23c in gsicc_cache_new (memory=0x224a8) at ./base/gsicc_cache.c:111
#5  0xf7a14dec in gs_imager_state_initialize (pis=0x3d4b8, mem=0x224a8)
    at ./base/gsistate.c:141
#6  0xf7a20c9c in gs_state_alloc (mem=0x224a8) at ./base/gsstate.c:234
#7  0xf780a0e4 in int_gstate_alloc (dmem=0xffd42050) at ./psi/zgstate.c:114
#8  0xf77d21bc in context_state_alloc (ppcst=0xffd41f3c, 
    psystem_dict=0xffd41fe8, dmem=0xffd42050) at ./psi/icontext.c:131
#9  0xf77d9748 in gs_interp_init (pi_ctx_p=0x221e4, psystem_dict=0xffd41fe8, 
    dmem=0xffd42050) at ./psi/interp.c:286
#10 0xf77d609c in obj_init (pi_ctx_p=0x221e4, idmem=0xffd42050)
    at ./psi/iinit.c:243
#11 0xf77ce42c in gs_main_init1 (minst=0x22190) at ./psi/imain.c:199
#12 0xf77cf784 in swproc (minst=0x22190, arg=<value optimized out>, 
    pal=0xffd427a4) at ./psi/imainarg.c:571
#13 0xf77d0854 in gs_main_init_with_args (minst=0x22190, argc=18, 
    argv=0xffd431d4) at ./psi/imainarg.c:200
#14 0x00010928 in main (argc=18, argv=0xffd431d4) at ./psi/dxmainc.c:84

cond needs to be 8-byte aligned, but isn't.
Comment 1 Chris Liddell (chrisl) 2011-02-21 16:17:53 UTC
Fixed in r12178.

The patch committed is just slightly changed to make use of Ghostscript's int64_t.

You can see the commit message and exact patch here:
http://ghostscript.com/pipermail/gs-cvs/2011-February/012339.html

Thanks for tracking this down, it's very much appreciated!