ports/174689: lang/python27: 64-bit pointers returned by C library get reduced to 32-bit

Rene Ladan rene at FreeBSD.org
Mon Dec 24 23:30:00 UTC 2012


>Number:         174689
>Category:       ports
>Synopsis:       lang/python27: 64-bit pointers returned by C library get reduced to 32-bit
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 24 23:30:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Rene Ladan
>Release:        FreeBSD 10-amd64
>Organization:
>Environment:
FreeBSD acer 10.0-CURRENT FreeBSD 10.0-CURRENT #6 r244650: Mon Dec 24 15:28:03 CET 2012     rene at acer:/usr/obj/usr/src/sys/GENERIC  amd64

Python 2.7.3 (default, Dec 24 2012, 23:47:23) 
[GCC 4.2.1 Compatible FreeBSD Clang 3.2 (tags/RELEASE_32/final 170710)] on freebsd10

>Description:
When initializing libmpg123.so.0 (audio/mpg123) from Python with CDLL, the 64-bit pointer value returned by mpg123_new(None, None) gets reduced to 32 bits.  The equivalent program in C does not have this problem.

-----8<----------------8<----------------------------8<-----------------
from ctypes import *

mpg123 = CDLL('libmpg123.so') # audio/mpg123
print mpg123

MPG123_OK = 0
if mpg123.mpg123_init() != MPG123_OK:
    print "mpg123_init() failed"
else:
    mh = mpg123.mpg123_new(None, None)
    # wrapping in c_void_p() does not help
    print "python mh=", hex(mh) # 0x800000000 short of C library result
    print "open_feed(mh)=", mpg123.mpg123_open_feed(mh) #XXX coredumps
    mpg123.mpg123_exit()
-----8<----------------8<----------------------------8<-----------------

When running this:

% python testcdll.py
<CDLL 'libmpg123.so', handle 800805c00 at 801a9c390>
mh=0x801af8000
python mh= 0x1af8000
Segmentation fault (core dumped)

To see the first value of mh, add this patch to audio/mpg123/files:
 
-----8<----------------8<----------------------------8<-----------------
--- src/libmpg123/libmpg123.c.orig	2012-07-26 15:36:44.000000000 +0200
+++ src/libmpg123/libmpg123.c	2012-12-25 00:03:30.000000000 +0100
@@ -42,7 +42,11 @@
 /* create a new handle with specified decoder, decoder can be "", "auto" or NULL for auto-detection */
 mpg123_handle attribute_align_arg *mpg123_new(const char* decoder, int *error)
 {
-	return mpg123_parnew(NULL, decoder, error);
+	mpg123_handle *mh;
+
+	mh = mpg123_parnew(NULL, decoder, error);
+	fprintf(stderr, "mh=%p\n", mh);
+	return mh;
 }
 
 /* ...the full routine with optional initial parameters to override defaults. */

-----8<----------------8<----------------------------8<-----------------

>How-To-Repeat:
See above.
>Fix:
Not yet known.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-ports-bugs mailing list