[llvm-bugs] [Bug 26691] New: Report false positive leak of memory
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 22 05:09:07 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26691
Bug ID: 26691
Summary: Report false positive leak of memory
Product: tools
Version: 3.8
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: analyze
Assignee: unassignedbugs at nondot.org
Reporter: tony at airtame.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
OSX 10.11.3
checker-278
clang version 3.8.0
A function is used to post a message in a priority queue. The thread dequeuing
the message is freeing it with "free(message);". Scan-build report no error
when the message is enqueued in the body of the function that allocated it but
report a problem if the message is enqueued by another function. An example is
illustrated below.
------
Example 1:
// No problem reported
int32_t send_message(void *data, void *message_queue)
{
Msg_t *message = calloc(1, sizeof(Msg_t));
message->type = MSG_TYPE_SEND_MESSAGE;
message->data[0] = data;
mq_enqueue_message(message_queue, PRIORITY_HIGH, (void *)message);
return OK;
}
------
Example 2:
// Potential leak of memory pointed to by 'message'
int32_t send_message(void *data, void *message_queue)
{
Msg_t *message = calloc(1, sizeof(Msg_t));
message->type = MSG_TYPE_SEND_MESSAGE;
message->data[0] = data;
return enqueue(message, message_queue);
}
int32_t enqueue(Msg_t *message, void *message_queue)
{
mq_enqueue_message(message_queue, PRIORITY_HIGH, (void *)message);
return OK;
}
------
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160222/4a62545d/attachment.html>
More information about the llvm-bugs
mailing list