Opened 17 years ago

Last modified 17 years ago

#304 closed defect

Memory alignment error for hash entry buffer causing crash on ARM (thanks ChenHuan) — at Initial Version

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-0.7.0
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description

When application wants to specify its own buffer when registering an entry in the hash table, it calls pj_hash_set_np and gives it a buffer. This buffer normally is declared by application as:

  char buffer[PJ_HASH_ENTRY_SIZE];

This buffer will be typecasted to struct pj_hash_entry in hash.c:

struct pj_hash_entry
{
    struct pj_hash_entry *next;
    const void *key;
    pj_uint32_t hash;
    pj_uint32_t keylen;
    void *value;
};

And this is where the problem starts.

Since the buffer is of type array of char, this won't get aligned by compiler, and later in find_entry() in hash.c, it will cause unaligned memory access exception in assignment to entry->value.

Change History (0)

Note: See TracTickets for help on using tickets.