<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>118600</bug_id>
          
          <creation_ts>2006-01-10 17:38 0000</creation_ts>
          <short_desc>largefile support in audiofile breaks esd on ppc</short_desc>
          <delta_ts>2007-02-21 04:06:57 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>2005.1</version>
          <rep_platform>PPC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ed@catmur.co.uk</reporter>
          <assigned_to>sound@gentoo.org</assigned_to>
          <cc>f95.lupo@gmail.com</cc>
    
    <cc>ppc@gentoo.org</cc>

      

      
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-01-10 17:38:27 0000</bug_when>
            <thetext>audiofile-0.2.6 is built with largefile support.

This breaks on big-endian 32-bit architectures (PPC) because the API and ABI conflict on the width of off_t; audiofile is built with _FILE_OFFSET_BITS = 64 so its off_t is 64-bit but esd (which links against audiofile) is built without so its off_t is 32-bit. The result is that functions that return off_t have the low 32 bits (the ones that matter) discarded. (This is why little-endian 32-bit architectures (x86) are OK; they discard the high 32 bits of off_t values, typically all zero.)

Quick fix: build audiofile without largefile on ppc and other big-endian 32-bit architectures.

Better: make the exposed API of audiofile use a type with well-defined width. Is this possible?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lu_zero@gentoo.org</who>
            <bug_when>2006-01-10 20:53:16 0000</bug_when>
            <thetext>why esd shouldn&apos;t use off_t as uint64_t if largefile is set?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-01-11 03:18:07 0000</bug_when>
            <thetext>esd is built without largefile support; that&apos;s the problem. (Ditto with anything else built against audiofile and without largefile support.)

Basically, off_t is not suitable for use in API because its width is not well defined.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-01-11 03:31:53 0000</bug_when>
            <thetext>Also, there are other packages built against audiofile; these will also break.

Actually, this needs fixing on x86 as well as there are potential crashers in the API; e.g. afSeekFrame takes an off_t as its last argument (frameoffset); on x86 only 32 bits will be placed on the stack so the high 32 bits of frameoffset will be taken from whatever is next on the stack.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-01-11 04:30:45 0000</bug_when>
            <thetext>Uh, I&apos;ve found a website that discusses this problem:

http://ac-archive.sourceforge.net/largefile/index.html

It seems changing off_t to int64_t in the exposed audiofile headers will fix the structure-mismatch and callframe-mismatch problems.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>lu_zero@gentoo.org</who>
            <bug_when>2006-01-11 20:37:27 0000</bug_when>
            <thetext>any upstream acknowledge of the issue?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-01-11 21:05:18 0000</bug_when>
            <thetext>Not much. http://blog.gmane.org/gmane.comp.audio.audiofile (third item) indicates the audiofile maintainers at least accept the issue exists. Can&apos;t find anything on the Gnome side of things, though. (There is plenty of stuff on largefile problems, but I can&apos;t find any discussions specifically on audiofile&lt;-&gt;esd.)

I imagine relatively few distros compile audiofile with largefile -- Fedora doesn&apos;t, I don&apos;t think Debian does; Mandrake does but they don&apos;t run on ppc so they won&apos;t have hit this bug.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>flameeyes@gentoo.org</who>
            <bug_when>2006-10-04 23:51:29 0000</bug_when>
            <thetext>As upstream seems pretty deadish, would you mind submitting a patch to change off_t to int64_t ? Or I&apos;ll try to do that asap.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-10-05 15:28:42 0000</bug_when>
            <thetext>Note: test case is:

$ ESDBG=1 esdplay /usr/share/sounds/warning.wav
frames: 0 channels: 1 rate: 44100.000000 format: 401 width: 16

Frames should be 6880 or similar.

I&apos;ve got a patch; I&apos;m just finishing testing it now. Unfortunately I don&apos;t have access to x86 or amd64 at the moment so someone else will have to test it there.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ed@catmur.co.uk</who>
            <bug_when>2006-10-05 15:31:02 0000</bug_when>
            <thetext>Created an attachment (id=98889)
api_replace_largefile_dependent_types.patch

Suggested patch. I think we can get away with something this simple; all that matters is that int64_t is of constant width and can always store an off_t.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>star@bamba.lt</who>
            <bug_when>2006-10-10 16:25:59 0000</bug_when>
            <thetext>Yep it should go upstream. I was running circles around it, until i found the problem. Confirmed on 32-bit ppc. 
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>josejx@gentoo.org</who>
            <bug_when>2007-02-08 02:20:38 0000</bug_when>
            <thetext>Diego, I can confirm that this fixes the problem on ppc.  Would you be okay with applying it?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>josejx@gentoo.org</who>
            <bug_when>2007-02-21 04:06:57 0000</bug_when>
            <thetext>InCVS.  Thanks!</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>98889</attachid>
            <date>2006-10-05 15:31 0000</date>
            <desc>api_replace_largefile_dependent_types.patch</desc>
            <filename>api_replace_largefile_dependent_types.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGxpYmF1ZGlvZmlsZS9hdWRpb2ZpbGUuaAkyMDA2LzEwLzA1IDIyOjA1OjUwCTEuMQorKysg
bGliYXVkaW9maWxlL2F1ZGlvZmlsZS5oCTIwMDYvMTAvMDUgMjI6MDY6MDAKQEAgLTQ1LDggKzQ1
LDggQEAgdHlwZWRlZiBzdHJ1Y3QgX0FGZmlsZXNldHVwICpBRmZpbGVzZXR1cAogdHlwZWRlZiBz
dHJ1Y3QgX0FGZmlsZWhhbmRsZSAqQUZmaWxlaGFuZGxlOwogdHlwZWRlZiB2b2lkICgqQUZlcnJm
dW5jKShsb25nLCBjb25zdCBjaGFyICopOwogCi10eXBlZGVmIG9mZl90IEFGZnJhbWVjb3VudDsK
LXR5cGVkZWYgb2ZmX3QgQUZmaWxlb2Zmc2V0OwordHlwZWRlZiBpbnQ2NF90IEFGZnJhbWVjb3Vu
dDsKK3R5cGVkZWYgaW50NjRfdCBBRmZpbGVvZmZzZXQ7CiAKICNkZWZpbmUgQUZfTlVMTF9GSUxF
U0VUVVAJKChzdHJ1Y3QgX0FGZmlsZXNldHVwICopIDApCiAjZGVmaW5lIEFGX05VTExfRklMRUhB
TkRMRQkoKHN0cnVjdCBfQUZmaWxlaGFuZGxlICopIDApCg==
</data>        

          </attachment>
    </bug>

</bugzilla>