|
Home About Us A-Z Index Search * Contact Us Register Login Press ShopThe Open Brand -- Problem Reporting and Interpretations System |
Problem Report 2708 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 2708.
Report 2708 Actions
Problem Report Number 2708 Submitter's Classification Test Suite problem State Resolved Resolution Rejected (REJ) Problem Resolution ID REJ.X.0699 Raised 2020-05-22 10:56 Updated 2020-09-24 15:31 Published 2020-09-24 15:31 Product Standard Internationalised System Calls and Libraries Extended V3 (UNIX 03) Certification Program The Open Brand certification program Test Suite VSU version 5.3.18NW Test Identification tset/CAPI.os/jump/makeconte/T.makeconte, Assertion 1 Specification Base Definitions Issue 6 Location in Spec https://pubs.opengroup.org/onlinepubs/009695399/functions/makecontext.html Problem Summary The test for makecontext() Assertion 1 uses a non-portable construction that does not work on our
system.Problem Text The file makeconte1.c (in tset/CAPI.os/jump/makeconte) contains the following code:
static int function_called = 0;
static ucontext_t ucp, ucp1, orig;
static void *stack, *stack1;
...
static void
test1A(void)
{
tet_infoline("TEST: makecontext() modifies context specified by ucp");
getcontext(&ucp);
if(!function_called) {
memcpy(&orig, &ucp, sizeof(ucp));
if((stack = malloc(SIGSTKSZ*4)) == NULL) {
uwerrno("malloc");
return;
}
ucp.uc_stack.ss_sp = (void *)((char *)stack+(SIGSTKSZ*2));
ucp.uc_stack.ss_size = SIGSTKSZ;
ucp.uc_stack.ss_flags = 0;
errno = 0;
makecontext(&ucp, function, 8, 1, 2, 3, 4, 5, 6, 7, 8);
if(errno != 0) {
uwerrno("makecontext");
return;
}
if(memcmp((void *)&ucp, (void *)&orig, sizeof(ucp)) == 0) {
tet_infoline("ERROR: ucp was not modified");
tet_result(TET_FAIL);
return;
}
The test goes on to switch contexts around and eventually calls setcontext(&orig) after
function_called has been set to 1.
The issue here is that memcpy() is not a valid or portable way to way to copy a ucontext_t. For
example, a ucontext_t may have additional internal data pointers pointing to the ucontext_t or
unique identifiers, which is allowed:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/ucontext.h.html
> The <ucontext.h> header shall define the ucontext_t type as a structure that shall include at
least the following members:...
Specifically, if U is a ucontext_t then our getcontext(&U) sets the value of the uc_mcontext field to
refer to other internal data in U. A memcpy of this structure will result in a ucontext_t with a
uc_mcontext field that references, not its own data structures, but the data structures in U. That is
an invalid structure.
In the test case, the call to setcontext(&orig) jumps to the intermediate context (which happens to
be the context decribed by ucp) instead of jumping back into test1A just after the
getcontext(&ucp) call. The test should instead make 2 getcontext() calls (for &orig and &ucp) in
test1A because getcontext() is the proper initializer for this structure.Test Output 400|197 1 1 23:53:56|IC Start
520|197 1 00051695 1 1|TEST: makecontext() modifies context specified by ucp
520|197 1 00051695 1 2|PREP: Generate a new context
520|197 1 00051695 1 3|PREP: Allocate stack space
520|197 1 00051695 1 4|TEST: Call makecontext
520|197 1 00051695 1 5|TEST: Execution continues with func after setcontext()
520|197 1 00051695 1 6|TEST: Parameters passed correctly after setcontext
520|197 1 00051695 1 7|PREP: Generate another new context
520|197 1 00051695 1 8|PREP: Allocate stack space
520|197 1 00051695 1 9|TEST: Call makecontext
520|197 1 00051695 1 10|TEST: Execution continues with func after swapcontext()
520|197 1 00051695 1 11|ERROR: Execution continued after swapcontext() call
220|197 1 1 23:53:56|FAIL
410|197 1 1 23:53:56|IC EndReview Information
Review Type TSMA Review Start Date 2020-05-22 10:56 Last Updated 2020-05-22 10:00 Completed 2020-05-22 10:00 Status Complete Review Recommendation Rejected (REJ) Review Response When a copy of a data object cannot be used, the standard says so
explicitly. See for example XSH 2.5 Standard I/O Streams:
"The address of the FILE object used to control a stream may be
significant; a copy of a FILE object need not necessarily serve in place
of the original."
or pthread_barrier_init():
"Only the object referenced by barrier may be used for performing
synchronization. The result of referring to copies of that object in
calls to pthread_barrier_destroy() or pthread_barrier_wait() is
undefined."
(and similar text for pthread_cond_init(), pthread_mutex_init(),
pthread_rwlock_init() and pthread_spin_init()).
There is no such text for the ucontext_t object initialised by
getcontext().
Also, this test has used setcontext(&orig) since 1994 and has worked on
all systems that have been certified since then (including earlier
versions of the submitter's system). There may well be applications that
rely on using a copy of the ucontext_t object and which will therefore
not be portable to an implementation that fails this test.
It is recommended that this TSD request is rejected.
Review Type SA Review Start Date 2020-05-22 18:00 Last Updated 2020-05-26 15:06 Completed 2020-05-26 15:06 Status Complete Review Resolution Rejected (REJ) Review Conclusion This TSD request is rejected.
When a copy of a data object cannot be used, the standard says so
explicitly. See for example XSH 2.5 Standard I/O Streams:
"The address of the FILE object used to control a stream may be
significant; a copy of a FILE object need not necessarily serve in place
of the original."
or pthread_barrier_init():
"Only the object referenced by barrier may be used for performing
synchronization. The result of referring to copies of that object in
calls to pthread_barrier_destroy() or pthread_barrier_wait() is
undefined."
(and similar text for pthread_cond_init(), pthread_mutex_init(),
pthread_rwlock_init() and pthread_spin_init()).
There is no such text for the ucontext_t object initialised by
getcontext().
Also, this test has used setcontext(&orig) since 1994 and has worked on
all systems that have been certified since then (including earlier
versions of the submitter's system). There may well be applications that
rely on using a copy of the ucontext_t object and which will therefore
not be portable to an implementation that fails this test.
Problem Reporting System Options:
- View Report 2708
- List All PRs
- Search Reports
- Email the System Administrator
- View the The Open Brand Interpretations Database User Manual
Contact the Certification Authority