<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><div id="yiv1184335336">Hi Mika,<br>cur should be type ProtocolFields.T if the NARROW doesn't crash the app,<br><pre>887 cur =<br> NARROW(seq.get(i.nextI),ProtocolFields.T)</pre>(that works if seq.get(i.nextI) is a member of ProtocolFields.T) however could be possible that the assignment statement in line 890 is failing and because of the TRY-FINALLY you don't get a Runtime Error (which would be the ideal behaviour if the MODULE is safe and correspondent IMPORT Modules aren't ill behaved ).<br><pre>890 f := cur; RETURN TRUE</pre>You could make a sanity check before that line with<br> <tt>ISTYPE(cur, FIXField.T) (</tt>*is cur a member of f's type, FIXField.T *<tt>) </tt> <br><br>Please feel free to ask further questions.<br>Hope this helps. Thanks.<br><br>--- El <b>sáb, 14/2/09, Mika Nystrom
<i><mika@async.caltech.edu></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">De: Mika Nystrom <mika@async.caltech.edu><br>Asunto: [M3devel] Question about PM3<br>Para: m3devel@elegosoft.com<br>Fecha: sábado, 14 febrero, 2009 1:10<br><br><pre>Dear Modula-3-ers:<br><br>I'm going to ask a question about an old, obsolete piece<br> of software, and<br>don't expect anybody knows the answer, but would be grateful for any<br>insight:<br><br>I have a Modula-3 program compiled with one of the last releases of PM3<br>"FreeBSD4" running on a FreeBSD/i386 5.5 system. I have some code<br>that looks like this:<br><br>PROCEDURE UINext(i : UpIterator; VAR f : FIXField.T) : BOOLEAN =<br> VAR seq : FIXFieldSeq.T;<br> BEGIN<br> LOOP<br> (* update seq *)<br> seq := i.t.data[i.part];<br><br> (* first see if we are at end or pointing to an uninteresting part *)<br> (* seq
can be NIL on certain error conditions *)<br> IF seq # NIL THEN<br> IF i.nextI = seq.size() OR NOT i.part IN i.parts THEN<br> IF i.part = LAST(Part) THEN (* at bitter end *)<br> RETURN FALSE<br> ELSE<br> INC(i.part); i.nextI := 0<br> END<br> ELSE (* not at end, but in the middle of an interesting Part *)<br> WITH cur =<br> NARROW(seq.get(i.nextI),ProtocolFields.T) DO<br> TRY<br> IF cur.type() IN i.fields THEN (* nteresting field? *)<br> f := cur; RETURN TRUE<br> END<br> FINALLY<br> INC(i.nextI) (* in any case, advance to next *)<br> END<br> END<br> END<br> END<br> END<br> END UINext;<br><br>What I am seeing is the following<br><br>Program received signal SIGSEGV, Segmentation fault.<br>0x080be11c in M_FIXMsgSuper4_1_LINE_893 () at FIXMsgSuper.mg:893<br>#0 0x080be11c
in M_FIXMsgSuper4_1_LINE_893 () at FIXMsgSuper.mg:893<br>893 INC(i.nextI) (* in any case, advance to next *)<br>(m3gdb) list<br>888 TRY<br>889 IF cur.type() IN i.fields THEN (* nteresting field? *)<br>890 f := cur; RETURN TRUE<br>891 END<br>892 FINALLY<br>893 INC(i.nextI) (* in<br> any case, advance to next *)<br>894 END<br>895 END<br>896 END<br>897 END<br><br>The crash makes no sense, because "i" has already been dereferenced<br>several times before this, without problem.<br><br>(m3gdb) where<br>#0 0x080be11c in M_FIXMsgSuper4_1_LINE_893 () at FIXMsgSuper.mg:893<br>#1 0x080be26f in FIXMsgSuper4_1__UINext (i=16_0957a0d4, f=NIL) at<br>FIXMsgSuper.mg:890<br>#2 0x080be01c in FIXMsgSuper4_1__GetSingleField (t=16_09579ea8,<br>ofType=SenderCompID) at FIXMsgSuper.mg:846<br>#3
0x081087f3 in FIXMsg4_1__T_GetOnlySenderCompIDProc (self=16_09579ea8) at<br>FIXMsg4_1.m3:411<br>#4 0x080bef29 in FIXEngine4_1__SanityCheckFields (t=16_082a896c,<br>msg=16_09579ea8) at FIXEngine.mg:321<br><br>We're in some sort of "fake" stack frame, and...<br><br>(m3gdb) up<br>#1 0x080be26f in FIXMsgSuper4_1__UINext (i=16_0957a0d4, f=NIL) at<br>FIXMsgSuper.mg:890<br>890 f := cur; RETURN<br> TRUE<br>(m3gdb) print i<br>$2 = (*16_0957a0d4*) OBJECT t = 16_09579ea8; parts = {Header, Body, Trailer};<br>fields = {SenderCompID}; part = Body; <br> nextI = 0; END<br>(m3gdb) <br><br>everything looks OK with i.<br><br>Is it possible there is some sort of problem with TRY .. FINALLY under<br>PM3? And of course, if so, might it go away with CM3?<br><br> Mika<br><br><br></pre></blockquote></div></td></tr></table><br>