Peter,
I've come across a really odd bug in EMS. It is not threading
related since I can see it in rev 27610 (the rev before the merge).
SMURF makes use of the fact that
msgSetc( "D", "Text1" );
msgSetc( "D", "Text2" );
msgOut(" ", "^D", status);
can be used to concatenate strings. I'm not sure when this broke (I
assume it used to work since otherwise Andy wouldn't have done it) and
how the breakage occurred but I have boiled it down to a test case in
mers/err_ftest.f. The bottom line is that if you do
errBegin
msgSetc
msgSetc
msgSetc
msgOut
only the last 2 Setc functions have any affect on the token. Things
work again after the errEnd. errMark and errRlse do not have the
problem. I noticed this because SMURF got a spurious errBegin turning
up without a matching errEnd.
CALL MSG_SETC('D', 'A')
CALL MSG_SETC('D', 'B')
CALL MSG_SETC('D', 'C')
CALL MSG_SETC('D', 'D')
CALL MSG_SETC('D', 'E')
CALL MSG_OUT( ' ','Should be ABCDE - ^D', STATUS)
CALL ERR_BEGIN( STATUS )
CALL ERR_MARK
CALL MSG_SETC('D', 'A')
CALL MSG_SETC('D', 'B')
CALL MSG_SETC('D', 'C')
CALL MSG_SETC('D', 'D')
CALL MSG_SETC('D', 'E')
CALL MSG_OUT( ' ','Should be ABCDE - ^D', STATUS)
CALL ERR_RLSE
CALL MSG_SETC('D', 'A')
CALL MSG_SETC('D', 'B')
CALL MSG_SETC('D', 'C')
CALL MSG_SETC('D', 'D')
CALL MSG_SETC('D', 'E')
CALL MSG_OUT( ' ','Should be ABCDE - ^D', STATUS)
CALL MSG_SETC('D', 'A')
CALL MSG_SETC('D', 'B')
CALL MSG_SETC('D', 'C')
CALL MSG_SETC('D', 'D')
CALL MSG_SETC('D', 'E')
CALL MSG_OUT( ' ','Should be ABCDE - ^D', STATUS)
CALL ERR_END( STATUS )
CALL MSG_SETC('D', 'A')
CALL MSG_SETC('D', 'B')
CALL MSG_SETC('D', 'C')
CALL MSG_SETC('D', 'D')
CALL MSG_SETC('D', 'E')
CALL MSG_OUT( ' ','Should be ABCDE - ^D', STATUS)
and you get as output:
Should be ABCDE - ABCDE <--- errBegin after here
Should be ABCDE - ABCDE <--- errMark and errRlse around here
Should be ABCDE - ABCDE
Should be ABCDE - BCDE <--- errEnd after this
Should be ABCDE - ABCDE
removing the errMark/Rlse gives you
Should be ABCDE - ABCDE
Should be ABCDE - ABCDE
Should be ABCDE - BCDE
Should be ABCDE - BCDE
Should be ABCDE - ABCDE
Oddly, using two errBegin calls in a row fixes the problem. Note that
it is only the second set of msgSetc+msgOut that trigger the problem.
The first one after the errBegin is ok.
If I call msgSetc a differing number of times I get:
A A
AB B
ABC BC
at some point I managed to get it to drop the first two but I can't
reproduce that.
As I said, calling errBegin 3 times is fine. 2 times is fine. It's
only the first that breaks things. (and I have realised that smurf
only called errBegin by mistake - we had not put it in smurf_mon, not
sure if it is required or if ADAM was doing it)
(Which is odd because the SMURF problem is triggered by the second
errBegin).
I haven't done this test in EMS but it's only calling EMS routines.
The old fortran MERS suffers from the same problem. Valgrind gives me
nothing.
Any thoughts?
--
Tim Jenness
Joint Astronomy Centre
|