|
Home About Us A-Z Index Search * Contact Us Register Login Press ShopThe Open Brand -- Problem Reporting and Interpretations System |
Problem Report 0125 Details
Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges
This page provides all information on Problem Report 0125.
Report 0125 Actions
Problem Report Number 0125 Submitter's Classification Test Suite problem State Resolved Resolution Test Suite Deficiency (TSD) Problem Resolution ID TSD.X.0125 Raised 1993-11-24 08:00 Updated 2003-03-13 08:00 Published 1993-12-08 08:00 Product Standard Internationalised System Calls and Libraries (XPG4) Certification Program The Open Brand certification program Test Suite VSX4 version 4.2.4 Test Identification ANSI.os/genuts/free 1 Problem Summary TSD4.125 The strategy in test 1 seems flawed based on the XPG4 and ANSI C specifications. The basic assumption that the same memory area is allocated on the subsequent malloc() after a free(), is not specified... Problem Text
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The strategy in test 1 seems flawed based on the XPG4 and ANSI C
specifications. The basic assumption that the same memory area is
allocated on the subsequent malloc() after a free(), is not specified
in XPG4 or ANSI. This assumption would require that an implementation
follow a specified algorithm for allocation of memory. Since no such
algorithm is specified by XPG4 or ANSI, the assumption made in the
test strategy is in error.
The algorithm/strategy used in our implementation is based on our
performance analysis and advanced algorithms for memory allocation
and dispersement. When smaller blocks are free'd, they are coalesced
into larger blocks, effectively removing the "individuality" of the
smaller block. Therefore, acquiring the exact same memory region in
a subsequent malloc is not guaranteed.
The following test program successfully demonstrates that our
implementation does indeed make free'd memory "availabe for further
allocation". Please feel free to review this test program.
In general, there needs to be a way to test the functionality as
specified for free(), without infringing on the ability of an
implementation to utilize unique algorithms for memory allocation.
---------------------Test program source -------------------------
/************************************************************************/
/* */
/* This program tests the free() specification "makes memory available */
/* for further allocation". */
/* */
/************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <malloc.h>
main(arg_num, argv )
int arg_num;
char *argv[];
{
long size = 40, i, j;
char *a, *b, *c;
a = malloc(size);
if(a == NULL) {
perror("free_test");
exit(1);
}
printf("free_test: malloc obtained the block a = (0x%x to 0x%x)\n",
a, a + size);
free(a);
printf("free_test: freed a\n");
for(i = 0; i < 2400; i++) {
b = malloc(size);
printf("free_test: malloc obtained the block b = (0x%x to 0x%x)\n",
b, b + size);
if(b == NULL) {
perror("free_test:");
exit(1);
}
for(j = 0; j < size; j++) {
c = &a[j];
if(c == b || (c > b && c < (b + size))) {
printf( "free_test: found block a[%ld] (0x%x) in b = (0x%x to 0x%x)\n",
j, c, b, b + size);
exit(0);
}
}
free(b);
}
printf("free_test: failed to re-malloc a\n");
}
--------------------------- End of test program source ------------------
The output from this test program was:
-------------------output------------------------------------------------
xtest2: malloc obtained the block a = (0x40003000 to 0x40003028)
xtest2: freed a
xtest2: malloc obtained the block b = (0x40003030 to 0x40003058)
xtest2: malloc obtained the block b = (0x40003000 to 0x40003028)
xtest2: found block a[0] (0x40003000) in b = (0x40003000 to 0x40003028)
-----------------end of output--------------------------------------------Test Output
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/tset/ANSI.os/genuts/free/T.free 1 Failed
Test Description:
free() frees the block pointed to by ptr and makes it available for
further allocation.
Posix Ref: Component FREE Assertion 8.1-04(A)
Test Strategy:
CREATE child process
CHILD process will
CALL malloc() to allocate a range of memory sizes
INITIALISE area of memory last allocated to contain NULL characters
CALL free() to free the area of memory last allocated
CALL malloc() to allocate same size of memory as that just freed
INITIALISE area of memory last allocated to contain non-NULL
characters
VERIFY that area of memory previously allocated contains non-NULL
characters (malloc() re-used freed memory)
Test Information:
failed to reuse freed memory for next malloc()
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Review Information
Review Type TSMA Review Start Date null Completed null Status Complete Review Recommendation No Resolution Given Review Response
It is accepted that this implementation correctly frees allocated memory in
a manner which allows its future re-use. A Test Suite Deficiency is
recommended.
Review Type SA Review Start Date null Completed null Status Complete Review Resolution Test Suite Deficiency (TSD) Review Conclusion
This is an agreed Test Suite Deficiency.
Problem Reporting System Options:
- View Report 0125
- List All PRs
- Search Reports
- Email the System Administrator
- View the The Open Brand Interpretations Database User Manual
Contact the Certification Authority