Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct.pack() on 64bit architectures #40101

Closed
pelotas mannequin opened this issue Mar 30, 2004 · 4 comments
Closed

struct.pack() on 64bit architectures #40101

pelotas mannequin opened this issue Mar 30, 2004 · 4 comments
Labels
tests Tests in the Lib/test dir

Comments

@pelotas
Copy link
Mannequin

pelotas mannequin commented Mar 30, 2004

BPO 925932
Nosy @tim-one, @loewis
Files
  • patch-Lib_test_test_fcntl_py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2007-04-10.16:45:14.000>
    created_at = <Date 2004-03-30.10:55:25.000>
    labels = ['tests']
    title = 'struct.pack() on 64bit architectures'
    updated_at = <Date 2007-04-10.16:45:14.000>
    user = 'https://bugs.python.org/pelotas'

    bugs.python.org fields:

    activity = <Date 2007-04-10.16:45:14.000>
    actor = 'zseil'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Tests']
    creation = <Date 2004-03-30.10:55:25.000>
    creator = 'pelotas'
    dependencies = []
    files = ['5900']
    hgrepos = []
    issue_num = 925932
    keywords = ['patch']
    message_count = 4.0
    messages = ['45688', '45689', '45690', '45691']
    nosy_count = 4.0
    nosy_names = ['tim.peters', 'loewis', 'zseil', 'pelotas']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue925932'
    versions = []

    @pelotas
    Copy link
    Mannequin Author

    pelotas mannequin commented Mar 30, 2004

    I'm running python on OpenBSD/sparc64 (SUN Ultra 10).

    On this machine struct.pack() gives me:

    >>> struct.pack('l', 1)
    '\x00\x00\x00\x00\x00\x00\x00\x01'
    >>> struct.pack('i', 1)
    '\x00\x00\x00\x01'

    On i386 box I have:

    >>> struct.pack('l', 1)
    '\x01\x00\x00\x00'
    >>> struct.pack('i', 1)
    '\x01\x00\x00\x00'

    Because of this, OpenBSD port uses attached patch. I
    guess that this is generic problem (not OpenBSD
    specific) and every 64bit platform would suffer.

    Am I right?

    @pelotas pelotas mannequin closed this as completed Mar 30, 2004
    @pelotas pelotas mannequin added the tests Tests in the Lib/test dir label Mar 30, 2004
    @pelotas pelotas mannequin closed this as completed Mar 30, 2004
    @pelotas pelotas mannequin added the tests Tests in the Lib/test dir label Mar 30, 2004
    @tim-one
    Copy link
    Member

    tim-one commented Mar 30, 2004

    Logged In: YES
    user_id=31435

    For a Unix-head reviewer: the patch is to test_fcntl.py,
    which uses a native struct.pack() to build a lockdata
    argument for fcntl. On the OP's box, it constructs stuff of
    the wrong size, due to "l" format codes producing 8-byte
    thingies. The patch changes the "l" codes to "i" on the OP's
    platform.

    I wonder whether we couldn't instead use "i" codes on all BSD-
    ish platforms -- on 32-bit boxes, "i" is synonymous with "l",
    while on 64-bit boxes it looks like "l" is wrong but "i" is correct.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 31, 2004

    Logged In: YES
    user_id=21627

    I don't quite understand the current code: struct flock is
    on Darwin

    struct flock {
            off_t   l_start;        /* starting offset */
            off_t   l_len;          /* len = 0 means until end
    of file */
            pid_t   l_pid;          /* lock owner */
            short   l_type;         /* lock type: read/write,
    etc. */
            short   l_whence;       /* type of l_start */
    };

    and off_t is

    typedef int64_t quad_t;
    typedef quad_t off_t; /* file offset */

    so it appears there is no padding at all. In any case,
    this needs to be changed in posixfile._posixfile_.flock
    accordingly.

    @zseil
    Copy link
    Mannequin

    zseil mannequin commented Apr 10, 2007

    test_fcntl was fixed in r38766 and r38767 to support
    64bit BSD systems:

    http://svn.python.org/view?rev=38766&view=rev

    That fix is included in Python 2.4.2 and above.
    Thanks for the patch anyway!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant