Subj : An order or linking bug To : borland.public.cpp.borlandcpp From : David Morris Date : Thu Dec 09 2004 11:32 pm Last week I posted l problem I was having in "bcc 5.02 command line v. ide", in which I was trying to eliminate a bug which had popped up as I was converting from the IDE to hand coded make files. The problem turned out to manifest itself because of the order in which I was linking the three libraries (as well as the standard ones for the DOS large model). I fixed it by just linking the ASYNC routines ahead of the bulk of the libraries. The problem occurred in an Interrupt Service Routine for a serial port (in asm). A circular buffer queue seemed to have the pointers change to spurious values (resulting in a negative number of characters in the buffer) on a non predictable but eventual occasion. It is possible that this happened as the queue rolled over. I had thought that this was due to a buffer over run, but by placing some marker characters around these pointers, I showed that it was not a buffer over-run. I also tried forcing the DS register to point to the data segment (this made no difference). It would seem that this problem only occurs if the ISR data is not near the beginning of the DATAS segment. For example by moving some data in to the uninitialised segment BSS (all still in the DGROUP), the problem goes away. BTW The queue variables (RecHead and RecTail) are not public. Other than that I don't really have a clue. The code is large enough to have linked in a lot of object modules from the Borland libraries as well as mine. The DOS executable is 340K and includes (my own) overlay code for a PABX driver module. Once I change the order of the libraries there doesn't seem to be a problem, and the code has literally worked elsewhere for years, so I think this really has fixed the problem, and there are no longer any hidden gotchas.... ....But I would like to know why it occurred in the first place? Any clues? regards DM .