Extend the test coverage
Move some of the RHEL QE testcases upstream to Fedora.
This commit is contained in:
parent
221d1d8371
commit
ab4bc8a24e
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
||||
# Description: Calls getaddrinfo and verifies behavior as per BZ
|
||||
# Author: Arjun Shankar <ashankar@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE tst-getaddrinfo.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
test -x runtest.sh || chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Arjun Shankar <ashankar@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Calls getaddrinfo and verifies behavior as per BZ" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: gcc glibc glibc-devel glibc-headers" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 1022022" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,3 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
||||
Description: Calls getaddrinfo and verifies behavior as per BZ
|
||||
Author: Arjun Shankar <ashankar@redhat.com>
|
@ -0,0 +1,17 @@
|
||||
summary: Calls getaddrinfo and verifies behavior as per BZ
|
||||
description: ''
|
||||
contact: Arjun Shankar <ashankar@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- gcc
|
||||
- glibc
|
||||
- glibc-devel
|
||||
- glibc-headers
|
||||
duration: 15m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1022022
|
||||
extra-summary: /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
||||
extra-task: /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz1022022-getaddrinfo-behavior-changed-between-RHEL-6-4-and-RHEL-6-5
|
||||
# Description: Calls getaddrinfo and verifies behavior as per BZ
|
||||
# Author: Arjun Shankar <ashankar@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE=glibc
|
||||
REQUIRES=(gcc glibc glibc-devel)
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
for p in "${REQUIRES[@]}"; do
|
||||
rlAssertRpm "$p"
|
||||
done; unset p
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "cp tst-getaddrinfo.c $TmpDir"
|
||||
rlRun "pushd $TmpDir"
|
||||
|
||||
rlRun "gcc -o tst-getaddrinfo tst-getaddrinfo.c"
|
||||
rlAssertExists "tst-getaddrinfo"
|
||||
|
||||
rlRun "ORIG_HOSTNAME=$(hostname)"
|
||||
rlFileBackup --clean "/etc/hostname"
|
||||
rlRun "echo 'www' > /etc/hostname"
|
||||
rlRun "hostname -F /etc/hostname"
|
||||
|
||||
rlFileBackup --clean "/etc/hosts"
|
||||
rlRun "echo '127.0.0.1 www.fubar.redhat www' >> /etc/hosts"
|
||||
rlRun "echo '::1 www.fubar.redhat www' >> /etc/hosts"
|
||||
# Note that the 'canonical name' is always the first name entry in
|
||||
# each tuple ^, i.e. 'www.fubar.redhat' in our case
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "./tst-getaddrinfo > tst.out"
|
||||
rlLog "$(cat tst.out)"
|
||||
rlRun "OUT=($(cat tst.out))"
|
||||
rlAssertEquals "Correct number of output lines" "${#OUT[@]}" "4"
|
||||
|
||||
if rlIsRHEL 6; then
|
||||
# The result 'www' for AF_INET is basically incorrect, but we want to
|
||||
# keep it consistent during the life of RHEL 6
|
||||
rlAssertEquals "gethostname" "${OUT[0]}" "www"
|
||||
rlAssertEquals "getaddrinfo, AF_INET" "${OUT[1]}" "www"
|
||||
rlAssertEquals "getaddrinfo, AF_UNSPEC" "${OUT[3]}" "www.fubar.redhat"
|
||||
|
||||
rlLog "We don't check (getaddrinfo, AF_INET6) on RHEL 6"
|
||||
else
|
||||
rlAssertEquals "gethostname" "${OUT[0]}" "www"
|
||||
rlAssertEquals "getaddrinfo, AF_INET" "${OUT[1]}" "www.fubar.redhat"
|
||||
rlAssertEquals "getaddrinfo, AF_INET6" "${OUT[2]}" "www.fubar.redhat"
|
||||
rlAssertEquals "getaddrinfo, AF_UNSPEC" "${OUT[3]}" "www.fubar.redhat"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlFileRestore "/etc/hosts"
|
||||
rlFileRestore "/etc/hostname"
|
||||
rlRun "hostname $ORIG_HOSTNAME"
|
||||
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
@ -0,0 +1,67 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SIZE 4096
|
||||
|
||||
#define exit_code_func_msg(c,f,m) \
|
||||
do \
|
||||
{ \
|
||||
printf ("error %d: %s: %s\n", c, f, m); \
|
||||
exit (1); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
static void
|
||||
get_canon_name (char *hostname, int af)
|
||||
{
|
||||
struct addrinfo hints, *result, *current;
|
||||
int error;
|
||||
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
hints.ai_family = af;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
|
||||
error = getaddrinfo (hostname, NULL, &hints, &result);
|
||||
|
||||
if (error != 0)
|
||||
exit_code_func_msg (error, "getaddrinfo", gai_strerror (error));
|
||||
|
||||
if (result->ai_canonname == NULL)
|
||||
exit_code_func_msg (-1, "getaddrinfo", "No canonical name returned");
|
||||
|
||||
for (current = result;
|
||||
current != NULL && current->ai_canonname != NULL;
|
||||
current = current->ai_next)
|
||||
printf ("%s\n", current->ai_canonname);
|
||||
|
||||
freeaddrinfo (result);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
||||
char hostname[SIZE];
|
||||
int error;
|
||||
|
||||
error = gethostname (hostname, SIZE);
|
||||
|
||||
if (error)
|
||||
exit_code_func_msg (error, "gethostname", "");
|
||||
|
||||
printf ("%s\n", hostname);
|
||||
|
||||
get_canon_name (hostname, AF_INET);
|
||||
get_canon_name (hostname, AF_INET6);
|
||||
get_canon_name (hostname, AF_UNSPEC);
|
||||
|
||||
return 0;
|
||||
}
|
49
tests/Regression/bz434601-timedlock-segfault/Makefile
Normal file
49
tests/Regression/bz434601-timedlock-segfault/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
# Makefile - bz434601-timedlock-segfault - Bugzilla(s) 434601
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /tools/glibc/Regression/bz434601-timedlock-segfault/Makefile
|
||||
|
||||
# Description: Tests segfault in pthread_mutex_timedlock function
|
||||
|
||||
|
||||
TOPLEVEL_NAMESPACE=/tools
|
||||
PACKAGE_NAME=glibc
|
||||
RELATIVE_PATH=Regression/bz434601-timedlock-segfault
|
||||
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile timedlock.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Tests segfault in pthread_mutex_timedlock function" >> $(METADATA)
|
||||
@echo "Bug: 434601" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 6m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "License: GPLv3" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
9
tests/Regression/bz434601-timedlock-segfault/PURPOSE
Normal file
9
tests/Regression/bz434601-timedlock-segfault/PURPOSE
Normal file
@ -0,0 +1,9 @@
|
||||
Test Name: bz434601-timedlock-segfault - Bugzilla(s) 434601
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz434601-timedlock-segfault
|
||||
|
||||
Short Description: Tests segfault in pthread_mutex_timedlock function
|
||||
|
||||
|
||||
Long Description:
|
||||
Tests segfault in pthread_mutex_timedlock function
|
24
tests/Regression/bz434601-timedlock-segfault/main.fmf
Normal file
24
tests/Regression/bz434601-timedlock-segfault/main.fmf
Normal file
@ -0,0 +1,24 @@
|
||||
summary: Tests segfault in pthread_mutex_timedlock function
|
||||
description: |
|
||||
Test Name: bz434601-timedlock-segfault - Bugzilla(s) 434601
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz434601-timedlock-segfault
|
||||
|
||||
Short Description: Tests segfault in pthread_mutex_timedlock function
|
||||
|
||||
|
||||
Long Description:
|
||||
Tests segfault in pthread_mutex_timedlock function
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
- gcc
|
||||
duration: 6m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=434601
|
||||
extra-summary: /tools/glibc/Regression/bz434601-timedlock-segfault
|
||||
extra-task: /tools/glibc/Regression/bz434601-timedlock-segfault
|
54
tests/Regression/bz434601-timedlock-segfault/runtest.sh
Executable file
54
tests/Regression/bz434601-timedlock-segfault/runtest.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz434601-timedlock-segfault
|
||||
# Description: Tests segfault in pthread_mutex_timedlock function bz434601
|
||||
# Author: Sergey Kolosov <skolosov@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2022 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
TESTPROG="timedlock"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "TESTTMPDIR=$(mktemp -d)"
|
||||
rlRun "cp ${TESTPROG}.c $TESTTMPDIR"
|
||||
rlRun "pushd $TESTTMPDIR"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG"
|
||||
rlAssertExists "$TESTPROG"
|
||||
rlRun -c "./${TESTPROG}"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TESTTMPDIR"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
|
64
tests/Regression/bz434601-timedlock-segfault/timedlock.c
Normal file
64
tests/Regression/bz434601-timedlock-segfault/timedlock.c
Normal file
@ -0,0 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static volatile int counter = 0;
|
||||
static volatile int stop = 0;
|
||||
|
||||
static void *
|
||||
testTimedLock(void *arg)
|
||||
{
|
||||
int rc = 0;
|
||||
struct timespec abstime;
|
||||
abstime.tv_sec = time(0) + 10;
|
||||
abstime.tv_nsec = 100000000;
|
||||
|
||||
for ( ; stop == 0; ) {
|
||||
rc = pthread_mutex_timedlock( &mutex, &abstime );
|
||||
if (rc != 0) { perror("Errno:"); };
|
||||
assert(rc == 0);
|
||||
++counter;
|
||||
rc = pthread_mutex_unlock( &mutex );
|
||||
if (rc != 0) { perror("Errno:"); };
|
||||
assert(rc == 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
createThreads(int nThreads, pthread_t *thr)
|
||||
{
|
||||
int nt;
|
||||
for ( nt = 0 ; nt < nThreads ; ++nt ) {
|
||||
int rc = pthread_create( thr+nt, NULL, testTimedLock, NULL);
|
||||
if (rc != 0) { perror("Errno:"); };
|
||||
assert( rc == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
joinThreads(int nThreads, pthread_t *thr)
|
||||
{
|
||||
int nt;
|
||||
for ( nt = 0 ; nt < nThreads ; ++nt ) {
|
||||
int rc = pthread_join( thr[nt], NULL);
|
||||
if (rc != 0) { perror("Errno:"); };
|
||||
assert( rc == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
int nThreads = 10;
|
||||
pthread_t thr[nThreads];
|
||||
|
||||
createThreads(nThreads, thr);
|
||||
usleep (1000000); // 1 second
|
||||
stop = 1;
|
||||
joinThreads(nThreads, thr);
|
||||
printf("counter = %d\n", counter);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
||||
# Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE testcase.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 455360" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,73 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
||||
Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: [RHEL4] vfprintf() call goes into recursive overflow and crashes with a segfault
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=455360
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem in short (details sent next thru IT):
|
||||
|
||||
Sporadically, when under load, the client is seeing tibco EMS processes be
|
||||
killed by segfaults. Getting a robust diagnosis has proven difficult, but from
|
||||
what can be told, it appears that somehow a vfprintf() call is getting into a
|
||||
state where it loops with:
|
||||
|
||||
<snip>
|
||||
6 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240
|
||||
#7 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=Variable "c" is not
|
||||
available.
|
||||
) at vfprintf.c:2058
|
||||
</snip>
|
||||
|
||||
It recurses for quite some time in glibc and then crashes with a segfault. I've
|
||||
just gotten the application binary (stripped unfortunately) and thus could
|
||||
actually get something from the core.
|
||||
|
||||
Customer's analysis:
|
||||
we have seen this issue before. What's going wrong is that we are calling
|
||||
vfprintf to perform a message trace including the body and the functions in
|
||||
glibc are recursing approximately 373909 frames and then it crashed.
|
||||
|
||||
|
||||
<snip>
|
||||
#373902 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240
|
||||
#373903 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=-1)
|
||||
at vfprintf.c:2058
|
||||
#373904 0x0086096f in _IO_default_xsputn (f=0xf7fe8688, data=0x32046928,
|
||||
n=10285) at genops.c:478
|
||||
#373905 0x0083e88e in _IO_vfprintf (s=0xf7fe8688,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", ap=0xf7feae90 "ïJ©\236À¦\004\204:Z\\Æ\\ò%$Ü\223K")
|
||||
at vfprintf.c:1553
|
||||
#373906 0x0083b0ac in buffered_vfprintf (s=0x929460,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", args=) at vfprintf.c:2144
|
||||
#373907 0x0083b2eb in _IO_vfprintf (s=0x929460,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", ap=0xf7feae58 "Яþ÷lê2\bP°þ÷;\216K") at vfprintf.c:1264
|
||||
#373908 0x0811ba34 in _authenticate ()
|
||||
#373909 0x0811bc4c in _authenticate ()
|
||||
#373910 0x080f7f3c in _authenticate ()
|
||||
#373911 0x080e8e6a in _authenticate ()
|
||||
#373912 0x080e6d88 in _authenticate ()
|
||||
#373913 0x080e6ed0 in _authenticate ()
|
||||
#373914 0x0807d4fd in ?? ()
|
||||
#373915 0x2846afc8 in ?? ()
|
||||
#373916 0x0830e880 in _IO_stdin_used ()
|
||||
#373917 0x00000432 in ?? ()
|
||||
#373918 0x0830e86d in _IO_stdin_used ()
|
||||
#373919 0x0830e86d in _IO_stdin_used ()
|
||||
#373920 0x00000000 in ?? ()
|
||||
</snip>
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.3.4-2.39
|
||||
|
||||
Additional info:
|
||||
|
||||
I have the core and binary set up on a lab host which has the correct version of
|
||||
glibc installed. Feel free to work on that host:
|
||||
|
||||
dhcp139.gsslab.rdu.redhat.com (root:redhat)
|
@ -0,0 +1,84 @@
|
||||
summary: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)
|
||||
description: |
|
||||
Bug summary: [RHEL4] vfprintf() call goes into recursive overflow and crashes with a segfault
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=455360
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem in short (details sent next thru IT):
|
||||
|
||||
Sporadically, when under load, the client is seeing tibco EMS processes be
|
||||
killed by segfaults. Getting a robust diagnosis has proven difficult, but from
|
||||
what can be told, it appears that somehow a vfprintf() call is getting into a
|
||||
state where it loops with:
|
||||
|
||||
<snip>
|
||||
6 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240
|
||||
#7 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=Variable "c" is not
|
||||
available.
|
||||
) at vfprintf.c:2058
|
||||
</snip>
|
||||
|
||||
It recurses for quite some time in glibc and then crashes with a segfault. I've
|
||||
just gotten the application binary (stripped unfortunately) and thus could
|
||||
actually get something from the core.
|
||||
|
||||
Customer's analysis:
|
||||
we have seen this issue before. What's going wrong is that we are calling
|
||||
vfprintf to perform a message trace including the body and the functions in
|
||||
glibc are recursing approximately 373909 frames and then it crashed.
|
||||
|
||||
|
||||
<snip>
|
||||
#373902 0x008602fa in *__GI___overflow (f=0xf7fe8688, ch=0) at genops.c:240
|
||||
#373903 0x0083afe6 in _IO_helper_overflow (s=0xf7fe8688, c=-1)
|
||||
at vfprintf.c:2058
|
||||
#373904 0x0086096f in _IO_default_xsputn (f=0xf7fe8688, data=0x32046928,
|
||||
n=10285) at genops.c:478
|
||||
#373905 0x0083e88e in _IO_vfprintf (s=0xf7fe8688,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", ap=0xf7feae90 "ïJ©\236À¦\004\204:Z\\Æ\\ò%$Ü\223K")
|
||||
at vfprintf.c:1553
|
||||
#373906 0x0083b0ac in buffered_vfprintf (s=0x929460,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", args=) at vfprintf.c:2144
|
||||
#373907 0x0083b2eb in _IO_vfprintf (s=0x929460,
|
||||
format=0x8321890 "%s %s from %s: connID=%lld prodID=%lld msgID='%s' %s
|
||||
mode=%s %s='%s'%s%s", ap=0xf7feae58 "Яþ÷lê2\bP°þ÷;\216K") at vfprintf.c:1264
|
||||
#373908 0x0811ba34 in _authenticate ()
|
||||
#373909 0x0811bc4c in _authenticate ()
|
||||
#373910 0x080f7f3c in _authenticate ()
|
||||
#373911 0x080e8e6a in _authenticate ()
|
||||
#373912 0x080e6d88 in _authenticate ()
|
||||
#373913 0x080e6ed0 in _authenticate ()
|
||||
#373914 0x0807d4fd in ?? ()
|
||||
#373915 0x2846afc8 in ?? ()
|
||||
#373916 0x0830e880 in _IO_stdin_used ()
|
||||
#373917 0x00000432 in ?? ()
|
||||
#373918 0x0830e86d in _IO_stdin_used ()
|
||||
#373919 0x0830e86d in _IO_stdin_used ()
|
||||
#373920 0x00000000 in ?? ()
|
||||
</snip>
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.3.4-2.39
|
||||
|
||||
Additional info:
|
||||
|
||||
I have the core and binary set up on a lab host which has the correct version of
|
||||
glibc installed. Feel free to work on that host:
|
||||
|
||||
dhcp139.gsslab.rdu.redhat.com (root:redhat)
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=455360
|
||||
extra-summary: /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
||||
extra-task: /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
54
tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/runtest.sh
Executable file
54
tests/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive/runtest.sh
Executable file
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz455360-RHEL4-vfprintf-call-goes-into-recursive
|
||||
# Description: Test for bz455360 ([RHEL4] vfprintf() call goes into recursive)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
rpm -Uvh http://nest.test.redhat.com/mnt/qa/scratch/pmuller/rhtslib/rhtslib.rpm
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup Setup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "gcc -O0 testcase.c -o tc0"
|
||||
rlRun "gcc -O2 testcase.c -o tc2"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest Testing
|
||||
rlRun "./tc0"
|
||||
rlAssertNotEquals "Checking for the bug 455360 itself" $? 139
|
||||
rlAssertExists "abcd"
|
||||
rlRun "rm -f abcd"
|
||||
rlRun "./tc2"
|
||||
rlAssertNotEquals "Checking for the bug 455360 itself" $? 139
|
||||
rlAssertExists "abcd"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup Cleanup
|
||||
rlRun "rm -f tc0 tc2 abcd"
|
||||
rlPhaseEnd
|
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
char str[8192+2048];
|
||||
memset (str, 'A', sizeof (str) - 1);
|
||||
str[sizeof (str) - 1] = '\0';
|
||||
FILE *f = fopen ("abcd", "w");
|
||||
setvbuf (f, NULL, _IONBF, 0);
|
||||
/* Force error on next overflow. */
|
||||
close (fileno (f));
|
||||
fprintf (f, "%s\n", str);
|
||||
return 0;
|
||||
}
|
66
tests/Regression/bz464146-sp-corruption/Makefile
Normal file
66
tests/Regression/bz464146-sp-corruption/Makefile
Normal file
@ -0,0 +1,66 @@
|
||||
# Makefile - bz464146-sp-corruption - Bugzilla(s) 464146
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /tools/glibc/Regression/bz464146-sp-corruption/Makefile
|
||||
|
||||
# Description: Test for bz464144, a stack pointer corruption problem
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
TOPLEVEL_NAMESPACE=/tools
|
||||
PACKAGE_NAME=glibc
|
||||
RELATIVE_PATH=Regression/bz464146-sp-corruption
|
||||
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE testit.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Test for bz464144, a stack pointer corruption problem" >> $(METADATA)
|
||||
@echo "Bug: 464146" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: quota-devel" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Architectures: x86_64 ia64 s390x" >> $(METADATA)
|
||||
@echo "Releases: -RHEL3 -RHEL4" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
10
tests/Regression/bz464146-sp-corruption/PURPOSE
Normal file
10
tests/Regression/bz464146-sp-corruption/PURPOSE
Normal file
@ -0,0 +1,10 @@
|
||||
Test Name: bz464146-sp-corruption - Bugzilla(s) 464146
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz464146-sp-corruption
|
||||
|
||||
Short Description: Test for bz464144, a stack pointer corruption problem
|
||||
|
||||
|
||||
Long Description:
|
||||
|
||||
In real life, the problem is only likely to occur with very large applications with hundreds of threads. The result of the bug is that a stack might suddenly jump to an area of virtual memory 4GB away from where it should be.
|
26
tests/Regression/bz464146-sp-corruption/main.fmf
Normal file
26
tests/Regression/bz464146-sp-corruption/main.fmf
Normal file
@ -0,0 +1,26 @@
|
||||
summary: Test for bz464144, a stack pointer corruption problem
|
||||
description: |
|
||||
Test Name: bz464146-sp-corruption - Bugzilla(s) 464146
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz464146-sp-corruption
|
||||
|
||||
Short Description: Test for bz464144, a stack pointer corruption problem
|
||||
|
||||
|
||||
Long Description:
|
||||
|
||||
In real life, the problem is only likely to occur with very large applications with hundreds of threads. The result of the bug is that a stack might suddenly jump to an area of virtual memory 4GB away from where it should be.
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
- quota-devel
|
||||
- gcc
|
||||
duration: 15m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=464146
|
||||
extra-summary: /tools/glibc/Regression/bz464146-sp-corruption
|
||||
extra-task: /tools/glibc/Regression/bz464146-sp-corruption
|
67
tests/Regression/bz464146-sp-corruption/runtest.sh
Executable file
67
tests/Regression/bz464146-sp-corruption/runtest.sh
Executable file
@ -0,0 +1,67 @@
|
||||
# runtest.sh - bz464146-sp-corruption - Bugzilla(s) 464146
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /tools/glibc/Regression/bz464146-sp-corruption/runtest.sh
|
||||
|
||||
# Description: Test for bz464144, a stack pointer corruption problem
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
PACKAGE=glibc
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
rlStartJournal
|
||||
|
||||
######################
|
||||
# Prepare environment
|
||||
######################
|
||||
rlPhaseStartSetup Preparation
|
||||
rlAssertRpm ${PACKAGE}
|
||||
ARCH=`uname -m`
|
||||
if [ "$ARCH" == "ia64" -o "$ARCH" == "aarch64" -o "$ARCH" == "ppc64le" ]
|
||||
then
|
||||
FLAGS=""
|
||||
else
|
||||
FLAGS="-m64"
|
||||
fi
|
||||
rlRun "gcc $FLAGS testit.c -o testit -lpthread" 0 "Compiling the testcase"
|
||||
|
||||
rlPhaseEnd
|
||||
|
||||
######################
|
||||
# Begin Test-Case
|
||||
######################
|
||||
rlPhaseStartTest Test
|
||||
output=`mktemp`
|
||||
./testit > $output
|
||||
RC=$?
|
||||
|
||||
rlAssert0 "Testing for success of the testcases" $RC
|
||||
rlAssertNotEquals "Testing for segfault (bug 464146)" $RC 139
|
||||
rlAssertEquals "Testing for correct output - output should contain 1 line" `cat $output | wc -l` 1
|
||||
cat $output > /tmp/mineminemine
|
||||
rlAssertGrep "received \"Hello World\!\"" /tmp/mineminemine
|
||||
rlPhaseEnd
|
||||
|
||||
######################
|
||||
# Clean after the test
|
||||
######################
|
||||
rlPhaseStartCleanup Clean-Up
|
||||
rlRun "rm -f $output testit"
|
||||
rlCreateLogFromJournal > ${OUTPUTFILE}
|
||||
rlCompareJournalWithRCW
|
||||
rlPhaseEnd
|
||||
|
||||
|
172
tests/Regression/bz464146-sp-corruption/testit.c
Normal file
172
tests/Regression/bz464146-sp-corruption/testit.c
Normal file
@ -0,0 +1,172 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/mman.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
/*
|
||||
In an attempt to situate a stack frame over a 4GB boundary, we
|
||||
first create a memory region which spans that boundary. The
|
||||
boundary which we are trying to span is arbitrarily chosen,
|
||||
just make sure does not intersect with a region already in use.
|
||||
*/
|
||||
|
||||
#define TARGET_BOUNDARY 0x3f600000000
|
||||
#define MEM_REGION_SIZE 0x200000
|
||||
#define MEM_REGION_START (TARGET_BOUNDARY - (MEM_REGION_SIZE/2))
|
||||
#define KLUDGE_SPACE (-0x6e68)
|
||||
|
||||
int proto_tcp;
|
||||
int port;
|
||||
|
||||
void *receiver(void *);
|
||||
void *sender(void *);
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
pthread_t server;
|
||||
pthread_t client;
|
||||
struct protoent *pe;
|
||||
void *stack_region;
|
||||
int ret;
|
||||
|
||||
void *stack_addr=(void *)(TARGET_BOUNDARY+KLUDGE_SPACE);
|
||||
size_t stack_size = 2 * PTHREAD_STACK_MIN;
|
||||
pthread_attr_t attr;
|
||||
|
||||
|
||||
/* set TCP port and protocol number */
|
||||
if (argc != 2 ) port=1027;
|
||||
else port = atoi(argv[1]);
|
||||
|
||||
pe = getprotobyname("tcp");
|
||||
proto_tcp=pe->p_proto;
|
||||
|
||||
|
||||
if (pthread_attr_init(&attr) < 0) {
|
||||
perror("pthread_attr_init\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* creating the memory region */
|
||||
stack_region=mmap((void *)MEM_REGION_START,
|
||||
MEM_REGION_SIZE, PROT_READ|PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANON, (-1), 0);
|
||||
if (stack_region == MAP_FAILED) {
|
||||
perror("mmap\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pthread_create(&server, NULL , sender, NULL) != 0){
|
||||
perror("pthread_create 1");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if ((ret=pthread_attr_setstack(&attr,stack_addr,stack_size))!=0)
|
||||
{
|
||||
perror("pthread_attr_setstack");
|
||||
printf("ret = %d\n",ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((ret=pthread_create(&client, &attr, receiver, NULL)) != 0){
|
||||
printf("pthread_create2 failed with %d\n",ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_join(server, NULL);
|
||||
pthread_join(client, NULL);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void *sender(void *context){
|
||||
int ret;
|
||||
int sfd; /* socket descriptor */
|
||||
int cfd; /* connection descriptor */
|
||||
struct sockaddr_in addr;
|
||||
char *p;
|
||||
char buffer[] = "Hello World!";
|
||||
|
||||
if ((sfd = socket(PF_INET, SOCK_STREAM, proto_tcp)) < 0 ) {
|
||||
perror("sender socket\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
addr.sin_family=AF_INET;
|
||||
addr.sin_port=htons(port);
|
||||
p=(gethostbyname("localhost")->h_addr_list[0]);
|
||||
memcpy(&(addr.sin_addr.s_addr),p,sizeof(p));
|
||||
|
||||
if (bind(sfd, (struct sockaddr*)&addr, sizeof addr) < 0) {
|
||||
perror("sender bind\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (listen(sfd, 1) == -1){
|
||||
perror("sender listen\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
cfd = accept(sfd, NULL, NULL);
|
||||
if (cfd < 0 )
|
||||
{
|
||||
perror("accept\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(send(cfd, (void*) buffer, sizeof(buffer), MSG_NOSIGNAL) == -1){
|
||||
perror("send");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
shutdown(cfd, SHUT_RDWR);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void *receiver(void *context){
|
||||
|
||||
char buf[100];
|
||||
int sfd;
|
||||
struct sockaddr_in addr;
|
||||
char *p;
|
||||
ssize_t ret;
|
||||
|
||||
addr.sin_family=AF_INET;
|
||||
addr.sin_port=htons(port);
|
||||
p=(gethostbyname("localhost")->h_addr_list[0]);
|
||||
memcpy(&(addr.sin_addr.s_addr),p,sizeof(p));
|
||||
|
||||
sleep(1);
|
||||
|
||||
if ((sfd = socket(PF_INET, SOCK_STREAM, proto_tcp)) < 0 ) {
|
||||
perror("receiver socket\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(connect(sfd, (struct sockaddr*)&addr, sizeof addr) == -1){
|
||||
perror("connect\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if ((ret = recv(sfd, (void*)buf, sizeof(buf), MSG_WAITALL))<0) {
|
||||
perror("recv");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
buf[ret]='\0';
|
||||
printf("received \"%s\"\n",buf);
|
||||
|
||||
shutdown(sfd, SHUT_RDWR);
|
||||
|
||||
return(NULL);
|
||||
}
|
64
tests/Regression/bz471298-pthread_cond/Makefile
Normal file
64
tests/Regression/bz471298-pthread_cond/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# Makefile - bz471298-pthread_cond - Bugzilla(s) 471298
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /tools/glibc/Regression/bz471298-pthread_cond/Makefile
|
||||
|
||||
# Description: Contains one simple testcase, hanging when exhibiting the bug
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
TOPLEVEL_NAMESPACE=/tools
|
||||
PACKAGE_NAME=glibc
|
||||
RELATIVE_PATH=Regression/bz471298-pthread_cond
|
||||
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE pthread_cond_test.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Contains one simple testcase, hanging when exhibiting the bug" >> $(METADATA)
|
||||
@echo "Bug: 471298" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Releases: -RHEL2.1 -RHEL3 -RHEL4" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
10
tests/Regression/bz471298-pthread_cond/PURPOSE
Normal file
10
tests/Regression/bz471298-pthread_cond/PURPOSE
Normal file
@ -0,0 +1,10 @@
|
||||
Test Name: bz471298-pthread_cond - Bugzilla(s) 471298
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz471298-pthread_cond
|
||||
|
||||
Short Description: Contains one simple testcase, hanging when exhibiting the bug
|
||||
|
||||
|
||||
Long Description:
|
||||
|
||||
Contains one simple testcase, hanging when exhibiting the bug
|
25
tests/Regression/bz471298-pthread_cond/main.fmf
Normal file
25
tests/Regression/bz471298-pthread_cond/main.fmf
Normal file
@ -0,0 +1,25 @@
|
||||
summary: Contains one simple testcase, hanging when exhibiting the bug
|
||||
description: |
|
||||
Test Name: bz471298-pthread_cond - Bugzilla(s) 471298
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Location: /tools/glibc/Regression/bz471298-pthread_cond
|
||||
|
||||
Short Description: Contains one simple testcase, hanging when exhibiting the bug
|
||||
|
||||
|
||||
Long Description:
|
||||
|
||||
Contains one simple testcase, hanging when exhibiting the bug
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
- gcc
|
||||
duration: 15m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=471298
|
||||
extra-summary: /tools/glibc/Regression/bz471298-pthread_cond
|
||||
extra-task: /tools/glibc/Regression/bz471298-pthread_cond
|
240
tests/Regression/bz471298-pthread_cond/pthread_cond_test.c
Normal file
240
tests/Regression/bz471298-pthread_cond/pthread_cond_test.c
Normal file
@ -0,0 +1,240 @@
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define PTHREAD_MUTEX_DEFAULT 0
|
||||
#define PTS_FAIL 1
|
||||
|
||||
/* The shared data */
|
||||
typedef struct
|
||||
{
|
||||
int count; /* number of children currently waiting */
|
||||
pthread_cond_t cnd;
|
||||
pthread_mutex_t mtx;
|
||||
int predicate; /* Boolean associated to the condvar */
|
||||
clockid_t cid; /* clock used in the condvar */
|
||||
char fork; /* the children are processes */
|
||||
} testdata_t;
|
||||
|
||||
testdata_t * td;
|
||||
|
||||
int child(int arg);
|
||||
|
||||
int main (int argc, char * argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
pthread_mutexattr_t ma;
|
||||
pthread_condattr_t ca;
|
||||
|
||||
pid_t pid, p_child;
|
||||
int ch;
|
||||
int status;
|
||||
|
||||
pthread_t t_timer;
|
||||
|
||||
char filename[] = "/tmp/cond_wait_stress-XXXXXX";
|
||||
size_t sz, ps;
|
||||
void * mmaped;
|
||||
int fd;
|
||||
char * tmp;
|
||||
|
||||
fd = mkstemp(filename);
|
||||
if (fd < 0) {
|
||||
perror("mkstemp");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
unlink(filename);
|
||||
|
||||
ps = (size_t)sysconf(_SC_PAGESIZE);
|
||||
sz = ((sizeof(testdata_t) / ps) + 1) * ps; /* # pages needed to store the testdata */
|
||||
tmp = calloc( 1 , sz);
|
||||
|
||||
if (tmp == NULL) {
|
||||
perror("calloc");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (write (fd, tmp, sz) != (ssize_t) sz) {
|
||||
perror("write");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mmaped = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (mmaped == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
td = (testdata_t *) mmaped;
|
||||
memset(td, 0, sizeof(testdata_t));
|
||||
free(tmp);
|
||||
|
||||
/* mutexattr & condattr init */
|
||||
ret = pthread_mutexattr_init(&ma);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutexattr_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_condattr_init(&ca);
|
||||
if (ret != 0) {
|
||||
perror("pthread_condattr_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
ret = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_DEFAULT);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutexattr_settype");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Set "PTHREAD_PROCESS_SHARED" */
|
||||
ret = pthread_mutexattr_setpshared(&ma, PTHREAD_PROCESS_SHARED);
|
||||
if(ret != 0) {
|
||||
perror("pthread_mutexattr_setpshared");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_condattr_setpshared(&ca, PTHREAD_PROCESS_SHARED);
|
||||
if(ret != 0) {
|
||||
perror("pthread_condattr_setpshared");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
/* Set "CLOCK_MONOTONIC" */
|
||||
ret = pthread_condattr_setclock(&ca, CLOCK_MONOTONIC);
|
||||
if(ret != 0) {
|
||||
perror("pthread_condattr_setclock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_condattr_getclock(&ca, &td->cid);
|
||||
if(ret != 0) {
|
||||
perror("pthread_condattr_getclock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
ret = pthread_cond_init(&td->cnd, &ca);
|
||||
if(ret != 0) {
|
||||
perror("pthread_cond_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_mutex_init(&td->mtx, &ma);
|
||||
if(ret != 0) {
|
||||
perror("pthread_mutex_init");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = pthread_condattr_destroy(&ca);
|
||||
if (ret != 0) {
|
||||
perror("pthread_condattr_destroy");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_mutexattr_destroy(&ma);
|
||||
if (ret != 0) {
|
||||
perror("pthread_condattr_destroy");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
td->fork = 1;
|
||||
p_child = fork();
|
||||
if (p_child < 0) {
|
||||
perror("fork");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (p_child == 0) {
|
||||
/* child process */
|
||||
child(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/* Parent process */
|
||||
|
||||
ret = pthread_mutex_lock(&td->mtx);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutex_lock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ch = td->count;
|
||||
|
||||
ret = pthread_mutex_unlock(&td->mtx);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutex_unlock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
|
||||
ret = pthread_mutex_lock(&td->mtx);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutex_lock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
td->predicate=1;
|
||||
ret = pthread_cond_signal(&td->cnd);
|
||||
printf("parent: pthread_cond_signal\n");
|
||||
if (ret != 0) {
|
||||
perror("pthread_cond_signal");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = pthread_mutex_unlock(&td->mtx);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutex_unlock");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
pid = waitpid(p_child, &status, 0);
|
||||
if(pid != p_child) {
|
||||
perror("waitpid");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ret = pthread_cond_destroy(&td->cnd);
|
||||
if (ret != 0) {
|
||||
perror("pthread_cond_destroy");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ret = pthread_mutex_destroy(&td->mtx);
|
||||
if (ret != 0) {
|
||||
perror("pthread_mutex_destroy");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int child(int arg)
|
||||
{
|
||||
int ret=0;
|
||||
struct timespec ts;
|
||||
|
||||
/* lock the mutex */
|
||||
ret = pthread_mutex_lock(&td->mtx);
|
||||
|
||||
printf("child: pthread_cond_wait\n");
|
||||
|
||||
do {
|
||||
/* Wait while the predicate is false */
|
||||
ret = pthread_cond_wait(&td->cnd, &td->mtx);
|
||||
} while ((ret == 0) && (td->predicate==0));
|
||||
|
||||
|
||||
ret = pthread_cond_signal(&td->cnd);
|
||||
ret = pthread_mutex_unlock(&td->mtx);
|
||||
|
||||
return 0;
|
||||
}
|
46
tests/Regression/bz471298-pthread_cond/runtest.sh
Executable file
46
tests/Regression/bz471298-pthread_cond/runtest.sh
Executable file
@ -0,0 +1,46 @@
|
||||
# runtest.sh - bz471298-pthread_cond - Bugzilla(s) 471298
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
# Location: /tools/glibc/Regression/bz471298-pthread_cond/runtest.sh
|
||||
|
||||
# Description: Contains one simple testcase, hanging when exhibiting the bug
|
||||
|
||||
# Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
||||
# is made available to anyone wishing to use, modify, copy, or
|
||||
# redistribute it subject to the terms and conditions of the GNU General
|
||||
# Public License v.2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
PACKAGE=glibc
|
||||
|
||||
# Include rhts environment
|
||||
rpm -Uvh http://nest.test.redhat.com/mnt/qa/scratch/pmuller/rhtslib/rhtslib.rpm
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
rlStartJournal
|
||||
|
||||
rlPhaseStartSetup Preparation
|
||||
rlAssertRpm ${PACKAGE}
|
||||
rlRun 'gcc -lpthread -lrt pthread_cond_test.c -o pthread_test' 0 "Comnpiling the testcase"
|
||||
rlPhaseEnd
|
||||
|
||||
######################
|
||||
# Begin Test-Case
|
||||
######################
|
||||
rlPhaseStartTest Test
|
||||
rlWatchdog './pthread_test' 10
|
||||
rlAssert0 "Checking if the command had to be killed (bug 471298)" $?
|
||||
rlPhaseEnd
|
||||
|
||||
######################
|
||||
# Clean after the test
|
||||
######################
|
||||
rlPhaseStartCleanup Clean-Up
|
||||
rlRun "rm -f pthread_test" 0 "Cleaning up the executable"
|
||||
rlPhaseEnd
|
@ -0,0 +1,65 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
||||
# Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE optinit.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 488748" >> $(METADATA)
|
||||
@echo "Release: -RHEL4" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,9 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
||||
Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: [RHEL5] inet6_opt_init() sets incorrect header extension length
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=488748
|
||||
|
||||
Description:
|
||||
|
||||
Escalated to Bugzilla from IssueTracker
|
@ -0,0 +1,20 @@
|
||||
summary: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)
|
||||
description: |
|
||||
Bug summary: [RHEL5] inet6_opt_init() sets incorrect header extension length
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=488748
|
||||
|
||||
Description:
|
||||
|
||||
Escalated to Bugzilla from IssueTracker
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=488748
|
||||
extra-summary: /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
||||
extra-task: /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LEN 16
|
||||
#define OPT_LEN(len) ((len - 8) >> 3)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char extbuf[LEN], cbuf[LEN];
|
||||
int extlen;
|
||||
uint8_t *len;
|
||||
|
||||
memset(extbuf, 0, sizeof(extbuf));
|
||||
memset(cbuf, 0, sizeof(cbuf));
|
||||
len = (uint8_t *)(extbuf + 1);
|
||||
|
||||
printf("== calculate the needed buffer size if extlen is: %d ==\n",LEN);
|
||||
extlen = inet6_opt_init(extbuf, LEN);
|
||||
if (extlen != 2) {
|
||||
printf("ERROR: return invalid length %d, expect:2 \n", extlen);
|
||||
printf("<=====NG=====>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (*len != OPT_LEN(LEN)) {
|
||||
printf("ERROR: the length field of extension header is invalid, length %d, expect:%d \n",
|
||||
*len, OPT_LEN(LEN));
|
||||
printf("<=====NG=====>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("OK\n");
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/lib/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz488748-inet6-opt-init-sets-incorrect-header-len
|
||||
# Description: Test for bz488748 ([RHEL5] inet6_opt_init() sets incorrect header)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun 'gcc optinit.c -o optinit' 0 "Compiling the testcase"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "./optinit" 0 "Running the testcase"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f optinit"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
@ -0,0 +1,66 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
||||
# Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE priv-mutex.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Requires: strace" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 495955" >> $(METADATA)
|
||||
@echo "Releases: -RHEL3 -RHEL4" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,46 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
||||
Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: [RHEL5] glibc doesn't use private futex system calls for pthread_mutex calls
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=495955
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=339722)
|
||||
private mutex test case
|
||||
|
||||
As I understand it, RHEL 5.3 is supposed to have pulled in the change to use PTHREAD_PROCESS_PRIVATE by default with the various pthread_mutex calls. While testing my recent requeue_pi code, I was seeing some unexpected behaviour on RHEL5.3 that didn't occur on FC10. Specifically, regardless of what I set the mutexattr pshared attribute to, glibc would make the shared versions of the futex calls. I've written the attached testcase to illustrate. It creates a PI mutex, and will set the pshared attribute to whatever you specify in the options, or use the OS default if you use no options. Using strace -f you can see which futex syscalls glibc used.
|
||||
|
||||
Compile with:
|
||||
# gcc -lrt -lpthread priv-mutex.c -o priv-mutex
|
||||
|
||||
Note: the ETIMEDOUT is intentional in the output below.
|
||||
|
||||
On Fedora Core 10 with glibc 2.9:
|
||||
|
||||
Default is private:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI
|
||||
[pid 13433] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying private works:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI
|
||||
[pid 13437] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying shared works:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI
|
||||
[pid 13441] futex(0x6015e0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
|
||||
On RHEL5.3:
|
||||
|
||||
Default uses shared (I expected private here):
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI
|
||||
[pid 9051] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Setting PTHREAD_PROCESS_PRIVATE has no effect:
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI
|
||||
[pid 9055] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying shared works as expected:
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI
|
||||
[pid 9059] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
@ -0,0 +1,58 @@
|
||||
summary: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)
|
||||
description: |
|
||||
Bug summary: [RHEL5] glibc doesn't use private futex system calls for pthread_mutex calls
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=495955
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=339722)
|
||||
private mutex test case
|
||||
|
||||
As I understand it, RHEL 5.3 is supposed to have pulled in the change to use PTHREAD_PROCESS_PRIVATE by default with the various pthread_mutex calls. While testing my recent requeue_pi code, I was seeing some unexpected behaviour on RHEL5.3 that didn't occur on FC10. Specifically, regardless of what I set the mutexattr pshared attribute to, glibc would make the shared versions of the futex calls. I've written the attached testcase to illustrate. It creates a PI mutex, and will set the pshared attribute to whatever you specify in the options, or use the OS default if you use no options. Using strace -f you can see which futex syscalls glibc used.
|
||||
|
||||
Compile with:
|
||||
# gcc -lrt -lpthread priv-mutex.c -o priv-mutex
|
||||
|
||||
Note: the ETIMEDOUT is intentional in the output below.
|
||||
|
||||
On Fedora Core 10 with glibc 2.9:
|
||||
|
||||
Default is private:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI
|
||||
[pid 13433] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying private works:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI
|
||||
[pid 13437] futex(0x6015e0, FUTEX_LOCK_PI_PRIVATE, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying shared works:
|
||||
[root@elm3b160 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI
|
||||
[pid 13441] futex(0x6015e0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
|
||||
On RHEL5.3:
|
||||
|
||||
Default uses shared (I expected private here):
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex | grep FUTEX_LOCK_PI
|
||||
[pid 9051] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Setting PTHREAD_PROCESS_PRIVATE has no effect:
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -p | grep FUTEX_LOCK_PI
|
||||
[pid 9055] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
|
||||
Specifying shared works as expected:
|
||||
[root@elm3c31 dvhart]# strace -f 2>&1 ./priv-mutex -s | grep FUTEX_LOCK_PI
|
||||
[pid 9059] futex(0x6015c0, FUTEX_LOCK_PI, 1) = -1 ETIMEDOUT (Connection timed out)
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
- strace
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=495955
|
||||
extra-summary: /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
||||
extra-task: /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
@ -0,0 +1,181 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright © International Business Machines Corp., 2009
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
* the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* NAME
|
||||
* priv-mutex.c
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test the shared and private settings of pthread mutexes.
|
||||
*
|
||||
* USAGE:
|
||||
* priv-mutex [-p][-s]
|
||||
*
|
||||
* AUTHOR
|
||||
* Darren Hart <dvhltc@us.ibm.com>
|
||||
*
|
||||
* HISTORY
|
||||
* 2009-Apr-9: Initial version by Darren Hart <dvhltc@us.ibm.com>
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define MUTEX_PSHARED_FLAG 128
|
||||
#define MUTEX_PI_FLAG 32
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
pthread_barrier_t lock_barrier;
|
||||
pthread_barrier_t unlock_barrier;
|
||||
|
||||
void usage(char *arg0)
|
||||
{
|
||||
printf("usage: %s [-p][-s]\n");
|
||||
printf("-p: use private mutexes\n");
|
||||
printf("-s: use shared mutexes\n");
|
||||
printf("no args: use system default\n");
|
||||
}
|
||||
|
||||
void *lock_thread(void *arg)
|
||||
{
|
||||
int ret;
|
||||
if (pthread_mutex_lock(&mutex))
|
||||
{
|
||||
perror("lock_thread failed to acquire the lock");
|
||||
return NULL;
|
||||
}
|
||||
/* Let the main thread know we took the lock. */
|
||||
ret = pthread_barrier_wait(&lock_barrier);
|
||||
if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
|
||||
perror("pthread_barrier_wait failed");
|
||||
return NULL;
|
||||
}
|
||||
/* Wait for the main thread to timeout trying to get the lock. */
|
||||
ret = pthread_barrier_wait(&unlock_barrier);
|
||||
if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
|
||||
perror("pthread_barrier_wait failed");
|
||||
return NULL;
|
||||
}
|
||||
if (pthread_mutex_unlock(&mutex))
|
||||
{
|
||||
perror("main failed to release the lock");
|
||||
return NULL;
|
||||
}
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int opt, pshared, child_ret, set_pshared = 0, ret = 0;
|
||||
pthread_mutexattr_t attr;
|
||||
struct timespec timeout;
|
||||
pthread_t child;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ps")) != -1) {
|
||||
switch (opt) {
|
||||
case 'p':
|
||||
pshared = PTHREAD_PROCESS_PRIVATE;
|
||||
set_pshared = 1;
|
||||
break;
|
||||
case 's':
|
||||
pshared = PTHREAD_PROCESS_SHARED;
|
||||
set_pshared = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup the mutex. */
|
||||
if (pthread_mutexattr_init(&attr)) {
|
||||
perror("pthread_mutexattr_init failed");
|
||||
return -1;
|
||||
}
|
||||
if (pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) {
|
||||
perror("pthread_mutexattr_setprotocol failed");
|
||||
return -1;
|
||||
}
|
||||
if (set_pshared) {
|
||||
if (pthread_mutexattr_setpshared(&attr, pshared)) {
|
||||
perror("pthread_mutexattr_setpshared failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (pthread_mutex_init(&mutex, &attr)) {
|
||||
perror("pthread_mutex_init failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Using %s mutexes\n", mutex.__data.__kind & MUTEX_PSHARED_FLAG ?
|
||||
"PTHREAD_PROCESS_SHARED" : "PTHREAD_PROCESS_PRIVATE");
|
||||
|
||||
|
||||
/* Setup the barriers. */
|
||||
if (pthread_barrier_init(&lock_barrier, NULL, 2)) {
|
||||
perror("failed to create lock_barrier");
|
||||
return -1;
|
||||
}
|
||||
if (pthread_barrier_init(&unlock_barrier, NULL, 2)) {
|
||||
perror("failed to create lock_barrier");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Spawn a thread to grab the lock and then try to grab it here,
|
||||
* forcing glibc to make the appropriate futex system-call.
|
||||
*/
|
||||
if (pthread_create(&child, NULL, lock_thread, NULL)) {
|
||||
perror("failed to create child thread");
|
||||
return -1;
|
||||
}
|
||||
ret = pthread_barrier_wait(&lock_barrier);
|
||||
if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
|
||||
perror("pthread_barrier_wait failed");
|
||||
return -1;
|
||||
}
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_nsec = 100000;
|
||||
ret = pthread_mutex_timedlock(&mutex, &timeout);
|
||||
if (ret && ret != ETIMEDOUT) {
|
||||
perror("main failed to acquire the lock");
|
||||
return -1;
|
||||
}
|
||||
ret = pthread_barrier_wait(&unlock_barrier);
|
||||
if (ret && ret != PTHREAD_BARRIER_SERIAL_THREAD) {
|
||||
perror("pthread_barrier_wait failed");
|
||||
return -1;
|
||||
}
|
||||
pthread_join(child, NULL);
|
||||
|
||||
|
||||
/* Cleanup */
|
||||
if (pthread_mutex_destroy(&mutex)) {
|
||||
perror("pthread_mutex_destroy failed");
|
||||
ret = -1;
|
||||
}
|
||||
if (pthread_mutexattr_destroy(&attr)) {
|
||||
perror("pthread_mutexattr_destroy failed");
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz495955-RHEL5-glibc-doesn-t-use-private-futex-system
|
||||
# Description: Test for bz495955 ([RHEL5] glibc doesn't use private futex system)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "gcc -lrt -lpthread priv-mutex.c -o priv-mutex" 0 "Compiling the testcase"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Checking for the default: should be using PRIVATE_PI"
|
||||
strace -f ./priv-mutex 2>&1 | grep FUTEX_LOCK_PI_PRIVATE
|
||||
rlAssert0 "Checking that FUTEX_LOCK_PI_PRIVATE was in the output" $?
|
||||
|
||||
rlLog "Checking for using PRIVATE_PI when asked for it"
|
||||
strace -f ./priv-mutex -p 2>&1 | grep FUTEX_LOCK_PI_PRIVATE
|
||||
rlAssert0 "Checking that FUTEX_LOCK_PI_PRIVATE was in the output" $?
|
||||
|
||||
rlLog "Checking for using SHARED_PI when asked for it"
|
||||
strace -f ./priv-mutex -s 2>&1 | grep "FUTEX_LOCK_PI,"
|
||||
rlAssert0 "Checking that just FUTEX_LOCK_PI was in the output" $?
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f priv-mutex"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
||||
# Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE function-nodename-servname-null.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 501595" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,48 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
||||
Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: [RHEL4] getnameinfo() should return EAI_NONAME when both nodename and servname are set to null and flag is set to NI_NAMEREQD
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=501595
|
||||
|
||||
Description:
|
||||
|
||||
+++ This bug was initially created as a clone of Bug #489419 +++
|
||||
|
||||
Description of Problem:
|
||||
glibc getnameinfo() returns 0 when both nodename and servname are set to null and flag is set to 'NI_NAMEREQD'.
|
||||
|
||||
The synopsis of function getnameinfo is:
|
||||
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_t nodelen, char *service, socklen_t servicelen, int flags);
|
||||
|
||||
RFC3493 tells that getnameinfo() should returns 'EAI_NONAME' when both nodename and servname are null. So when use getnameinfo() with both nodename and servname are null and the NI_NAMEREQD flag is set, glibc should return 'EAI_NONAME' rather than 0.
|
||||
|
||||
|
||||
Version-Release number of selected component:
|
||||
glibc-2.3.4-2.43
|
||||
|
||||
|
||||
How reproducible:
|
||||
every time
|
||||
|
||||
|
||||
Step to Reproduce:
|
||||
1. gcc function-nodename-servname-null.c
|
||||
2. ./a.out
|
||||
|
||||
|
||||
Actual Results:
|
||||
# ./a.out
|
||||
==Both nodename and servname are null if the NI_NAMEREQD flag is set==
|
||||
ERROR:return 0, expect error EAI_NONAME
|
||||
<=== NG ===>
|
||||
|
||||
|
||||
Expected Results:
|
||||
# ./a.out
|
||||
==Both nodename and servname are null if the NI_NAMEREQD flag is set==
|
||||
<=== OK ===>
|
||||
|
||||
|
||||
Additional Info:
|
||||
Upstream patch:
|
||||
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/inet/getnameinfo.c.diff?r1=1.36&r2=1.37&cvsroot=glibc
|
@ -0,0 +1,33 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct sockaddr_in6 addr6;
|
||||
socklen_t size = sizeof(addr6);
|
||||
int ret;
|
||||
|
||||
memset(&addr6, 0, size);
|
||||
addr6.sin6_family = AF_INET6;
|
||||
addr6.sin6_port = 0;
|
||||
addr6.sin6_addr = in6addr_loopback;
|
||||
|
||||
printf("==Both nodename and servname are null if the NI_NAMEREQD flag is set==\n");
|
||||
ret = getnameinfo((struct sockaddr *) &addr6, size, NULL, 0, NULL, 0, NI_NAMEREQD);
|
||||
if(ret != EAI_NONAME)
|
||||
{
|
||||
printf("ERROR:return %d, expect error EAI_NONAME\n", ret);
|
||||
printf("<=== NG ===>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("<=== OK ===>\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
summary: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)
|
||||
description: |
|
||||
Bug summary: [RHEL4] getnameinfo() should return EAI_NONAME when both nodename and servname are set to null and flag is set to NI_NAMEREQD
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=501595
|
||||
|
||||
Description:
|
||||
|
||||
+++ This bug was initially created as a clone of Bug #489419 +++
|
||||
|
||||
Description of Problem:
|
||||
glibc getnameinfo() returns 0 when both nodename and servname are set to null and flag is set to 'NI_NAMEREQD'.
|
||||
|
||||
The synopsis of function getnameinfo is:
|
||||
int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_t nodelen, char *service, socklen_t servicelen, int flags);
|
||||
|
||||
RFC3493 tells that getnameinfo() should returns 'EAI_NONAME' when both nodename and servname are null. So when use getnameinfo() with both nodename and servname are null and the NI_NAMEREQD flag is set, glibc should return 'EAI_NONAME' rather than 0.
|
||||
|
||||
|
||||
Version-Release number of selected component:
|
||||
glibc-2.3.4-2.43
|
||||
|
||||
|
||||
How reproducible:
|
||||
every time
|
||||
|
||||
|
||||
Step to Reproduce:
|
||||
1. gcc function-nodename-servname-null.c
|
||||
2. ./a.out
|
||||
|
||||
|
||||
Actual Results:
|
||||
# ./a.out
|
||||
==Both nodename and servname are null if the NI_NAMEREQD flag is set==
|
||||
ERROR:return 0, expect error EAI_NONAME
|
||||
<=== NG ===>
|
||||
|
||||
|
||||
Expected Results:
|
||||
# ./a.out
|
||||
==Both nodename and servname are null if the NI_NAMEREQD flag is set==
|
||||
<=== OK ===>
|
||||
|
||||
|
||||
Additional Info:
|
||||
Upstream patch:
|
||||
http://sourceware.org/cgi-bin/cvsweb.cgi/libc/inet/getnameinfo.c.diff?r1=1.36&r2=1.37&cvsroot=glibc
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=501595
|
||||
extra-summary: /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
||||
extra-task: /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz501595-RHEL4-getnameinfo-should-return-EAI-NONAME
|
||||
# Description: Test for bz501595 ([RHEL4] getnameinfo() should return EAI_NONAME)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
rlRun "gcc function-nodename-servname-null.c -o repro"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "./repro"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f repro"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
@ -0,0 +1,65 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
||||
# Description: Test for bz503723 (fopen mode 'x' ignored in some cases)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE fopen.c expected.py2 expected.py3
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz503723 (fopen mode 'x' ignored in some cases)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 90m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc perl strace python python3 python38" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 503723" >> $(METADATA)
|
||||
@echo "Releases: -RHEL4" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,38 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
||||
Description: Test for bz503723 (fopen mode 'x' ignored in some cases)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: fopen mode 'x' ignored in some cases
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=503723
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=346240)
|
||||
fopen.c - test for fopen modes
|
||||
|
||||
Description of problem:
|
||||
O_EXCL is not used if mode is "wbex", but O_EXCL is used if mode is "wbxe".
|
||||
|
||||
This bug can cause security vulnerabilities in software relying on this glibc extension.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
2.10.1-2, 2.9.90-3
|
||||
|
||||
How reproducible:
|
||||
always
|
||||
|
||||
Steps to Reproduce:
|
||||
1. compile attached C source file
|
||||
2. run with options ababab wbex, and ababab wbxe
|
||||
3.
|
||||
|
||||
Actual results:
|
||||
'x' may be ignored
|
||||
|
||||
Expected results:
|
||||
'x' not ignored
|
||||
|
||||
Additional info:
|
||||
$ strace -eopen ./a.out ababab wbxe 2>&1 | grep ababab ; rm -f ababab
|
||||
open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0666) = 3
|
||||
$ strace -eopen ./a.out ababab wbex 2>&1 | grep ababab ; rm -f ababab
|
||||
open("ababab", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
|
109
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py2
Executable file
109
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py2
Executable file
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
exists = { 'r' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rm' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rc' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rcm' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'r+' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+x' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+m' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+c' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+cm' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', }
|
||||
|
||||
nexists= { 'r' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rc' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rcm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+x' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+m' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+c' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+cm' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', }
|
||||
|
||||
import sys
|
||||
|
||||
var = sys.argv[1]
|
||||
what = sys.argv[2]
|
||||
|
||||
if var == "ex":
|
||||
print exists[what]
|
||||
elif var == "nex":
|
||||
print nexists[what]
|
109
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py3
Executable file
109
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/expected.py3
Executable file
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
exists = { 'r' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rm' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rc' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'rcm' : 'open("ababab", O_RDONLY) = 3',
|
||||
'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = 3',
|
||||
'r+' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+x' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+m' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+c' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'r+cm' : 'open("ababab", O_RDWR) = 3',
|
||||
'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = 3',
|
||||
'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = -1 EEXIST (File exists)',
|
||||
'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)',
|
||||
'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = -1 EEXIST (File exists)', }
|
||||
|
||||
nexists= { 'r' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rc' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rcx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'rcm' : 'open("ababab", O_RDONLY) = -1 ENOENT (No such file or directory)',
|
||||
'rcmx' : 'open("ababab", O_RDONLY|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+x' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+m' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+mx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+c' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+cx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'r+cm' : 'open("ababab", O_RDWR) = -1 ENOENT (No such file or directory)',
|
||||
'r+cmx' : 'open("ababab", O_RDWR|O_EXCL) = -1 ENOENT (No such file or directory)',
|
||||
'w' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wc' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'wcm' : 'open("ababab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'wcmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+m' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+c' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'w+cm' : 'open("ababab", O_RDWR|O_CREAT|O_TRUNC, 0666) = 3',
|
||||
'w+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0666) = 3',
|
||||
'a' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'ax' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'am' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'amx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'ac' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'acm' : 'open("ababab", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'acmx' : 'open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+x' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+m' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+mx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+c' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3',
|
||||
'a+cm' : 'open("ababab", O_RDWR|O_CREAT|O_APPEND, 0666) = 3',
|
||||
'a+cmx' : 'open("ababab", O_RDWR|O_CREAT|O_EXCL|O_APPEND, 0666) = 3', }
|
||||
|
||||
import sys
|
||||
|
||||
var = sys.argv[1]
|
||||
what = sys.argv[2]
|
||||
|
||||
if var == "ex":
|
||||
print (exists[what])
|
||||
elif var == "nex":
|
||||
print (nexists[what])
|
@ -0,0 +1,21 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE* f;
|
||||
|
||||
if (argc != 3) return 1;
|
||||
|
||||
f = fopen (argv[1], argv[2]);
|
||||
if (f == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if (fclose (f)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
summary: Test for bz503723 (fopen mode 'x' ignored in some cases)
|
||||
description: |
|
||||
Bug summary: fopen mode 'x' ignored in some cases
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=503723
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=346240)
|
||||
fopen.c - test for fopen modes
|
||||
|
||||
Description of problem:
|
||||
O_EXCL is not used if mode is "wbex", but O_EXCL is used if mode is "wbxe".
|
||||
|
||||
This bug can cause security vulnerabilities in software relying on this glibc extension.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
2.10.1-2, 2.9.90-3
|
||||
|
||||
How reproducible:
|
||||
always
|
||||
|
||||
Steps to Reproduce:
|
||||
1. compile attached C source file
|
||||
2. run with options ababab wbex, and ababab wbxe
|
||||
3.
|
||||
|
||||
Actual results:
|
||||
'x' may be ignored
|
||||
|
||||
Expected results:
|
||||
'x' not ignored
|
||||
|
||||
Additional info:
|
||||
$ strace -eopen ./a.out ababab wbxe 2>&1 | grep ababab ; rm -f ababab
|
||||
open("ababab", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0666) = 3
|
||||
$ strace -eopen ./a.out ababab wbex 2>&1 | grep ababab ; rm -f ababab
|
||||
open("ababab", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: shell
|
||||
recommend:
|
||||
- glibc
|
||||
- perl
|
||||
- strace
|
||||
- python
|
||||
- python3
|
||||
- python38
|
||||
duration: 90m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=503723
|
||||
extra-summary: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
||||
extra-task: /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
101
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/runtest.sh
Executable file
101
tests/Regression/bz503723-fopen-mode-x-ignored-in-some-cases/runtest.sh
Executable file
@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz503723-fopen-mode-x-ignored-in-some-cases
|
||||
# Description: Test for bz503723 (fopen mode 'x' ignored in some cases)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
if rlIsRHEL ">=8" || rlIsFedora
|
||||
then
|
||||
rlRun -c "cp expected.py3 expected.py"
|
||||
else
|
||||
rlRun -c "cp expected.py2 expected.py"
|
||||
fi
|
||||
rlAssertExists "expected.py"
|
||||
rlRun "gcc fopen.c -o fopen"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "Testing modes on existing file"
|
||||
rlLog "Trying all variants of modes in open"
|
||||
rlRun "touch ababab" 0 "Creating a test file"
|
||||
for mode in "r" "r+" "w" "w+" "a" "a+"
|
||||
do
|
||||
for f in "" "c"
|
||||
do
|
||||
for s in "" "m"
|
||||
do
|
||||
for t in "" "x"
|
||||
do
|
||||
golden="`./expected.py ex $mode$f$s$t | tr --squeeze ' '`"
|
||||
for variant in "$mode$f$s$t" "$mode$f$t$s" "$mode$s$f$t" "$mode$s$t$f" "$mode$t$f$s" "$mode$t$s$f"
|
||||
do
|
||||
try="`strace -e open,openat ./fopen ababab $variant 2>&1 | grep ababab | tr --squeeze ' ' | perl -pe 's/openat\(AT_FDCWD, /open\(/'`"
|
||||
echo $try
|
||||
rlAssertEquals "Checking mode [$variant] is identical to golden [$mode$f$s$t]" "$golden" "$try"
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "Testing modes on nonexisting file"
|
||||
rlLog "Trying all variants of modes in open"
|
||||
|
||||
for mode in "r" "r+" "w" "w+" "a" "a+"
|
||||
do
|
||||
for f in "" "c"
|
||||
do
|
||||
for s in "" "m"
|
||||
do
|
||||
for t in "" "x"
|
||||
do
|
||||
golden="`./expected.py nex $mode$f$s$t | tr --squeeze ' '`"
|
||||
for variant in "$mode$f$s$t" "$mode$f$t$s" "$mode$s$f$t" "$mode$s$t$f" "$mode$t$f$s" "$mode$t$s$f"
|
||||
do
|
||||
rlRun "rm -f ababab"
|
||||
try="`strace -e open,openat ./fopen ababab $variant 2>&1 | grep ababab | tr --squeeze ' ' | perl -pe 's/openat\(AT_FDCWD, /open\(/'`"
|
||||
echo $try
|
||||
rlAssertEquals "Checking mode [$variant] is identical to golden [$mode$f$s$t]" "$golden" "$try"
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f fopen"
|
||||
rlRun "rm -f ababab"
|
||||
rlRun "rm expected.py"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
||||
# Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid())
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE reproducer.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid())" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 75m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 522528" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,59 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
||||
Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid())
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: pthread_join() hangs if a thread calls setuid()
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=522528
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=360523)
|
||||
reproducer's source file
|
||||
|
||||
Description of problem:
|
||||
|
||||
When a program creates a thread which calls setuid() and terminates, the other
|
||||
thread trying to wait for it hangs.
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
RHEL5 (2.5-34), also RHEL4 and the newest upstream sources
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
always
|
||||
|
||||
|
||||
Steps to Reproduce:
|
||||
|
||||
1. Compile attached source file of reproducer:
|
||||
|
||||
$ gcc -o reproducer reproducer.c -lpthread
|
||||
|
||||
2. and run it:
|
||||
|
||||
$ ./reproducer
|
||||
|
||||
|
||||
Actual results:
|
||||
|
||||
program hangs
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
program should end without hanging
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
This bug has appeared quite a long ago, you can find it in a sourceware BZ with existing patch at:
|
||||
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=3270#c2
|
||||
|
||||
The patch solves the problem, but I have no idea why this hasn't been applied in the upstream already. I have attached a slightly modiffied version of the patch to be able to be applied and built on RHEL5 glibc sources and it works and solves the problem.
|
||||
|
||||
There is also existing BZ for RHEL4:
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=248671
|
@ -0,0 +1,70 @@
|
||||
summary: Test for bz522528 (pthread_join() hangs if a thread calls setuid())
|
||||
description: |
|
||||
Bug summary: pthread_join() hangs if a thread calls setuid()
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=522528
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=360523)
|
||||
reproducer's source file
|
||||
|
||||
Description of problem:
|
||||
|
||||
When a program creates a thread which calls setuid() and terminates, the other
|
||||
thread trying to wait for it hangs.
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
RHEL5 (2.5-34), also RHEL4 and the newest upstream sources
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
always
|
||||
|
||||
|
||||
Steps to Reproduce:
|
||||
|
||||
1. Compile attached source file of reproducer:
|
||||
|
||||
$ gcc -o reproducer reproducer.c -lpthread
|
||||
|
||||
2. and run it:
|
||||
|
||||
$ ./reproducer
|
||||
|
||||
|
||||
Actual results:
|
||||
|
||||
program hangs
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
program should end without hanging
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
This bug has appeared quite a long ago, you can find it in a sourceware BZ with existing patch at:
|
||||
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=3270#c2
|
||||
|
||||
The patch solves the problem, but I have no idea why this hasn't been applied in the upstream already. I have attached a slightly modiffied version of the patch to be able to be applied and built on RHEL5 glibc sources and it works and solves the problem.
|
||||
|
||||
There is also existing BZ for RHEL4:
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=248671
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- gcc
|
||||
duration: 75m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=522528
|
||||
extra-summary: /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
||||
extra-task: /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
@ -0,0 +1,38 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define LOOPS 1000
|
||||
|
||||
uid_t uid;
|
||||
|
||||
void *subthread(void *dummy)
|
||||
{
|
||||
setuid(uid);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pthread_t tid[LOOPS];
|
||||
int i, ret;
|
||||
|
||||
uid = getuid();
|
||||
|
||||
for(i=0; i < LOOPS; i++) {
|
||||
ret = pthread_create(&tid[i], NULL, &subthread, NULL);
|
||||
if(ret != 0) {
|
||||
perror("pthread_create");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for(i=0; i < LOOPS; i++) {
|
||||
ret = pthread_join(tid[i], NULL);
|
||||
if(ret != 0) {
|
||||
perror("pthread_join");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz522528-pthread-join-hangs-if-a-thread-calls-setuid
|
||||
# Description: Test for bz522528 (pthread_join() hangs if a thread calls setuid())
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
TESTPROG="reproducer"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
rlRun "TESTTMPDIR=$(mktemp -d)"
|
||||
rlRun "cp ${TESTPROG}.c $TESTTMPDIR"
|
||||
rlRun "pushd $TESTTMPDIR"
|
||||
|
||||
PRARCH=$(rlGetPrimaryArch)
|
||||
if [[ $PRARCH =~ ia64 || $PRARCH =~ armv7 || $PRARCH =~ i.86 || $PRARCH =~ aarch64 ]]
|
||||
then
|
||||
rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -lpthread"
|
||||
else
|
||||
rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -lpthread -m64"
|
||||
fi
|
||||
|
||||
if [[ $PRARCH =~ s390x ]]
|
||||
then
|
||||
sleeptime=60
|
||||
else
|
||||
sleeptime=10
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Running the testcase 20 times"
|
||||
export FAILURES=0
|
||||
for i in `seq 20`
|
||||
do
|
||||
rlLog "Running the reproducer: try $i"
|
||||
./${TESTPROG} &
|
||||
PID=$!
|
||||
sleep $sleeptime
|
||||
NAME=`ps -p $PID -o comm=`
|
||||
|
||||
[ "$NAME" != "`basename ${TESTPROG}`" ]
|
||||
RESULT=$?
|
||||
rlAssert0 "Testing if the program is running" $RESULT
|
||||
|
||||
if [ "$RESULT" != "0" ]
|
||||
then
|
||||
rlLog "Killing the stray process"
|
||||
kill -9 $PID
|
||||
|
||||
rlLog "The program is still running"
|
||||
FAILURES=$((FAILURES+1))
|
||||
fi
|
||||
done
|
||||
rlAssert0 "Checking that no process had to be killed" $FAILURES
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlLog "Killing all reproducers, just to be sure"
|
||||
killall ${TESTPROG}
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TESTTMPDIR"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
||||
# Description: Test for bz529997 (assembler implementation of sem_timedwait() on)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE newrepr.c oldrepr.c real-reproducer.c golden-repro.out golden-real.out
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz529997 (assembler implementation of sem_timedwait() on)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 529997" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,148 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
||||
Description: Test for bz529997 (assembler implementation of sem_timedwait() on)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: assembler implementation of sem_timedwait() on x86/x86_64 reveals a bug when invalid nanosecond argument is used
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=529997
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=365459)
|
||||
the reproducer's source code
|
||||
|
||||
Description of problem:
|
||||
|
||||
An assembler implementation of seg_timedwait() for x86/x86_64 wrongly decrements the number of waiting threads stored in block of memory pointed by (sem_t *) when invalid nanosecond value is passed through the second argument. This is caused by jumping over the code, which increments (new_sem *)->nwaiters (because of wrong nanosecond argument) to the end of the seg_timedwait() function, where (new_sem *)->nwaiters is finally decremented. This breaks the subsequent semaphore operations. Please, see the `Additional info' for more details.
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
RHEL5(2,3,4), Fedora 11, the newest upstream sources from ftp.gnu.org (2.10.1)
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
always
|
||||
|
||||
|
||||
Steps to Reproduce:
|
||||
|
||||
1. compile attached reproducer:
|
||||
|
||||
$ gcc -o reproducer reproducer.c -lpthread
|
||||
|
||||
2. run it:
|
||||
|
||||
$ ./reproducer
|
||||
|
||||
|
||||
Actual results:
|
||||
|
||||
$ ./reproducer
|
||||
before sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
ERR: sem_timedwait() failed (errno=22: Invalid argument)
|
||||
after sem_timedwait(): new_sem->nwaiters = 0xffffffff
|
||||
$
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
$ ./reproducer
|
||||
before sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
ERR: sem_timedwait() failed (errno=22: Invalid argument)
|
||||
after sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
$
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
The bug was introduced by implementation of private futexes into glibc by a patch:
|
||||
glibc/RHEL-5/glibc-private-futex.patch
|
||||
|
||||
this patch relates to the following BZ:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=433353
|
||||
|
||||
and was introduced in:
|
||||
glibc-2.5-29/RHEL2 (it enables the above patch in spec.file)
|
||||
|
||||
|
||||
I have attached proposed patch, which fixes the bug and also more real-world reproducer (gcc -o real-reproducer real-reproducer.c -lrt).
|
||||
|
||||
Some details from investigation of the real world reproducer:
|
||||
|
||||
The output:
|
||||
|
||||
$ ./real-reproducer
|
||||
main: top of loop: sval = 0
|
||||
main: calling sem_timedwait
|
||||
thread: calling sem_timedwait with bogus tv_nsec
|
||||
thread: sem_timedwait: errno = 22 strerror = Invalid argument
|
||||
thread: calling sem_post
|
||||
main: sem_timedwait: errno = 110 strerror = Connection timed out <<< --- it waits here until timeouts, even if the thread calls sem_post()
|
||||
main: top of loop: sval = 1
|
||||
main: calling sem_timedwait
|
||||
main: sem_timedwait: success <<< --- passes
|
||||
main: calling sem_post
|
||||
$
|
||||
|
||||
If the value of nanosecond field is greater than 1000000000d, it directly jumps to the end of the function and executes the code which decrements the number of waiters, but remember the number of waiters wasn't incremented at the beginning.
|
||||
|
||||
See the rosponsible code with comments:
|
||||
|
||||
glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S:
|
||||
=== snip ===
|
||||
...
|
||||
/* Check for invalid nanosecond field. */
|
||||
cmpq $1000000000, 8(%r13)
|
||||
movl $EINVAL, %r14d
|
||||
jae 6f <<< the value is invalid it jumps to 6:
|
||||
|
||||
LOCK
|
||||
addq $1, NWAITERS(%r12) <<< see this incrementation is after jump to 6:
|
||||
|
||||
...
|
||||
6:
|
||||
movq errno@gottpoff(%rip), %rdx
|
||||
movl %r14d, %fs:(%rdx)
|
||||
orl $-1, %eax
|
||||
jmp 10b <<< jumping to 10:
|
||||
|
||||
...
|
||||
10: LOCK
|
||||
subq $1, NWAITERS(%r12) <<< we shouldn't increment here
|
||||
|
||||
addq $24, %rsp
|
||||
.Laddq:
|
||||
popq %r14
|
||||
.Lpop_r14:
|
||||
popq %r13
|
||||
.Lpop_r13:
|
||||
popq %r12
|
||||
.Lpop_r12:
|
||||
retq <<< end of sem_timedwait()
|
||||
=== end of snip ===
|
||||
|
||||
If we move the incrementation of number of waiting threads before checking for the correct value of nanosecond field or change the logic of the code to not decrement the waiters, it works correctly.
|
||||
|
||||
The reason why the sem_post() doesn't work in the func() function is that, the sem_timedwait() decreases the number of waiters as described above and the sem_post() checks this value and if it is zero, it jumps over the code, which would otherwise wake the other threads:
|
||||
|
||||
glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:
|
||||
=== snip ===
|
||||
...
|
||||
cmpq $0, NWAITERS(%rdi) <<< this makes the call to sem_post() in func() useless
|
||||
je 2f <<< jump to 2:
|
||||
|
||||
movl $SYS_futex, %eax
|
||||
movl $FUTEX_WAKE, %esi
|
||||
orl PRIVATE(%rdi), %esi
|
||||
movl $1, %edx
|
||||
syscall
|
||||
|
||||
testq %rax, %rax
|
||||
js 1f
|
||||
|
||||
2:
|
||||
xorl %eax, %eax <<< do exit clearly
|
||||
retq
|
||||
=== end of snip ===
|
||||
|
||||
so the sem_timedwait() in main() timeouts and the next call to sem_timedwait() passes immediately.
|
@ -0,0 +1,11 @@
|
||||
main: top of loop: sval = 0
|
||||
main: calling sem_timedwait
|
||||
thread: calling sem_timedwait with bogus tv_nsec
|
||||
thread: sem_timedwait: errno = 22 strerror = Invalid argument
|
||||
thread: calling sem_post
|
||||
main: sem_timedwait: success
|
||||
main: calling sem_post
|
||||
main: top of loop: sval = 1
|
||||
main: calling sem_timedwait
|
||||
main: sem_timedwait: success
|
||||
main: calling sem_post
|
@ -0,0 +1,3 @@
|
||||
before sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
ERR: sem_timedwait() failed (errno=22: Invalid argument)
|
||||
after sem_timedwait(): new_sem->nwaiters = 0x0
|
@ -0,0 +1,159 @@
|
||||
summary: Test for bz529997 (assembler implementation of sem_timedwait() on)
|
||||
description: |
|
||||
Bug summary: assembler implementation of sem_timedwait() on x86/x86_64 reveals a bug when invalid nanosecond argument is used
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=529997
|
||||
|
||||
Description:
|
||||
|
||||
Created an attachment (id=365459)
|
||||
the reproducer's source code
|
||||
|
||||
Description of problem:
|
||||
|
||||
An assembler implementation of seg_timedwait() for x86/x86_64 wrongly decrements the number of waiting threads stored in block of memory pointed by (sem_t *) when invalid nanosecond value is passed through the second argument. This is caused by jumping over the code, which increments (new_sem *)->nwaiters (because of wrong nanosecond argument) to the end of the seg_timedwait() function, where (new_sem *)->nwaiters is finally decremented. This breaks the subsequent semaphore operations. Please, see the `Additional info' for more details.
|
||||
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
RHEL5(2,3,4), Fedora 11, the newest upstream sources from ftp.gnu.org (2.10.1)
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
always
|
||||
|
||||
|
||||
Steps to Reproduce:
|
||||
|
||||
1. compile attached reproducer:
|
||||
|
||||
$ gcc -o reproducer reproducer.c -lpthread
|
||||
|
||||
2. run it:
|
||||
|
||||
$ ./reproducer
|
||||
|
||||
|
||||
Actual results:
|
||||
|
||||
$ ./reproducer
|
||||
before sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
ERR: sem_timedwait() failed (errno=22: Invalid argument)
|
||||
after sem_timedwait(): new_sem->nwaiters = 0xffffffff
|
||||
$
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
$ ./reproducer
|
||||
before sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
ERR: sem_timedwait() failed (errno=22: Invalid argument)
|
||||
after sem_timedwait(): new_sem->nwaiters = 0x0
|
||||
$
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
The bug was introduced by implementation of private futexes into glibc by a patch:
|
||||
glibc/RHEL-5/glibc-private-futex.patch
|
||||
|
||||
this patch relates to the following BZ:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=433353
|
||||
|
||||
and was introduced in:
|
||||
glibc-2.5-29/RHEL2 (it enables the above patch in spec.file)
|
||||
|
||||
|
||||
I have attached proposed patch, which fixes the bug and also more real-world reproducer (gcc -o real-reproducer real-reproducer.c -lrt).
|
||||
|
||||
Some details from investigation of the real world reproducer:
|
||||
|
||||
The output:
|
||||
|
||||
$ ./real-reproducer
|
||||
main: top of loop: sval = 0
|
||||
main: calling sem_timedwait
|
||||
thread: calling sem_timedwait with bogus tv_nsec
|
||||
thread: sem_timedwait: errno = 22 strerror = Invalid argument
|
||||
thread: calling sem_post
|
||||
main: sem_timedwait: errno = 110 strerror = Connection timed out <<< --- it waits here until timeouts, even if the thread calls sem_post()
|
||||
main: top of loop: sval = 1
|
||||
main: calling sem_timedwait
|
||||
main: sem_timedwait: success <<< --- passes
|
||||
main: calling sem_post
|
||||
$
|
||||
|
||||
If the value of nanosecond field is greater than 1000000000d, it directly jumps to the end of the function and executes the code which decrements the number of waiters, but remember the number of waiters wasn't incremented at the beginning.
|
||||
|
||||
See the rosponsible code with comments:
|
||||
|
||||
glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S:
|
||||
=== snip ===
|
||||
...
|
||||
/* Check for invalid nanosecond field. */
|
||||
cmpq $1000000000, 8(%r13)
|
||||
movl $EINVAL, %r14d
|
||||
jae 6f <<< the value is invalid it jumps to 6:
|
||||
|
||||
LOCK
|
||||
addq $1, NWAITERS(%r12) <<< see this incrementation is after jump to 6:
|
||||
|
||||
...
|
||||
6:
|
||||
movq errno@gottpoff(%rip), %rdx
|
||||
movl %r14d, %fs:(%rdx)
|
||||
orl $-1, %eax
|
||||
jmp 10b <<< jumping to 10:
|
||||
|
||||
...
|
||||
10: LOCK
|
||||
subq $1, NWAITERS(%r12) <<< we shouldn't increment here
|
||||
|
||||
addq $24, %rsp
|
||||
.Laddq:
|
||||
popq %r14
|
||||
.Lpop_r14:
|
||||
popq %r13
|
||||
.Lpop_r13:
|
||||
popq %r12
|
||||
.Lpop_r12:
|
||||
retq <<< end of sem_timedwait()
|
||||
=== end of snip ===
|
||||
|
||||
If we move the incrementation of number of waiting threads before checking for the correct value of nanosecond field or change the logic of the code to not decrement the waiters, it works correctly.
|
||||
|
||||
The reason why the sem_post() doesn't work in the func() function is that, the sem_timedwait() decreases the number of waiters as described above and the sem_post() checks this value and if it is zero, it jumps over the code, which would otherwise wake the other threads:
|
||||
|
||||
glibc-2.5-20061008T1257/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S:
|
||||
=== snip ===
|
||||
...
|
||||
cmpq $0, NWAITERS(%rdi) <<< this makes the call to sem_post() in func() useless
|
||||
je 2f <<< jump to 2:
|
||||
|
||||
movl $SYS_futex, %eax
|
||||
movl $FUTEX_WAKE, %esi
|
||||
orl PRIVATE(%rdi), %esi
|
||||
movl $1, %edx
|
||||
syscall
|
||||
|
||||
testq %rax, %rax
|
||||
js 1f
|
||||
|
||||
2:
|
||||
xorl %eax, %eax <<< do exit clearly
|
||||
retq
|
||||
=== end of snip ===
|
||||
|
||||
so the sem_timedwait() in main() timeouts and the next call to sem_timedwait() passes immediately.
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=529997
|
||||
extra-summary: /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
||||
extra-task: /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
@ -0,0 +1,100 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//#define TST_TEST_MODE 1
|
||||
|
||||
#define __HAVE_64B_ATOMICS 1
|
||||
|
||||
/* Semaphore variable structure. */
|
||||
// taken from nptl/sysdeps/unix/sysv/linux/internaltypes.h
|
||||
struct new_sem
|
||||
{
|
||||
#if __HAVE_64B_ATOMICS
|
||||
/* The data field holds both value (in the least-significant 32 bytes) and
|
||||
nwaiters. */
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define SEM_VALUE_OFFSET 0
|
||||
# elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define SEM_VALUE_OFFSET 1
|
||||
# else
|
||||
# error Unsupported byte order.
|
||||
# endif
|
||||
# define SEM_NWAITERS_SHIFT 32
|
||||
# define SEM_VALUE_MASK (~(unsigned int)0)
|
||||
unsigned long int data;
|
||||
int private;
|
||||
int pad;
|
||||
#else
|
||||
# define SEM_VALUE_SHIFT 1
|
||||
# define SEM_NWAITERS_MASK ((unsigned int)1)
|
||||
unsigned int value;
|
||||
int private;
|
||||
int pad;
|
||||
unsigned int nwaiters;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if TST_TEST_MODE
|
||||
void func(sem_t *semp) {
|
||||
struct timespec ts1 = {10, 1};
|
||||
struct timespec ts2 = {10, 1};
|
||||
struct timespec ts3 = {10, 1};
|
||||
|
||||
printf("Starting thread\n");
|
||||
|
||||
if (sem_post(semp) == -1) {
|
||||
printf("sem_post error\n");
|
||||
sem_timedwait(semp, &ts1);
|
||||
}
|
||||
|
||||
if (sem_post(semp) == -1) {
|
||||
printf("sem_post error\n");
|
||||
sem_timedwait(semp, &ts2);
|
||||
}
|
||||
if (sem_timedwait(semp, &ts3) < 0)
|
||||
printf("THREAD ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno));
|
||||
|
||||
sleep(10);
|
||||
printf("Finishing thread\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#if TST_TEST_MODE
|
||||
pthread_t thread1,thread2,thread3;
|
||||
struct timespec ts = {10, 1}; // set incorrect nanoseconds
|
||||
#else
|
||||
struct timespec ts = {0, -1}; // set incorrect nanoseconds
|
||||
#endif
|
||||
sem_t sem;
|
||||
struct new_sem *isem = (struct new_sem *)&sem;
|
||||
|
||||
sem_init(&sem, 0, 0);
|
||||
|
||||
#if TST_TEST_MODE
|
||||
|
||||
pthread_create(&thread1, NULL, (void *)&func, (void *)&sem);
|
||||
sleep(1);
|
||||
pthread_create(&thread2, NULL, (void *)&func, (void *)&sem);
|
||||
sleep(1);
|
||||
pthread_create(&thread3, NULL, (void *)&func, (void *)&sem);
|
||||
sleep(1);
|
||||
#endif
|
||||
unsigned int *pres;
|
||||
pres=(unsigned int*) &isem->data;
|
||||
printf("before sem_timedwait(): new_sem->nwaiters = 0x%x\n", *pres );
|
||||
if (sem_timedwait(&sem, &ts) < 0)
|
||||
printf("ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno));
|
||||
pres=(unsigned int*) &isem->data;
|
||||
printf("after sem_timedwait(): new_sem->nwaiters = 0x%x\n", *pres );
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
/* Semaphore variable structure. */
|
||||
// taken from nptl/sysdeps/unix/sysv/linux/internaltypes.h
|
||||
struct new_sem
|
||||
{
|
||||
unsigned int value;
|
||||
int private;
|
||||
unsigned long int nwaiters;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct timespec ts = {0, -1}; // set incorrect nanoseconds
|
||||
sem_t sem;
|
||||
int ret = 0;
|
||||
struct new_sem *isem = (struct new_sem *)&sem;
|
||||
|
||||
sem_init(&sem, 0, 0);
|
||||
|
||||
printf("before sem_timedwait(): new_sem->nwaiters = 0x%x\n", isem->nwaiters);
|
||||
if (sem_timedwait(&sem, &ts) < 0)
|
||||
printf("ERR: sem_timedwait() failed (errno=%d: %s)\n", errno, strerror(errno));
|
||||
printf("after sem_timedwait(): new_sem->nwaiters = 0x%x\n", isem->nwaiters);
|
||||
|
||||
return (isem->nwaiters != 0);
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <semaphore.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
void func(sem_t *semp)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
sleep(2);
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = -1;
|
||||
|
||||
errno = 0;
|
||||
printf("thread: calling sem_timedwait with bogus tv_nsec\n");
|
||||
if (sem_timedwait(semp, &ts) != 0)
|
||||
printf("thread: sem_timedwait: errno = %d strerror = %s\n",
|
||||
errno, strerror(errno));
|
||||
|
||||
printf("thread: calling sem_post\n");
|
||||
if (sem_post(semp) != 0)
|
||||
printf("thread: sem_post: errno = %d strerror = %s\n", errno,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
struct timespec ts;
|
||||
pthread_t thread;
|
||||
sem_t sem;
|
||||
int i = 0, sval = 0;
|
||||
|
||||
sem_init(&sem, 0, 0);
|
||||
|
||||
pthread_create(&thread, NULL, (void *)&func, (void *)&sem);
|
||||
|
||||
/* two passes to illustrate that only the processes that are already
|
||||
waiting for the semaphore when the call to sem_timedwait with the
|
||||
bogus args is made are negatively impacted, i.e. subsequent calls
|
||||
to sem_timedwait succeed */
|
||||
for (i = 0; i < 2; i++) {
|
||||
sem_getvalue(&sem, &sval);
|
||||
printf("main: top of loop: sval = %d\n", sval);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
ts.tv_sec += 10;
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
printf("main: calling sem_timedwait\n");
|
||||
if (sem_timedwait(&sem, &ts) != 0) {
|
||||
printf("main: sem_timedwait: errno = %d strerror = "
|
||||
"%s\n", errno, strerror(errno));
|
||||
} else {
|
||||
printf("main: sem_timedwait: success\n");
|
||||
printf("main: calling sem_post\n");
|
||||
if (sem_post(&sem) != 0)
|
||||
printf("thread: sem_post: errno = %d strerror "
|
||||
"= %s\n", errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
81
tests/Regression/bz529997-sem_timedwait-with-invalid-time/runtest.sh
Executable file
81
tests/Regression/bz529997-sem_timedwait-with-invalid-time/runtest.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz529997-sem_timedwait-with-invalid-time
|
||||
# Description: Test for bz529997 (assembler implementation of sem_timedwait() on)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
PRARCH="$(rlGetPrimaryArch)"
|
||||
rlLog "Architecture : $PRARCH"
|
||||
rlAssertRpm $PACKAGE
|
||||
if rlIsRHEL 5 6
|
||||
then
|
||||
rlRun "gcc oldrepr.c -o repro1 -lpthread"
|
||||
else
|
||||
rlRun "gcc newrepr.c -o repro1 -lpthread"
|
||||
fi
|
||||
rlRun "gcc real-reproducer.c -o repro2 -lrt -lpthread"
|
||||
|
||||
# just adding --copy-dt-needed-entries to the linker would work as well
|
||||
# rlRun "gcc -Wl,--copy-dt-needed-entries reproducer.c -o repro1 -lrt"
|
||||
# rlRun "gcc -Wl,--copy-dt-needed-entries real-reproducer.c -o repro2 -lrt"
|
||||
# https://fedoraproject.org/wiki/UnderstandingDSOLinkChange
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Running reproducers"
|
||||
./repro1 > repro.out
|
||||
./repro2 > real.out
|
||||
rlAssertNotDiffer "golden-repro.out" "repro.out"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "The first repro output differs from golden:"
|
||||
diff -u "golden-repro.out" "repro.out" | while read line
|
||||
do
|
||||
rlLog "$line"
|
||||
done
|
||||
fi
|
||||
|
||||
rlAssertNotDiffer "golden-real.out" "real.out" ||
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
rlLog "The second repro output differs from golden:"
|
||||
diff -u "golden-real.out" "real.out" | while read line
|
||||
do
|
||||
rlLog "$line"
|
||||
done
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm repro1 repro2 real.out repro.out"
|
||||
rlPhaseEnd
|
||||
rlJournalEnd
|
@ -0,0 +1,67 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
||||
# Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE p2.pl p1.pl p3_3.py p3.py p4_3.py p4.py
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 90m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc-utils" >> $(METADATA)
|
||||
@echo "Requires: python python3" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 531576" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,101 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
||||
Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: [RHEL5] memusage cmd segfaults if run on a perl script that has 'use' in it
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531576
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
|
||||
memusage utility is part of glibc-devel
|
||||
|
||||
memusage cmd segfaults if run on a perl script that has 'use' in it.
|
||||
|
||||
Examples:
|
||||
|
||||
[my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
|
||||
This works (contents of perltest.pl):
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
print "my_name\n";
|
||||
|
||||
This segfaults:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
use Net::SSH::Perl;
|
||||
print "my_name\n";
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
very
|
||||
|
||||
Steps to Reproduce:
|
||||
1.create perl script:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
# perltest.pl
|
||||
use Net::SSH::Perl;
|
||||
print "my_name\n";
|
||||
|
||||
2. run memusage on script:
|
||||
[my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
|
||||
Actual results:
|
||||
|
||||
|
||||
my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
/usr/bin/memusage: line 253: 29483 Segmentation fault (core dumped) LD_PRELOAD=/usr/\$LIB/libmemusage.so MEMUSAGE_OUTPUT=/tmp/memusage.S29480 "$@"
|
||||
/usr/bin/memusage: line 265: 29484 Floating point exception(core dumped) $memusagestat $memusagestat_args "$datafile" "$png"
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
my_name
|
||||
|
||||
Memory usage summary: heap total: 278236, heap peak: 271027, stack peak: 10816
|
||||
total calls total memory failed calls
|
||||
malloc| 684 277100 0
|
||||
realloc| 14 1136 0 (nomove:6, dec:1, free:0)
|
||||
calloc| 0 0 0
|
||||
free| 94 20735
|
||||
Histogram for block sizes:
|
||||
0-15 215 30% ==================================================
|
||||
16-31 110 15% =========================
|
||||
32-47 36 5% ========
|
||||
48-63 110 15% =========================
|
||||
64-79 34 4% =======
|
||||
80-95 64 9% ==============
|
||||
96-111 63 9% ==============
|
||||
112-127 3 <1%
|
||||
128-143 8 1% =
|
||||
144-159 2 <1%
|
||||
160-175 4 <1%
|
||||
240-255 4 <1%
|
||||
256-271 8 1% =
|
||||
512-527 2 <1%
|
||||
592-607 1 <1%
|
||||
800-815 3 <1%
|
||||
1024-1039 3 <1%
|
||||
1568-1583 1 <1%
|
||||
2400-2415 1 <1%
|
||||
4032-4047 2 <1%
|
||||
4048-4063 1 <1%
|
||||
4064-4079 1 <1%
|
||||
4080-4095 7 1% =
|
||||
4096-4111 10 1% ==
|
||||
4224-4239 1 <1%
|
||||
4368-4383 2 <1%
|
||||
7904-7919 1 <1%
|
||||
large 1 <1%
|
||||
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
I have no ulimit and yet there does not appear to be a core file.
|
@ -0,0 +1,116 @@
|
||||
summary: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)
|
||||
description: |
|
||||
Bug summary: [RHEL5] memusage cmd segfaults if run on a perl script that has 'use' in it
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=531576
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
|
||||
memusage utility is part of glibc-devel
|
||||
|
||||
memusage cmd segfaults if run on a perl script that has 'use' in it.
|
||||
|
||||
Examples:
|
||||
|
||||
[my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
|
||||
This works (contents of perltest.pl):
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
print "my_name\n";
|
||||
|
||||
This segfaults:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
use Net::SSH::Perl;
|
||||
print "my_name\n";
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
|
||||
|
||||
How reproducible:
|
||||
|
||||
very
|
||||
|
||||
Steps to Reproduce:
|
||||
1.create perl script:
|
||||
|
||||
#!/usr/bin/perl -w
|
||||
# perltest.pl
|
||||
use Net::SSH::Perl;
|
||||
print "my_name\n";
|
||||
|
||||
2. run memusage on script:
|
||||
[my_name@my_host ~]$ ./memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
|
||||
Actual results:
|
||||
|
||||
|
||||
my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
/usr/bin/memusage: line 253: 29483 Segmentation fault (core dumped) LD_PRELOAD=/usr/\$LIB/libmemusage.so MEMUSAGE_OUTPUT=/tmp/memusage.S29480 "$@"
|
||||
/usr/bin/memusage: line 265: 29484 Floating point exception(core dumped) $memusagestat $memusagestat_args "$datafile" "$png"
|
||||
|
||||
|
||||
Expected results:
|
||||
|
||||
my_name@my_host /tmp % memusage --png=out.png -x 800 -y 300 ./perltest.pl
|
||||
my_name
|
||||
|
||||
Memory usage summary: heap total: 278236, heap peak: 271027, stack peak: 10816
|
||||
total calls total memory failed calls
|
||||
malloc| 684 277100 0
|
||||
realloc| 14 1136 0 (nomove:6, dec:1, free:0)
|
||||
calloc| 0 0 0
|
||||
free| 94 20735
|
||||
Histogram for block sizes:
|
||||
0-15 215 30% ==================================================
|
||||
16-31 110 15% =========================
|
||||
32-47 36 5% ========
|
||||
48-63 110 15% =========================
|
||||
64-79 34 4% =======
|
||||
80-95 64 9% ==============
|
||||
96-111 63 9% ==============
|
||||
112-127 3 <1%
|
||||
128-143 8 1% =
|
||||
144-159 2 <1%
|
||||
160-175 4 <1%
|
||||
240-255 4 <1%
|
||||
256-271 8 1% =
|
||||
512-527 2 <1%
|
||||
592-607 1 <1%
|
||||
800-815 3 <1%
|
||||
1024-1039 3 <1%
|
||||
1568-1583 1 <1%
|
||||
2400-2415 1 <1%
|
||||
4032-4047 2 <1%
|
||||
4048-4063 1 <1%
|
||||
4064-4079 1 <1%
|
||||
4080-4095 7 1% =
|
||||
4096-4111 10 1% ==
|
||||
4224-4239 1 <1%
|
||||
4368-4383 2 <1%
|
||||
7904-7919 1 <1%
|
||||
large 1 <1%
|
||||
|
||||
|
||||
|
||||
Additional info:
|
||||
|
||||
I have no ulimit and yet there does not appear to be a core file.
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
- glibc-utils
|
||||
- python
|
||||
- python3
|
||||
- gcc
|
||||
duration: 90m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=531576
|
||||
extra-summary: /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
||||
extra-task: /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
print "P1\n";
|
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
print "P2\n";
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
|
||||
print "P3"
|
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
|
||||
print ("P3")
|
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
print "P4"
|
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
print ("P4")
|
74
tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/runtest.sh
Executable file
74
tests/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts/runtest.sh
Executable file
@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz531576-memusage-cmd-segfaults-on-perl-scripts
|
||||
# Description: Test for bz531576 ([RHEL5] memusage cmd segfaults if run on a perl)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
TEMPC=`mktemp`.c
|
||||
echo "int main(){ return 0; }" > $TEMPC
|
||||
echo "int result() { return 1; }" >> $TEMPC
|
||||
for i in `seq 10000`
|
||||
do
|
||||
echo "int fction$i(){ return result(); }" >> $TEMPC
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
if rlIsRHEL ">=8" || rlIsFedora
|
||||
then
|
||||
CURPYTHON="python3"
|
||||
P3="p3_3.py"
|
||||
P4="p4_3.py"
|
||||
else
|
||||
CURPYTHON="python"
|
||||
P3="p3.py"
|
||||
P4="p4.py"
|
||||
fi
|
||||
|
||||
for testcase in "perl p1.pl" "perl p2.pl" "$CURPYTHON $P3" "$CURPYTHON $P4" "$CURPYTHON -V" "ps" "gcc -O0 $TEMPC -o /dev/null"
|
||||
do
|
||||
for output in "" "--png=out.png" "--png=out.png -x 800 -y 300" "--data=out.dat"
|
||||
do
|
||||
for mmap in "" "--mmap"
|
||||
do
|
||||
rlRun "memusage $output $mmap $testcase"
|
||||
done
|
||||
done
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f out.png out.dat $TEMPC"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
Binary file not shown.
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
||||
# Description: Test for bz549813 (dl_close() race with C++ destructor)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE C_Only.tar
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz549813 (dl_close() race with C++ destructor)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 549813" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,91 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
||||
Description: Test for bz549813 (dl_close() race with C++ destructor)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: dl_close() race with C++ destructor
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=549813
|
||||
|
||||
Description:
|
||||
|
||||
This looks like a dup of
|
||||
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=654
|
||||
|
||||
|
||||
Create a pthread in the library init. In fini, cancel the pthread and then join. If the main thread does a dlclose(), the program hangs at pthread_join().
|
||||
It is stuck in a futex. I tried the testcase from http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 and that fails too.
|
||||
|
||||
One thing that may be relevant is that if dlopen is called with RTLD_NODELETE, pthread_join will not hang.
|
||||
|
||||
|
||||
main program->
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
void *handle;
|
||||
|
||||
handle = dlopen("tiny.so",RTLD_NOW);
|
||||
if (handle)
|
||||
printf("loaded shared library\n");
|
||||
else {
|
||||
printf("could not load shared library\n");
|
||||
return (-1);
|
||||
}
|
||||
sleep(1);
|
||||
dlclose(handle);
|
||||
|
||||
}
|
||||
|
||||
the lib ->
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
pthread_t t;
|
||||
|
||||
|
||||
void *F(void *arg) {
|
||||
|
||||
int old;
|
||||
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old) == 0) {
|
||||
printf("> cancelability enabled.\n");
|
||||
}
|
||||
else {
|
||||
printf("> could not set cancelability\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
} /*end F */
|
||||
|
||||
int _init_rick (void) {
|
||||
|
||||
printf("in init\n");
|
||||
if (pthread_create(&t, NULL, (void *(*)(void *)) F, NULL) == 0)
|
||||
printf("started thread\n");
|
||||
else
|
||||
printf("could not start thread\n");
|
||||
|
||||
} /* end _init_rick */
|
||||
|
||||
int _fini_rick (void) {
|
||||
|
||||
printf("in fini\n");
|
||||
|
||||
printf("canceling thread\n");
|
||||
if (pthread_cancel(t) == 0)
|
||||
printf("canceled thread\n");
|
||||
else
|
||||
printf("could not cancel thread \n");
|
||||
|
||||
printf("joining thread\n");
|
||||
if (pthread_join(t, NULL) == 0)
|
||||
printf("joined with thread\n");
|
||||
else
|
||||
printf("could not join with thread\n");
|
||||
|
||||
|
||||
} /* end _fini_rick */
|
@ -0,0 +1,102 @@
|
||||
summary: Test for bz549813 (dl_close() race with C++ destructor)
|
||||
description: |
|
||||
Bug summary: dl_close() race with C++ destructor
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=549813
|
||||
|
||||
Description:
|
||||
|
||||
This looks like a dup of
|
||||
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=654
|
||||
|
||||
|
||||
Create a pthread in the library init. In fini, cancel the pthread and then join. If the main thread does a dlclose(), the program hangs at pthread_join().
|
||||
It is stuck in a futex. I tried the testcase from http://sources.redhat.com/bugzilla/show_bug.cgi?id=654 and that fails too.
|
||||
|
||||
One thing that may be relevant is that if dlopen is called with RTLD_NODELETE, pthread_join will not hang.
|
||||
|
||||
|
||||
main program->
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
void *handle;
|
||||
|
||||
handle = dlopen("tiny.so",RTLD_NOW);
|
||||
if (handle)
|
||||
printf("loaded shared library\n");
|
||||
else {
|
||||
printf("could not load shared library\n");
|
||||
return (-1);
|
||||
}
|
||||
sleep(1);
|
||||
dlclose(handle);
|
||||
|
||||
}
|
||||
|
||||
the lib ->
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
pthread_t t;
|
||||
|
||||
|
||||
void *F(void *arg) {
|
||||
|
||||
int old;
|
||||
if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old) == 0) {
|
||||
printf("> cancelability enabled.\n");
|
||||
}
|
||||
else {
|
||||
printf("> could not set cancelability\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
} /*end F */
|
||||
|
||||
int _init_rick (void) {
|
||||
|
||||
printf("in init\n");
|
||||
if (pthread_create(&t, NULL, (void *(*)(void *)) F, NULL) == 0)
|
||||
printf("started thread\n");
|
||||
else
|
||||
printf("could not start thread\n");
|
||||
|
||||
} /* end _init_rick */
|
||||
|
||||
int _fini_rick (void) {
|
||||
|
||||
printf("in fini\n");
|
||||
|
||||
printf("canceling thread\n");
|
||||
if (pthread_cancel(t) == 0)
|
||||
printf("canceled thread\n");
|
||||
else
|
||||
printf("could not cancel thread \n");
|
||||
|
||||
printf("joining thread\n");
|
||||
if (pthread_join(t, NULL) == 0)
|
||||
printf("joined with thread\n");
|
||||
else
|
||||
printf("could not join with thread\n");
|
||||
|
||||
|
||||
} /* end _fini_rick */
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=549813
|
||||
extra-summary: /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
||||
extra-task: /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
56
tests/Regression/bz549813-dl-close-race-with-C-destructor/runtest.sh
Executable file
56
tests/Regression/bz549813-dl-close-race-with-C-destructor/runtest.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz549813-dl-close-race-with-C-destructor
|
||||
# Description: Test for bz549813 (dl_close() race with C++ destructor)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
rlRun "tar xfv C_Only.tar"
|
||||
rlRun "pushd C_Only" && rlRun "make it"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
export LD_LIBRARY_PATH=.
|
||||
rlLog "Checking that the command does not hang"
|
||||
rlRun "rlWatchdog ./c_only 5" && rlRun "./c_only" 0 "Checking that the testcase works correctly"
|
||||
unset LD_LIRBARY_PATH
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlLog "Killing possible remnants"
|
||||
killall -9 c_only
|
||||
rlRun "make clean"
|
||||
rlRun "popd"
|
||||
rlRun "rm -rf C_Only"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
64
tests/Regression/bz566712-aio-write-ll-corruption/Makefile
Normal file
64
tests/Regression/bz566712-aio-write-ll-corruption/Makefile
Normal file
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
||||
# Description: Test for bz566712 (If pthread_create fails in aio_write, requests)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE aio_write.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz566712 (If pthread_create fails in aio_write, requests)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 30m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 566712" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
33
tests/Regression/bz566712-aio-write-ll-corruption/PURPOSE
Normal file
33
tests/Regression/bz566712-aio-write-ll-corruption/PURPOSE
Normal file
@ -0,0 +1,33 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
||||
Description: Test for bz566712 (If pthread_create fails in aio_write, requests)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: If pthread_create fails in aio_write, requests linked list is corrupted
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=566712
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
When one calls aio_write, it internally calls __aio_enqueue_request, which will in turn call aio_create_helper_thread. If thread creation fails, the newly created request (newp in the code) will still be in the requests linked list, but it will be freed later in __aio_enqueue_request.
|
||||
|
||||
A subsequent call to aio_write will cause a segmentation fault.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.5-*.el5
|
||||
|
||||
How reproducible:
|
||||
100%
|
||||
|
||||
Steps to Reproduce:
|
||||
There's a test case from Neil Vachharajani in upstream bugzilla:
|
||||
|
||||
http://sources.redhat.com/bugzilla/attachment.cgi?id=4198&action=view
|
||||
|
||||
|
||||
Actual results:
|
||||
If compiled -DCRASH the program segfaults.
|
||||
|
||||
Expected results:
|
||||
If compiled -DCRASH the program does not segfault.
|
||||
|
||||
Additional info:
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10643
|
@ -0,0 +1,55 @@
|
||||
#include <aio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
__thread int x[4096];
|
||||
|
||||
struct aiocb * do_aio_write(int fd, char *buf, int len, int offset)
|
||||
{
|
||||
|
||||
struct aiocb *op = calloc(1, sizeof(struct aiocb));
|
||||
|
||||
if (!op) {
|
||||
printf("Could not allocate memory\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
op->aio_fildes = fd;
|
||||
op->aio_buf = buf;
|
||||
op->aio_nbytes = len;
|
||||
op->aio_offset = offset;
|
||||
|
||||
if (aio_write(op) == -1)
|
||||
printf("aio_write() err\n");
|
||||
else
|
||||
printf("aio_write() success\n");
|
||||
|
||||
return op;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf1[] = "Hello World\n";
|
||||
char buf2[] = "Goodbye World\n";
|
||||
int fd;
|
||||
struct aiocb *op1, *op2;
|
||||
|
||||
fd = open("foo.txt", O_CREAT | O_WRONLY | O_TRUNC);
|
||||
|
||||
if (fd == -1) {
|
||||
perror("open");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
op1 = do_aio_write(fd, buf1, strlen(buf1), 0);
|
||||
op2 = do_aio_write(fd, buf2, strlen(buf2), strlen(buf1));
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
44
tests/Regression/bz566712-aio-write-ll-corruption/main.fmf
Normal file
44
tests/Regression/bz566712-aio-write-ll-corruption/main.fmf
Normal file
@ -0,0 +1,44 @@
|
||||
summary: Test for bz566712 (If pthread_create fails in aio_write, requests)
|
||||
description: |
|
||||
Bug summary: If pthread_create fails in aio_write, requests linked list is corrupted
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=566712
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
When one calls aio_write, it internally calls __aio_enqueue_request, which will in turn call aio_create_helper_thread. If thread creation fails, the newly created request (newp in the code) will still be in the requests linked list, but it will be freed later in __aio_enqueue_request.
|
||||
|
||||
A subsequent call to aio_write will cause a segmentation fault.
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.5-*.el5
|
||||
|
||||
How reproducible:
|
||||
100%
|
||||
|
||||
Steps to Reproduce:
|
||||
There's a test case from Neil Vachharajani in upstream bugzilla:
|
||||
|
||||
http://sources.redhat.com/bugzilla/attachment.cgi?id=4198&action=view
|
||||
|
||||
|
||||
Actual results:
|
||||
If compiled -DCRASH the program segfaults.
|
||||
|
||||
Expected results:
|
||||
If compiled -DCRASH the program does not segfault.
|
||||
|
||||
Additional info:
|
||||
http://sources.redhat.com/bugzilla/show_bug.cgi?id=10643
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
duration: 30m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=566712
|
||||
extra-summary: /tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
||||
extra-task: /tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
56
tests/Regression/bz566712-aio-write-ll-corruption/runtest.sh
Executable file
56
tests/Regression/bz566712-aio-write-ll-corruption/runtest.sh
Executable file
@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz566712-aio-write-ll-corruption
|
||||
# Description: Test for bz566712 (If pthread_create fails in aio_write, requests)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
rlRun "gcc aio_write.c -o aio-rt -lrt"
|
||||
if rlIsRHEL 5
|
||||
then
|
||||
rlRun "gcc aio_write.c -o aio-rtkaio -lrtkaio -lpthread"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "./aio-rt"
|
||||
if rlIsRHEL 5
|
||||
then
|
||||
rlRun "./aio-rtkaio"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm -f aio-rt aio-rtkaio foo.txt"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
@ -0,0 +1,65 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
||||
# Description: Calls ftell after write and verifies that buf is not flushed
|
||||
# Author: Arjun Shankar <ashankar@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE tst-write-ftell.c tst-ftell-with-fdopen.c tst-ftell-with-fdopen.expected
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
test -x runtest.sh || chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Arjun Shankar <ashankar@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Calls ftell after write and verifies that buf is not flushed" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: gcc glibc glibc-devel glibc-headers strace" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 577950" >> $(METADATA)
|
||||
@echo "Releases: -RHELServer5 -RHELClient5 -RHEL6" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,3 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
||||
Description: Calls ftell after write and verifies that buf is not flushed
|
||||
Author: Arjun Shankar <ashankar@redhat.com>
|
@ -0,0 +1,18 @@
|
||||
summary: Calls ftell after write and verifies that buf is not flushed
|
||||
description: ''
|
||||
contact: Arjun Shankar <ashankar@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- gcc
|
||||
- glibc
|
||||
- glibc-devel
|
||||
- glibc-headers
|
||||
- strace
|
||||
duration: 15m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=577950
|
||||
extra-summary: /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
||||
extra-task: /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz577950-ftell-after-write-causes-glibc-to-flush-buffer
|
||||
# Description: Calls ftell after write and verifies that buf is not flushed
|
||||
# Author: Arjun Shankar <ashankar@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
REQUIRES=(gcc glibc glibc-devel strace)
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
for p in ${REQUIRES[@]}; do
|
||||
rlAssertRpm $p
|
||||
done; unset p
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "cp *.c *.expected $TmpDir"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlRun "gcc -o tst-write-ftell tst-write-ftell.c"
|
||||
rlAssertExists "tst-write-ftell"
|
||||
rlRun "gcc -o tst-ftell-with-fdopen tst-ftell-with-fdopen.c"
|
||||
rlAssertExists "tst-ftell-with-fdopen"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun "strace ./tst-write-ftell /dev/null 40 0 &> strace.out"
|
||||
rlAssertEquals "Do not expect any writes of size 208 bytes" "$(cat strace.out | grep '^write.*208$' | wc -l)" "0"
|
||||
rlLog "$(cat strace.out | grep ^write | head)"
|
||||
rlRun "strace ./tst-write-ftell /dev/null 40 1 &> strace.out"
|
||||
rlAssertEquals "Do not expect any writes of size 208 bytes" "$(cat strace.out | grep '^write.*208$' | wc -l)" "0"
|
||||
rlLog "$(cat strace.out | grep ^write | head)"
|
||||
for f1 in "" "-f"; do
|
||||
for f2 in "" "-o"; do
|
||||
rlRun "./tst-ftell-with-fdopen $f1 $f2"
|
||||
rlRun "cmp tst-ftell-with-fdopen.out tst-ftell-with-fdopen.expected"
|
||||
done
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
@ -0,0 +1,59 @@
|
||||
/* Test case from:
|
||||
https://sourceware.org/bugzilla/show_bug.cgi?id=16532#c0 */
|
||||
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp;
|
||||
size_t written;
|
||||
off_t off;
|
||||
int do_flush = 0, do_fopen = 0;
|
||||
int opt;
|
||||
const char *const fname = "tst-ftell-with-fdopen.out";
|
||||
|
||||
while ((opt = getopt (argc, argv, "fo")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'f':
|
||||
do_flush = 1;
|
||||
break;
|
||||
case 'o':
|
||||
do_fopen = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fp = fopen (fname, "w");
|
||||
written = fwrite ("abcabc", 1, 6, fp);
|
||||
assert (written == 6);
|
||||
|
||||
fclose (fp);
|
||||
|
||||
if (do_fopen)
|
||||
fp = fopen (fname, "a");
|
||||
else
|
||||
{
|
||||
int fd = open (fname, O_WRONLY, 0);
|
||||
assert (fd != -1);
|
||||
fp = fdopen (fd, "a");
|
||||
}
|
||||
|
||||
assert (fp != NULL);
|
||||
|
||||
written = fwrite ("ghi", 1, 3, fp);
|
||||
assert (written == 3);
|
||||
|
||||
if (do_flush)
|
||||
fflush (NULL);
|
||||
|
||||
off = ftello (fp);
|
||||
assert (off == 9);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
abcabcghi
|
@ -0,0 +1,105 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define MEGABYTE 1048576
|
||||
#define KILOBYTE 1024
|
||||
|
||||
/* How to call:
|
||||
./tst-write-ftell DESTFILE SIZE_KB 0|1
|
||||
|
||||
0 => do not call ftell;
|
||||
1 => call ftell;
|
||||
|
||||
SIZE_KB must be in range [10,200]. */
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
char *filename;
|
||||
char *data;
|
||||
int dsize, writesize, chunksize, count;
|
||||
FILE *file;
|
||||
|
||||
int ftell_on = 0;
|
||||
chunksize = 208;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
fprintf (stderr, "Invalid arguments\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
|
||||
errno = 0;
|
||||
dsize = strtol (argv[2], NULL, 0);
|
||||
if (errno)
|
||||
{
|
||||
perror ("strtol() failed");
|
||||
return 1;
|
||||
}
|
||||
if ((dsize < 10)
|
||||
|| (dsize > 200))
|
||||
{
|
||||
fprintf (stderr, "Invalid SIZE_KB: %d\n", dsize);
|
||||
exit (1);
|
||||
}
|
||||
dsize *= KILOBYTE;
|
||||
|
||||
ftell_on = strtol (argv[3], NULL, 0);
|
||||
if (errno)
|
||||
{
|
||||
perror ("strtol() failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
data = malloc (sizeof (char) * dsize);
|
||||
if (!data)
|
||||
{
|
||||
perror ("malloc() failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
file = fopen (filename, "w");
|
||||
if (file == NULL)
|
||||
{
|
||||
perror ("fopen failed()");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
for (count = 0; count < dsize; count += chunksize)
|
||||
{
|
||||
if (count + chunksize <= dsize)
|
||||
{
|
||||
writesize = chunksize;
|
||||
}
|
||||
else
|
||||
{
|
||||
writesize = dsize - count;
|
||||
}
|
||||
|
||||
ret = fwrite (data, writesize, 1, file);
|
||||
|
||||
if (ret != 1)
|
||||
{
|
||||
perror ("Write failed");
|
||||
abort ();
|
||||
}
|
||||
|
||||
if (ftell_on)
|
||||
{
|
||||
int pos;
|
||||
pos = ftell (file);
|
||||
if (pos < 0)
|
||||
{
|
||||
perror ("ftell() failed");
|
||||
abort ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
ret = fclose (file);
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
||||
# Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)
|
||||
# Author: Miroslav Franc <mfranc@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE pthread_rwlock_timedwrlock.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Miroslav Franc <mfranc@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc gcc" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 580498" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,27 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
||||
Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)
|
||||
Author: Miroslav Franc <mfranc@redhat.com>
|
||||
Bug summary: pthread_rwlock_timedwrlock/rdlock() never return
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=580498
|
||||
|
||||
Description:
|
||||
|
||||
Different behavior between RHEL5 and RHEL6 in both pthread_rwlock_timedwrlock()
|
||||
and pthread_rwlock_timedrdlock() functions.
|
||||
|
||||
If you call one of them with setting a negative number to abs_timeout->tv_sec,
|
||||
and a write lock to the specified rwlock has already been acquired by a different thread:
|
||||
|
||||
RHEL 5) the function returns with ETIMEDOUT errno, but
|
||||
RHEL 6) the function never return (spinning).
|
||||
|
||||
According to the man page and specs, EINVAL should be the return value on a negative timespec.
|
||||
|
||||
|
||||
EINVAL The value specified by rwlock does not refer to an initialized
|
||||
read-write lock object, or the abs_timeout nanosecond value is
|
||||
less than zero or greater than or equal to 1000 million.
|
||||
|
||||
|
||||
Apparently this change caused the issue:
|
||||
http://sourceware.org/ml/glibc-cvs/2009-q3/msg00036.html
|
@ -0,0 +1,39 @@
|
||||
summary: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)
|
||||
description: |
|
||||
Bug summary: pthread_rwlock_timedwrlock/rdlock() never return
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=580498
|
||||
|
||||
Description:
|
||||
|
||||
Different behavior between RHEL5 and RHEL6 in both pthread_rwlock_timedwrlock()
|
||||
and pthread_rwlock_timedrdlock() functions.
|
||||
|
||||
If you call one of them with setting a negative number to abs_timeout->tv_sec,
|
||||
and a write lock to the specified rwlock has already been acquired by a different thread:
|
||||
|
||||
RHEL 5) the function returns with ETIMEDOUT errno, but
|
||||
RHEL 6) the function never return (spinning).
|
||||
|
||||
According to the man page and specs, EINVAL should be the return value on a negative timespec.
|
||||
|
||||
|
||||
EINVAL The value specified by rwlock does not refer to an initialized
|
||||
read-write lock object, or the abs_timeout nanosecond value is
|
||||
less than zero or greater than or equal to 1000 million.
|
||||
|
||||
|
||||
Apparently this change caused the issue:
|
||||
http://sourceware.org/ml/glibc-cvs/2009-q3/msg00036.html
|
||||
contact: Miroslav Franc <mfranc@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
- gcc
|
||||
duration: 15m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=580498
|
||||
extra-summary: /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
||||
extra-task: /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
pthread_rwlock_t rwlock;
|
||||
|
||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
|
||||
(ts)->tv_sec = (tv)->tv_sec; \
|
||||
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||
}
|
||||
|
||||
void * func()
|
||||
{
|
||||
int ret = 0;
|
||||
struct timeval tv;
|
||||
struct timespec ts;
|
||||
|
||||
(void)gettimeofday(&tv, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&tv, &ts);
|
||||
|
||||
ts.tv_sec = -1;
|
||||
|
||||
ret = pthread_rwlock_timedwrlock(&rwlock, &ts);
|
||||
if (ret == ETIMEDOUT) {
|
||||
printf("pthread_rwlock_timedwrlock:TIME OUT.\n");
|
||||
pthread_exit(0);
|
||||
} else if (ret == EINVAL) {
|
||||
printf("pthread_rwlock_timedwrlock:INVALID ARG.\n");
|
||||
pthread_exit(0);
|
||||
}
|
||||
printf("pthread_rwlock_timedwrlock:return = %d\n", ret);
|
||||
pthread_exit(0);
|
||||
}
|
||||
|
||||
int main(int argv, char *argc[])
|
||||
{
|
||||
pthread_t tid;
|
||||
|
||||
if (pthread_rwlock_init(&rwlock, NULL) != 0) {
|
||||
printf("pthread_rwlock_init error\n");
|
||||
exit(-1);
|
||||
}
|
||||
pthread_rwlock_wrlock(&rwlock);
|
||||
pthread_create(&tid, NULL, func, NULL);
|
||||
pthread_join(tid, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz580498-pthread-rwlock-timedwrlock-rdlock-never-return
|
||||
# Description: Test for bz580498 (pthread_rwlock_timedwrlock/rdlock() never return)
|
||||
# Author: Miroslav Franc <mfranc@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2011 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
PACKAGE0="gcc"
|
||||
SOURCEFILE="pthread_rwlock_timedwrlock.c"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlAssertRpm $PACKAGE0
|
||||
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
|
||||
rlRun "cp $SOURCEFILE $TmpDir" 0 "Copying reproducer $SOURCEFILE into $TmpDir"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlRun "gcc -o pthread_rwlock_timedwrlock_a.out $SOURCEFILE -lpthread"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
./pthread_rwlock_timedwrlock_a.out > log &
|
||||
pidaout=$!
|
||||
# poor man's watchdog, cannot rely on beakerlib on this one
|
||||
sleep 5
|
||||
if test -d /proc/$pidaout &&
|
||||
test "`cat /proc/$pidaout/cmdline`" = "./pthread_rwlock_timedwrlock_a.out"; then
|
||||
rlFail "Fuction should return and errno=ETIMEDOUT (not returning anything, it's spinning instead)"
|
||||
kill -9 $pidaout
|
||||
elif grep -q 'TIME OUT' log; then
|
||||
rlPass "Fuction should return and errno=ETIMEDOUT"
|
||||
else
|
||||
ReprOut=`cat log`
|
||||
rlFail "Fuction should return and errno=ETIMEDOUT ($ReprOut)"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
66
tests/Regression/bz585674-free-race-in-mcheck-hooks/Makefile
Normal file
66
tests/Regression/bz585674-free-race-in-mcheck-hooks/Makefile
Normal file
@ -0,0 +1,66 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
||||
# Description: Test for bz585674 (free() race in mcheck hooks)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE malloc_check.c
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Muller <pmuller@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz585674 (free() race in mcheck hooks)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 90m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc" >> $(METADATA)
|
||||
@echo "Requires: gcc" >> $(METADATA)
|
||||
@echo "Requires: libgomp" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 585674" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
49
tests/Regression/bz585674-free-race-in-mcheck-hooks/PURPOSE
Normal file
49
tests/Regression/bz585674-free-race-in-mcheck-hooks/PURPOSE
Normal file
@ -0,0 +1,49 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
||||
Description: Test for bz585674 (free() race in mcheck hooks)
|
||||
Author: Petr Muller <pmuller@redhat.com>
|
||||
Bug summary: free() race in mcheck hooks
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=585674
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
segfaults can occur with MEMCHECK_ALLOC_=3 enabled. This was reported and fixed upstream at
|
||||
http://sourceware.org/bugzilla/show_bug.cgi?id=10282
|
||||
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc49a5a8837be1f9307b167d9bf4399798a847c9
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.5-49
|
||||
|
||||
How reproducible:
|
||||
every time
|
||||
|
||||
Steps to Reproduce:
|
||||
1. cat malloc_test.c
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#pragma omp parallel num_threads(256)
|
||||
while (1) {
|
||||
void *ptr = malloc(rand() % 65536);
|
||||
usleep((rand() % 100) * 100);
|
||||
free(ptr);
|
||||
usleep((rand() % 100) * 100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
2. gcc -fopenmp -g -o malloc_check malloc_check.c
|
||||
|
||||
3. MALLOC_CHECK_=3 ./malloc_test
|
||||
|
||||
Actual results:
|
||||
malloc: using debugging hooks
|
||||
*** glibc detected *** ./malloc_test: free(): invalid pointer: 0x00000000043e9c90 ***
|
||||
|
||||
|
||||
Expected results:
|
||||
no segfaults
|
||||
|
||||
Additional info:
|
62
tests/Regression/bz585674-free-race-in-mcheck-hooks/main.fmf
Normal file
62
tests/Regression/bz585674-free-race-in-mcheck-hooks/main.fmf
Normal file
@ -0,0 +1,62 @@
|
||||
summary: Test for bz585674 (free() race in mcheck hooks)
|
||||
description: |
|
||||
Bug summary: free() race in mcheck hooks
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=585674
|
||||
|
||||
Description:
|
||||
|
||||
Description of problem:
|
||||
segfaults can occur with MEMCHECK_ALLOC_=3 enabled. This was reported and fixed upstream at
|
||||
http://sourceware.org/bugzilla/show_bug.cgi?id=10282
|
||||
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc49a5a8837be1f9307b167d9bf4399798a847c9
|
||||
|
||||
Version-Release number of selected component (if applicable):
|
||||
glibc-2.5-49
|
||||
|
||||
How reproducible:
|
||||
every time
|
||||
|
||||
Steps to Reproduce:
|
||||
1. cat malloc_test.c
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#pragma omp parallel num_threads(256)
|
||||
while (1) {
|
||||
void *ptr = malloc(rand() % 65536);
|
||||
usleep((rand() % 100) * 100);
|
||||
free(ptr);
|
||||
usleep((rand() % 100) * 100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
2. gcc -fopenmp -g -o malloc_check malloc_check.c
|
||||
|
||||
3. MALLOC_CHECK_=3 ./malloc_test
|
||||
|
||||
Actual results:
|
||||
malloc: using debugging hooks
|
||||
*** glibc detected *** ./malloc_test: free(): invalid pointer: 0x00000000043e9c90 ***
|
||||
|
||||
|
||||
Expected results:
|
||||
no segfaults
|
||||
|
||||
Additional info:
|
||||
contact: Petr Muller <pmuller@redhat.com>
|
||||
component:
|
||||
- glibc
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
recommend:
|
||||
- glibc
|
||||
- gcc
|
||||
- libgomp
|
||||
duration: 90m
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=585674
|
||||
extra-summary: /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
||||
extra-task: /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
@ -0,0 +1,20 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned int i;
|
||||
#pragma omp parallel num_threads(256) private(i)
|
||||
{
|
||||
i = 1;
|
||||
while (i != 2000) {
|
||||
void *ptr = malloc(rand() % 65536);
|
||||
usleep((rand() % 100) * 100);
|
||||
free(ptr);
|
||||
usleep((rand() % 100) * 100);
|
||||
i++;
|
||||
}
|
||||
#pragma omp barrier
|
||||
}
|
||||
return 0;
|
||||
}
|
57
tests/Regression/bz585674-free-race-in-mcheck-hooks/runtest.sh
Executable file
57
tests/Regression/bz585674-free-race-in-mcheck-hooks/runtest.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /tools/glibc/Regression/bz585674-free-race-in-mcheck-hooks
|
||||
# Description: Test for bz585674 (free() race in mcheck hooks)
|
||||
# Author: Petr Muller <pmuller@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="glibc"
|
||||
TESTPROG="malloc_check"
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup
|
||||
rlRun "TESTTMPDIR=$(mktemp -d)"
|
||||
rlRun "cp ${TESTPROG}.c $TESTTMPDIR"
|
||||
rlRun "pushd $TESTTMPDIR"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlRun -c "gcc ${TESTPROG}.c -o $TESTPROG -g -fopenmp"
|
||||
export MALLOC_CHECK_=3
|
||||
for i in `seq 10`
|
||||
do
|
||||
rlRun -c "./${TESTPROG}" 0 "Testcase attempt $i"
|
||||
done
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TESTTMPDIR"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
@ -0,0 +1,64 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs
|
||||
# Description: Test for bz587360 (Pattern matching of digraphs differs across archs)
|
||||
# Author: Petr Splichal <psplicha@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Petr Splichal <psplicha@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test for bz587360 (Pattern matching of digraphs differs across archs)" >> $(METADATA)
|
||||
@echo "Type: Regression" >> $(METADATA)
|
||||
@echo "TestTime: 15m" >> $(METADATA)
|
||||
@echo "RunFor: glibc" >> $(METADATA)
|
||||
@echo "Requires: glibc glibc-langpack-cs" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Bug: 587360" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
@ -0,0 +1,16 @@
|
||||
PURPOSE of /tools/glibc/Regression/bz587360-digraph-matching-differs-across-archs
|
||||
Description: Test for bz587360 (Pattern matching of digraphs differs across archs)
|
||||
Author: Petr Splichal <psplicha@redhat.com>
|
||||
Bug summary: Pattern matching of digraphs inconsistent and differs across architectures
|
||||
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=587360
|
||||
|
||||
Description:
|
||||
|
||||
The "ch" character is treated strangely by the latest sed while
|
||||
in the Czech locale. Seems to be a glibc issue. I was able to
|
||||
reproduce it on s390x & ppc only.
|
||||
|
||||
The test was updated because of new behaviour or glibc-2.28 (and RHEL8
|
||||
accordingly). For more information:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1653745
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1601681
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user