memalign() bug found & fixed

Kurt Wampler Kurt.Wampler at asml.com
Fri Jan 16 17:44:43 PST 2015


Greetings,

I'm new to this list, so will expect guidance if I violate any conventions.

I'd like to report a bug which we found and fixed in jemalloc-3.6.0.

In the imemalign() function, when the allocation fails, there are
"goto" statements that end up reaching "label_return:" without ever
dereferencing memptr (the first argument).  However, je_memalign() is
written in a way that ignores imemalign()'s function return value, and
depends instead on imemalign() to communicate the results using memptr.

Our local fix for this problem was to move one line in imemalign() below
"label_return:".


Original code:
-------------

        *memptr = result;
        ret = 0;
label_return:


Revised code:
------------

        ret = 0;
label_return:
        *memptr = result;


The above seemed like the simplest fix, but maybe it would be clearer
to change je_memalign() to follow the same convention as je_posix_memalign()?

Regards,

Kurt Wampler  (Kurt.Wampler at asml.com)  408-200-3722

-- The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. Unless explicitly stated otherwise in the body of this communication or the attachment thereto (if any), the information is provided on an AS-IS basis without any express or implied warranties or liabilities. To the extent you are relying on this information, you are doing so at your own risk. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. The sender nor the company/group of companies he or she represents shall be liable for the proper and complete transmission of the information contained in this communication, or for any delay in its receipt.


More information about the jemalloc-discuss mailing list