From 72745d7b0ccfea6a77c4751b9d65321059d5472b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 29 Apr 2016 16:20:25 -0500 Subject: [PATCH 1/6] Only make runtests and tapfiles if T_A = EPICS_HOST_ARCH --- configure/RULES_BUILD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index 1528c48d5..ad5e76f4f 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -338,7 +338,9 @@ $(MODNAME): %$(MODEXT): %$(EXE) $(LINK.mod) runtests: $(TESTSCRIPTS) +ifeq ($(T_A),$(EPICS_HOST_ARCH)) -$(PERL) -MTest::Harness -e 'runtests @ARGV if @ARGV;' $^ +endif testspec: $(TESTSCRIPTS) @$(RM) $@ @@ -351,7 +353,9 @@ tapfiles: $(TESTSCRIPTS) $(TAPFILES) # A .tap file is the output from running the associated test script %.tap: %.t +ifeq ($(T_A),$(EPICS_HOST_ARCH)) -$(PERL) $< -tap > $@ +endif # If there's a perl test script (.plt) available, use it %.t: ../%.plt From 51dd3717846204e82905e753770c911490b47815 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 26 Apr 2016 17:06:22 -0400 Subject: [PATCH 2/6] rsrv: add rsrvCS_shutdown to avoid race in destroyAllChannels() A race can occur between rsrv and cac by way of asLib whereby casAccessRightsCB() is called after a channel_in_use has been removed from chanList/chanPendingUpdateARList. casAccessRightsCB() would then attempt to remove the node again, causing corruption. Create a new rsrvCS_shutdown state when the channel is not in either list. Attempt to resolve lp:1571224 --- src/rsrv/camessage.c | 10 +++++++++- src/rsrv/caservertask.c | 1 + src/rsrv/server.h | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/rsrv/camessage.c b/src/rsrv/camessage.c index e6c4330ab..800d90810 100644 --- a/src/rsrv/camessage.c +++ b/src/rsrv/camessage.c @@ -1072,7 +1072,7 @@ unsigned cid * casAccessRightsCB() * * If access right state changes then inform the client. - * + * asLock is held */ static void casAccessRightsCB(ASCLIENTPVT ascpvt, asClientStatus type) { @@ -1521,6 +1521,9 @@ static void sendAllUpdateAS ( struct client *client ) else if ( pciu->state == rsrvCS_inServiceUpdatePendAR ) { access_rights_reply ( pciu ); } + else if ( pciu->state == rsrvCS_shutdown ) { + /* no-op */ + } else { errlogPrintf ( "%s at %d: corrupt channel state detected durring AR update\n", @@ -2003,10 +2006,15 @@ static int clear_channel_reply ( caHdrLargeArray *mp, if ( pciu->state == rsrvCS_inService || pciu->state == rsrvCS_pendConnectResp ) { ellDelete ( &client->chanList, &pciu->node ); + pciu->state = rsrvCS_shutdown; } else if ( pciu->state == rsrvCS_inServiceUpdatePendAR || pciu->state == rsrvCS_pendConnectRespUpdatePendAR ) { ellDelete ( &client->chanPendingUpdateARList, &pciu->node ); + pciu->state = rsrvCS_shutdown; + } + else if ( pciu->state == rsrvCS_shutdown ) { + /* no-op */ } else { epicsMutexUnlock( client->chanListLock ); diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index 7c911d64b..7eef1d200 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -622,6 +622,7 @@ static void destroyAllChannels ( epicsMutexMustLock ( client->chanListLock ); pciu = (struct channel_in_use *) ellGet ( pList ); + if(pciu) pciu->state = rsrvCS_shutdown; epicsMutexUnlock ( client->chanListLock ); if ( ! pciu ) { diff --git a/src/rsrv/server.h b/src/rsrv/server.h index 9c222d09b..fc7627f80 100644 --- a/src/rsrv/server.h +++ b/src/rsrv/server.h @@ -98,12 +98,25 @@ typedef struct client { char disconnect; /* disconnect detected */ } client; +/* Channel state shows which struct client list a + * channel_in_us::node is in. + * + * client::chanList + * rsrvCS_pendConnectResp, rsrvCS_inService + * client::chanPendingUpdateARList + * rsrvCS_pendConnectRespUpdatePendAR, rsrvCS_inServiceUpdatePendAR + * Not in any list + * rsrvCS_shutdown + * + * rsrvCS_invalid is not used + */ enum rsrvChanState { rsrvCS_invalid, rsrvCS_pendConnectResp, rsrvCS_inService, rsrvCS_pendConnectRespUpdatePendAR, - rsrvCS_inServiceUpdatePendAR + rsrvCS_inServiceUpdatePendAR, + rsrvCS_shutdown }; /* From 67097456e33cac9f33af0673c4ee5daa7fe09272 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 3 May 2016 12:26:40 -0500 Subject: [PATCH 3/6] Add additional RELEASE file checks These checks are important for mixing Debian modules with privately-built applications. --- documentation/RELEASE_NOTES.html | 35 ++++++++++++++++++++++++++++++++ src/tools/convertRelease.pl | 32 +++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 68463ab7e..f4370c22f 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,41 @@ +

