A probable bug in WCSLIB is causing wcscopy to create copies of Wcs objects which are not the same as the object that was copied. In some cases when this object is passed to wcsset it fails, as the Wcs object contains impossible values.
This has behaviour is non-deterministic (failure is only seen occasionally). The error has only been observed on OSX, but we do not believe it to be operating system dependent (except insofar as different systems and compilers produce different memory layouts and hence different failure modes). This reliably causes ci_hsc to fail when running on a Mac.
Relevant lines in afw are image/Wcs.cc:140 and the Wcs copy constructor in image/Wcs.cc:468
Additionally a bug has been found in image/Wcs.cc on line 485 where the flag property should be set on an element, and not on the object itself, ie _wcsInfo[i]->flag = -1;.