<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi all:<br>reading through the green book chapter on IO streams, p160, it seems, there should not be such a range violation cause its actually allowed to be NIL (see ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/abstracts/src-rr-053.html<br>p 30 and above) so this must be related to the fact there is some missing a conditional if so as it is unsafely checked by the compiler, but it might not be necessarily that, I mean unsafe perse, but in that case just for that may get a RT error unneeded to argue for that (i.e it might not), indeed most of the crashes might come by this classes, but as I read TextWr seek method style was to raise an unlisted exception which is by itself a RT error as a policy, however subclasses of Rd.T must be aware of their obligations that is, they have invariants so we could check for those I believe they
are there in safe MODULES (as I think is checked already) and manner that is even as one could argue in UNSAFE modules they hold (if they don't hold just the first case), we could if this is really broken get it in safe modules to check for them in an ESC, actually first RW lib was absolutely according to their comments unsafe for speed performance but after crashed many times decided to made safe interfaces to look for those kind of errors. So it might be need a middle layer not UNSAFE module of FileRd INTERFACE to look for those errors closely, e.g implement that method failing (FileRd.seek) and related safely and check them by ESC.<br>Specifically from the three invariants the most feasible mentioned in RdClass interface which might be not be satisfied and should be checked in a debugger is the first of the three (because would cause same RT error shown there):<br>rd is valid if =><br>[rd.lo .. rd.hi-i] <br>where i can be 0 and so buff=NIL, <br>so
its possible though would need confirmation a breakpoint there in line FileRd.m3:83 to see rd.buff<br>the others that come after this, <br>cur(rd) = MIN(rd.cur, len(rd))<br>from what<br>rd.cur>len(rd) or rd.cur = len(rd)<br>and third:<br>NOT (rd.intermittent AND rd.seekable)<br>That said I would recommend the latter method a mechanic debugger meanwhile, tough if positive we would follow the guideline of Greg and the gang to specify it in a safe module, at least the method. Then in an automatic debugger might help to proof that for us too if so.<br>Indeed there are more classes of invariants there for declare clean and also private invariants too. Will check for that too. <br>Thanks in advance<br><br>--- El <b>jue, 17/3/11, Coleburn, Randy <i><rcolebur@SCIRES.COM></i></b> escribió:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>De: Coleburn, Randy
<rcolebur@SCIRES.COM><br>Asunto: Re: [M3devel] thread test results on Win7 64-bit<br>Para: "m3devel" <m3devel@elegosoft.com><br>Fecha: jueves, 17 de marzo, 2011 14:46<br><br><div id="yiv235295595"><style><!--
#yiv235295595
_filtered #yiv235295595 {font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;}
_filtered #yiv235295595 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
_filtered #yiv235295595 {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
#yiv235295595
#yiv235295595 p.yiv235295595MsoNormal, #yiv235295595 li.yiv235295595MsoNormal, #yiv235295595 div.yiv235295595MsoNormal
{margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv235295595 a:link, #yiv235295595 span.yiv235295595MsoHyperlink
{color:blue;text-decoration:underline;}
#yiv235295595 a:visited, #yiv235295595 span.yiv235295595MsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
#yiv235295595 p.yiv235295595MsoListParagraph, #yiv235295595 li.yiv235295595MsoListParagraph, #yiv235295595 div.yiv235295595MsoListParagraph
{margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"serif";}
#yiv235295595 span.yiv235295595apple-style-span
{}
#yiv235295595 span.yiv235295595EmailStyle19
{font-family:"sans-serif";color:#1F497D;}
#yiv235295595 .yiv235295595MsoChpDefault
{font-size:10.0pt;}
_filtered #yiv235295595 {margin:1.0in 1.0in 1.0in 1.0in;}
#yiv235295595 div.yiv235295595WordSection1
{}
#yiv235295595
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
_filtered #yiv235295595 {}
#yiv235295595 ol
{margin-bottom:0in;}
#yiv235295595 ul
{margin-bottom:0in;}
--></style><div class="yiv235295595WordSection1"><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Tony et al:</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">On the surface, it would seem this convoluted code is doing the following:</span></p><p class="yiv235295595MsoListParagraph" style=""><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
</span></span></span><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Making rd.buff appear as an “ARRAY OF <b>Byte</b>”, vice an “ARRAY OF <b>CHAR</b>, so as to meet the requirements of the File.T.read interface.</span></p><p class="yiv235295595MsoListParagraph" style=""><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"><span style="">2.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Limiting the buffer to be the smaller of “BIG”, or the actual number of elements in rd.buff</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family:
"sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Now, re #2, the code in FileRd seems to allocate buffers in 4096-char arrays, and BIG is 16M, so I don’t quite see why the need to ensure the buffer is limited to no more than BIG, as it should never be more than 4096.</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">All that aside, are you concerned that the GC could be relocating rd.buff after its address is obtained and fed to the File.T.read (rd.sourceH.read) procedure?</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif";
color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">If indeed this movement can occur, this code definitely needs to change.</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">How can we force the GC not to move rd.buff, or is there another “safe” way to make rd.buff appear as an “ARRAY OF Byte” to satisfy the File.T.read interface?</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73,
125);">Buffers are allocated in line #45 as a <u>traced</u> reference to an ARRAY OF CHAR via:</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> rd.buff := NEW(CharBuffer, BufferSize);</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Yet, the ByteArrayPtr in FileRd.m3 (line 25) is an <u>untraced</u> reference (to an array of Byte).</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Should we be allocating buffers (rd.buff) as <u>untraced</u> refs instead, and then explicitly freeing? Or, is there a way to keep them as
traced refs, but avoid collection/movement while being used in an unsafe manner?</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Finally, there are multiple statements in the FileRd.m3 module similar to line #83 that must be dealt with (e.g., 114, 119).</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Regards,</span></p><p class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);">Randy Coleburn</span></p><p
class="yiv235295595MsoNormal"><span style="font-size: 11pt; font-family: "sans-serif"; color: rgb(31, 73, 125);"> </span></p><div><div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;"><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><b><span style="font-size: 10pt; font-family: "sans-serif";">From:</span></b><span style="font-size: 10pt; font-family: "sans-serif";"> Tony Hosking [mailto:hosking@cs.purdue.edu] <br><b>Sent:</b> Wednesday, March 16, 2011 8:14 PM<br><b>To:</b> Coleburn, Randy<br><b>Cc:</b> m3devel<br><b>Subject:</b> Re: [M3devel] thread test results on Win7 64-bit</span></p></div></div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> </p><p class="yiv235295595MsoNormal" style="margin-right: 0in; margin-bottom: 12pt; margin-left: 0.5in;">This is the offending
line:</p><div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;">On Mar 16, 2011, at 6:50 PM, Coleburn, Randy wrote:</p></div><p class="yiv235295595MsoNormal" style="margin-right: 0in; margin-bottom: 12pt; margin-left: 0.5in;"> </p><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Courier New";">***</span><span style="font-size: 11pt; font-family: "sans-serif";"></span></p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Courier New";">*** runtime error:</span><span style="font-size: 11pt; font-family: "sans-serif";"></span></p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Courier New";">*** An array subscript was out of range.</span><span style="font-size: 11pt;
font-family: "sans-serif";"></span></p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Courier New";">*** file "..\src\rw\FileRd.m3", line 83</span><span style="font-size: 11pt; font-family: "sans-serif";"></span></p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"><span style="font-size: 10pt; font-family: "Courier New";">***</span><span style="font-size: 11pt; font-family: "sans-serif";"></span></p></div></div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> </p><div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> n := rd.sourceH.read(</p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> SUBARRAY(LOOPHOLE(ADR(rd.buff[0]), ByteArrayPtr)^, 0,</p></div><div><p
class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> MIN (NUMBER(rd.buff^), BIG)), mayBlock := NOT dontBlock)</p></div></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> </p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;">I am very suspicious about this... anyone have any insights?</p></div><div><p class="yiv235295595MsoNormal" style="margin-left: 0.5in;"> </p></div></div></div></blockquote></td></tr></table><br>