Privacy and Security Notice

Archived Messages for CDEV_1996@cebaf.gov: cdev 1.4 caService build errors

cdev 1.4 caService build errors

Peregrine McGehee (mcgehee@cfht.hawaii.edu)
Wed, 30 Oct 1996 13:16:38 -1000

Using g++ 2.7.2 under HPUX 9.05, I encountered scoping errors in six
channel access service layer routines.

File Method
---- -------
caChannel.cc ::addMonitorObj
::removeMonitorObj
caRequestObject.cc ::setValueCbk (two places)
::convertData
caService.cc ::addReadFd
::removeReadFd

The errors were all of the same form, illustrated here by the instance
in caService::addReadFd():

caService::addReadFd (int fd)
{
if (numFds_){
int *newfds = new int[numFds_ + 1];
for (int i =0; i < numFds_; i++)
newfds[i] = fds_[i];
delete []fds_;
newfds[i] = fd;
<snip>

While the compiler only generated warnings, the resultant program
crashed with a Bus Error within caService::removeReadFd() during
process exit handling - presumably due to garbage values with the
newfds[] array.

Declaring the loop index variables at the start of each method
corrects the problem.

Aloha,
Peregrine

-------------------------------------------------------------------------------
Peregrine M. McGehee http://www.cfht.hawaii.edu/~mcgehee
Telescope Control Systems Group Canada-France-Hawaii Telescope
(808) 885-3178 P.O. Box 1597, Kamuela, Hawaii 96743