Additional RELEASE file checks

+ +

An additional check has been added at build-time for the contents of the +configure/RELEASE file(s), which will mostly only affect users of the Debian +EPICS packages published by NSLS-2. Support modules may share an install path, +but all such modules must be listed adjacent to each other in any RELEASE files +that point to them. For example the following will fail the new checks:

+ +
+AUTOSAVE = /usr/lib/epics
+ASYN = /home/mdavidsaver/asyn
+EPICS_BASE = /usr/lib/epics
+
+ +

giving the compile-time error

+ +
+This application's RELEASE file(s) define
+	EPICS_BASE = /usr/lib/epics
+after but not adjacent to
+	AUTOSAVE = /usr/lib/epics
+Module definitions that share paths must be grouped together.
+Either remove a definition, or move it to a line immediately
+above or below the other(s).
+Any non-module definitions belong in configure/CONFIG_SITE.
+
+ + +

In many cases such as the one above the order of the AUTOSAVE and +ASYN lines can be swapped to let the checks pass, but if the +AUTOSAVE module depended on ASYN and hence had to appear +before it in the list this error indicates that AUTOSAVE should also be +built in its own private area; a shared copy would likely be incompatible with +the version of ASYN built in the home directory.

+

String field buffer overflows

Two buffer overflow bugs that can crash the IOC have been fixed, caused by diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index abf63c3ec..772ce1112 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -217,7 +217,7 @@ sub checkRelease { delete $macros{RULES}; delete $macros{TOP}; delete $macros{TEMPLATE_TOP}; - + while (my ($app, $path) = each %macros) { my %check = (TOP => $path); my @order = (); @@ -240,7 +240,35 @@ sub checkRelease { } } } - print "\n" if ($status); + + my @modules = @apps; + my $app = shift @modules; + my $latest = AbsPath($macros{$app}); + my %paths = ($latest => $app); + foreach $app (@modules) { + my $path = AbsPath($macros{$app}); + if ($path ne $latest && exists $paths{$path}) { + my $prev = $paths{$path}; + print "\n" unless ($status); + print "This application's RELEASE file(s) define\n"; + print "\t$app = $macros{$app}\n"; + print "after but not adjacent to\n\t$prev = $macros{$prev}\n"; + print "both of which resolve to $path\n" + if $path ne $macros{$app} || $path ne $macros{$prev}; + $status = 2; + } + $paths{$path} = $app; + $latest = $path; + } + if ($status == 2) { + print "Module definitions that share paths must be grouped together.\n"; + print "Either remove a definition, or move it to a line immediately\n"; + print "above or below the other(s).\n"; + print "Any non-module definitions belong in configure/CONFIG_SITE.\n"; + $status = 1; + } + + print "\n" if $status; exit $status; } From 3be97865b3cc060400dc5ddaff891a1400c1e885 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 4 May 2016 14:41:51 -0500 Subject: [PATCH 4/6] Warn instead of building cap5 if xsubpp is missing --- src/cap5/Makefile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cap5/Makefile b/src/cap5/Makefile index 41c66a51c..f749864c5 100644 --- a/src/cap5/Makefile +++ b/src/cap5/Makefile @@ -21,10 +21,19 @@ ifeq ($(OS_CLASS),Darwin) LOADABLE_SHRLIB_SUFFIX = .$(shell $(PERL) ../perlConfig.pl dlext) endif -PERL_VERSION = $(shell $(PERL) ../perlConfig.pl version) -PERL_ARCHNAME = $(shell $(PERL) ../perlConfig.pl archname) -PERL_ARCHPATH = $(PERL_VERSION)/$(PERL_ARCHNAME) +ifdef T_A + PERL_VERSION = $(shell $(PERL) ../perlConfig.pl version) + PERL_ARCHNAME = $(shell $(PERL) ../perlConfig.pl archname) + PERL_ARCHPATH := $(PERL_VERSION)/$(PERL_ARCHNAME) + EXTUTILS := $(shell $(PERL) ../perlConfig.pl privlib)/ExtUtils + PERLBIN := $(shell $(PERL) ../perlConfig.pl bin) + XSUBPP := $(firstword $(wildcard $(PERLBIN)/xsubpp $(EXTUTILS)/xsubpp)) + +ifeq ($(strip $(XSUBPP)),) + $(warning Perl's xsubpp program was not found.) + $(warning The Perl CA module will not be built.) +else ifeq ($(T_A),$(EPICS_HOST_ARCH)) # No cross-builds (wrong Perl!) ifeq ($(findstring $(OS_CLASS),WIN32 cygwin32),) # Doesn't build on WIN32 LOADABLE_LIBRARY_HOST = Cap5 @@ -42,6 +51,8 @@ ifeq ($(findstring $(OS_CLASS),WIN32 cygwin32),) # Doesn't build on WIN32 HTMLS = CA.html endif endif +endif +endif Cap5_SRCS = Cap5.xs Cap5_LIBS = ca Com @@ -51,10 +62,6 @@ Cap5_CFLAGS = $(shell $(PERL) ../perlConfig.pl ccflags) include $(TOP)/configure/RULES ifdef T_A - EXTUTILS = $(shell $(PERL) ../perlConfig.pl privlib)/ExtUtils - PERLBIN = $(shell $(PERL) ../perlConfig.pl bin) - XSUBPP = $(firstword $(wildcard $(PERLBIN)/xsubpp $(EXTUTILS)/xsubpp)) - %.c: ../%.xs $(RM) $@ $@_new $(PERL) $(XSUBPP) -typemap $(EXTUTILS)/typemap $< > $@_new && $(MV) $@_new $@ From 9b51444fb720d5285ebec1843f83dd7ba12cd4cc Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 4 May 2016 18:15:54 -0500 Subject: [PATCH 5/6] Fix data types and macro name --- src/db/db_field_log.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/db/db_field_log.h b/src/db/db_field_log.h index 2012f49f6..9b2661c88 100644 --- a/src/db/db_field_log.h +++ b/src/db/db_field_log.h @@ -3,8 +3,7 @@ * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found +* EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* $Revision-Id$ @@ -14,6 +13,8 @@ #ifndef INCLdb_field_logh #define INCLdb_field_logh +#include + #ifdef __cplusplus extern "C" { #endif @@ -25,18 +26,20 @@ extern "C" { * priority task pending on the event queue wakes up). Strings would slow down * events for more reasonable size values. DB fields of native type string * will most likely change infrequently. - * + * + * Strings can be added to the set of types for which updates will be queued + * by defining the macro DB_EVENT_LOG_STRINGS. The code in db_add_event() + * will adjust automatically, it just compares field sizes. */ union native_value{ - short dbf_int; - short dbf_short; - float dbf_float; - short dbf_enum; - char dbf_char; - long dbf_long; - double dbf_double; + epicsInt8 dbf_char; + epicsInt16 dbf_short; + epicsEnum16 dbf_enum; + epicsInt32 dbf_long; + epicsFloat32 dbf_float; + epicsFloat64 dbf_double; #ifdef DB_EVENT_LOG_STRINGS - char dbf_string[MAXSTRINGSIZE]; + char dbf_string[MAX_STRING_SIZE]; #endif }; From 6db0e13809470ea83a7f6d39c938dd2b66e4e9ff Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 13 May 2016 13:00:48 -0500 Subject: [PATCH 6/6] Added CROSS_COMPILER_RUNTEST_ARCHS --- configure/CONFIG_SITE | 7 +++++++ configure/RULES_BUILD | 4 ++-- documentation/RELEASE_NOTES.html | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 3063a993f..84301a0f7 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -122,6 +122,13 @@ CROSS_COMPILER_TARGET_ARCHS= # CROSS_COMPILER_HOST_ARCHS= +# The 'make runtests' and 'make tapfiles' build targets normally only run +# self-tests for the EPICS_HOST_ARCH architecture. If the host can execute +# the self-test programs for any other cross-built architectures such as +# a -debug architecture, those architectures can be named here. +# +CROSS_COMPILER_RUNTEST_ARCHS= + # Build shared libraries? # must be either YES or NO # NOTE: os/CONFIG.$(EPICS_HOST_ARCH).$(EPICS_HOST_ARCH) files and diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index ad5e76f4f..7b7ac07dc 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -338,7 +338,7 @@ $(MODNAME): %$(MODEXT): %$(EXE) $(LINK.mod) runtests: $(TESTSCRIPTS) -ifeq ($(T_A),$(EPICS_HOST_ARCH)) +ifneq (,$(findstring $(T_A),$(EPICS_HOST_ARCH) $(CROSS_COMPILER_RUNTEST_ARCHS))) -$(PERL) -MTest::Harness -e 'runtests @ARGV if @ARGV;' $^ endif @@ -353,7 +353,7 @@ tapfiles: $(TESTSCRIPTS) $(TAPFILES) # A .tap file is the output from running the associated test script %.tap: %.t -ifeq ($(T_A),$(EPICS_HOST_ARCH)) +ifneq (,$(findstring $(T_A),$(EPICS_HOST_ARCH) $(CROSS_COMPILER_RUNTEST_ARCHS))) -$(PERL) $< -tap > $@ endif diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index f4370c22f..d6e89cc60 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,18 @@ +

New CONFIG_SITE variable for running self-tests

+ +

The 'make runtests' and 'make tapfiles' build targets normally only run the +self-tests for the main EPICS_HOST_ARCH architecture. If the host is +able to execute self-test programs for other target architectures that are being +built by the host, such as when building a -debug version of the host +architecture for example, the names of those other architectures can be added to +the new CROSS_COMPILER_RUNTEST_ARCHS variable in either the +configure/CONFIG_SITE file or in an appropriate +configure/os/CONFIG_SITE.<host>.Common file to have the test +programs for those targets be run as well.

+

Additional RELEASE file checks

An additional check has been added at build-time for the contents of the