<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
I'm going to make one or two changes because of this.<BR>
<BR>
- Where we process memory in a range, I'm going to go in stack growth order instead from lowest address to highest. If we don't already.<BR>
Or possibly recieve a direction parameter and pass it as 1 everywhere except for -1 when processing Win32 stacks.<BR>
<BR>
<BR>
- On Win32 I'm going to process the "entire" stack, instead of just from the current stack pointer to the "initial" stack pointer (highest address).<BR> This is wasteful, will avoid reclaiming some garbage, will scan generally far more than needed.<BR>
However it is also what we do on FreeBSD and OpenBSD (see ThreadOpenBSD.c's use of pthread_stackseg_np and ThreadFreeBSD.c's use of pthread_stackseg_np)<BR> <BR>
<BR>
I think the main other alternative is the more portable "cooperative" scheme Tony has proposed where each thread has a boolean<BR>
it checks occasionally as to if suspension is requested. It is a nice scheme, since it would remove a bunch of platform-specific code<BR>
and posix-specific code (i.e. all signal stuff that isn't for user threads).<BR>
<BR>
<BR>
On the matter of garbage lingering in stack frames that have been popped...should we consider NIL'ing local pointers before turn?<BR>
Or it is too expensive and doesn't gain much?<BR>
And they'll tend to get overwritten fairly soon anyway??<BR>
Seems very gray.<BR>
<BR>
<BR>
- Jay<BR>
<BR>
<BR>
<HR id=stopSpelling>
From: jay.krell@cornell.edu<BR>To: rcolebur@scires.com; m3devel@elegosoft.com<BR>Date: Mon, 7 Mar 2011 05:51:32 +0000<BR>Subject: Re: [M3devel] results of threadtest program on Windows7<BR><BR>
<META name=Generator content="Microsoft SafeHTML">
<STYLE>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
I find this worrisome, and want to understand it, and workaround it, somehow.<BR> <BR><A href="http://zachsaw.blogspot.com/2010/11/wow64-bug-getthreadcontext-may-return.html" target=_blank>http://zachsaw.blogspot.com/2010/11/wow64-bug-getthreadcontext-may-return.html</A><BR> <BR> - Jay<BR> <BR>
<HR id=ecxstopSpelling>
From: jay.krell@cornell.edu<BR>To: rcolebur@scires.com; m3devel@elegosoft.com<BR>Date: Mon, 7 Mar 2011 05:39:53 +0000<BR>Subject: Re: [M3devel] results of threadtest program on Windows7<BR><BR>
<STYLE>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
Ok. I see it fail often on Windows now too. I didn't change anything.<BR>I enabled pageheap to try to narrow it down, only to find an operating system bug, which I have worked around.<BR>"pageheap" causes heap allocations to be followed immediately by an unused page, to catch heap overruns right away.<BR> Modulo alignment restrictions -- i.e. malloc(1) will still have a few bytes you can silently corrupt before the unused page.<BR> <BR>Here is one instance.<BR> <BR>0:000> g<BR>Writing file...done<BR>Creating read threads...done<BR>Creating fork threads...done<BR>Creating alloc threads...done<BR>Creating lock threads...done<BR>running...printing oldest/median age/newest<BR>.ModLoad: 73b20000 73b6b000 C:\Windows\SysWOW64\apphelp.dll<BR>(1028.ca0): Access violation - code c0000005 (first chance)<BR>First chance exceptions are reported before any exception handling.<BR>This exception may be expected and handled.<BR>eax=01155e18 ebx=00200000 ecx=00000005 edx=0111caee esi=001ffffc edi=00a80018<BR>eip=0111cb3e esp=06d9f5c4 ebp=06d9f5fc iopl=0 nv up ei pl nz ac pe nc<BR>cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010216<BR>*** WARNING: Unable to verify checksum for threadtest.exe<BR>threadtest!RTCollector__Move+0x50:<BR>0111cb3e 8b1e mov ebx,dword ptr [esi] ds:002b:001ffffc=????????<BR>0:009> r esi<BR>esi=001ffffc<BR>0:009> db @esi<BR>001ffffc ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020000c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020001c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020002c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020003c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020004c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020005c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0020006c ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????<BR>0:009> ~*k<BR> 0 Id: 1028.d60 Suspend: 2 Teb: 7efdd000 Unfrozen<BR>ChildEBP RetAddr<BR><BR>...<BR>0045f674 0111a448 KERNELBASE!Sleep+0xf<BR>0045f6b4 0111a218 threadtest!ThreadWin32__XPause+0x1cd<BR>0045f6d8 010f356e threadtest!Thread__Pause+0x37<BR>0045f7cc 01115268 threadtest!Main_M3+0xe67<BR>0045f810 01114818 threadtest!RTLinker__RunMainBody+0x257<BR>0045f828 011148bf threadtest!RTLinker__AddUnitI+0xf7<BR>0045f848 010f1038 threadtest!RTLinker__AddUnit+0x9f<BR>0045f864 011515d3 threadtest!main+0x38<BR>0045f8a8 75e63677 threadtest!__tmainCRTStartup+0x122<BR>0045f8b4 771c9f02 kernel32!BaseThreadInitThunk+0x12<BR>...<BR> <BR> 1 Id: 1028.ab8 Suspend: 2 Teb: 7efda000 Unfrozen<BR>ChildEBP RetAddr<BR>00f6f680 771c8cc8 ntdll!NtWaitForSingleObject+0x15<BR>00f6f6a8 0111b262 ntdll!RtlIntegerToUnicodeString+0x20b<BR>00f6f6bc 01117b86 threadtest!RTOS__LockHeap+0x2c<BR>00f6f6fc 011171cc threadtest!RTAllocator__AllocTraced+0xcd<BR>00f6f730 01116ce6 threadtest!RTAllocator__GetTracedObj+0x89<BR>00f6f74c 010f6829 threadtest!RTHooks__AllocateTracedObj+0x15<BR>00f6f774 010f1288 threadtest!FileRd__Open+0x19<BR>00f6f8ac 01119ca4 threadtest!Main__RApply+0x78<BR>00f6f8e8 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 2 Id: 1028.d50 Suspend: 2 Teb: 7efd7000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>0106f9b0 011188ef threadtest!ThreadWin32__InitMutex+0x56<BR>0106f9c8 010f7c08 threadtest!ThreadWin32__LockMutex+0x42<BR>0106f9f0 010f12e3 threadtest!Rd__GetChar+0x28<BR>0106fb28 01119ca4 threadtest!Main__RApply+0xd3<BR>0106fb64 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 3 Id: 1028.ef0 Suspend: 2 Teb: 7efaf000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>062ff510 01117b86 threadtest!RTOS__LockHeap+0x2c<BR>062ff550 011171cc threadtest!RTAllocator__AllocTraced+0xcd<BR>062ff584 01116ce6 threadtest!RTAllocator__GetTracedObj+0x89<BR>062ff5a0 011076b2 threadtest!RTHooks__AllocateTracedObj+0x15<BR>062ff5d8 01106302 threadtest!FileWin32__New+0x52<BR>062ff600 010f6839 threadtest!FS__OpenFileReadonly+0x8a<BR>062ff628 010f1288 threadtest!FileRd__Open+0x29<BR>062ff760 01119ca4 threadtest!Main__RApply+0x78<BR>062ff79c 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 4 Id: 1028.10c8 Suspend: 2 Teb: 7efa9000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>0674fc44 010f17b9 threadtest!Process__Wait+0x8c<BR>0674fd00 01119ca4 threadtest!Main__FApply+0xa2<BR>0674fd3c 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 5 Id: 1028.c54 Suspend: 2 Teb: 7efac000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>0646fcc8 010f17b9 threadtest!Process__Wait+0x8c<BR>0646fd84 01119ca4 threadtest!Main__FApply+0xa2<BR>0646fdc0 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> 6 Id: 1028.101c Suspend: 2 Teb: 7efa3000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>06a1fdac 01117b86 threadtest!RTOS__LockHeap+0x2c<BR>06a1fdec 0111772a threadtest!RTAllocator__AllocTraced+0xcd<BR>06a1fe28 01116d9b threadtest!RTAllocator__GetOpenArray+0x94<BR>06a1fe4c 010f1ada threadtest!RTHooks__AllocateOpenArray+0x19<BR>06a1fea8 01119ca4 threadtest!Main__AApply+0x46<BR>06a1fee4 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>06a1fef0 771c9f02 kernel32!BaseThreadInitThunk+0x12<BR>...<BR> 7 Id: 1028.d5c Suspend: 2 Teb: 7efa6000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>0684f6d0 01118eb1 threadtest!ThreadWin32__InitCondition+0xb0<BR>0684f6f0 0111b328 threadtest!Thread__Broadcast+0x3f<BR>0684f70c 01117c31 threadtest!RTOS__UnlockHeap+0xb3<BR>0684f728 01117bbe threadtest!RTAllocator_M3_LINE_368+0x15<BR>0684f768 011171cc threadtest!RTAllocator__AllocTraced+0x105<BR>0684f79c 01116ce6 threadtest!RTAllocator__GetTracedObj+0x89<BR>0684f7b8 011410c9 threadtest!RTHooks__AllocateTracedObj+0x15<BR>0684f7d4 0112ce59 threadtest!Text8CString__New+0x19<BR>0684f7ec 0112b63a threadtest!M3toC__StoT+0x16<BR>0684f818 010fb22d threadtest!RTArgs__GetArg+0x70<BR>0684f840 010f1776 threadtest!Params__Get+0x5d<BR>0684f8fc 01119ca4 threadtest!Main__FApply+0x5f<BR>0684f938 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> 8 Id: 1028.d14 Suspend: 2 Teb: 7efa0000 Unfrozen<BR>ChildEBP RetAddr<BR>WARNING: Stack unwind information not available. Following frames may be wrong.<BR>...<BR>06c6f6c8 01117b86 threadtest!RTOS__LockHeap+0x2c<BR>06c6f708 0111772a threadtest!RTAllocator__AllocTraced+0xcd<BR>06c6f744 01116d9b threadtest!RTAllocator__GetOpenArray+0x94<BR>06c6f768 010f1ada threadtest!RTHooks__AllocateOpenArray+0x19<BR>06c6f7c4 01119ca4 threadtest!Main__AApply+0x46<BR>06c6f800 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR># 9 Id: 1028.ca0 Suspend: 1 Teb: 7ef9d000 Unfrozen<BR>ChildEBP RetAddr<BR>06d9f5fc 0113e6bd threadtest!RTCollector__Move+0x50<BR>06d9f640 0113dfa8 threadtest!RTHeapMap__Walk+0x45a<BR>06d9f664 0113df83 threadtest!RTHeapMap__DoWalkRef+0x62<BR>06d9f688 0113df83 threadtest!RTHeapMap__DoWalkRef+0x3d<BR>06d9f6ac 0113df3e threadtest!RTHeapMap__DoWalkRef+0x3d<BR>06d9f6d8 0111e65f threadtest!RTHeapMap__WalkRef+0xfe<BR>06d9f6fc 0111e4ad threadtest!RTCollector__CleanBetween+0xeb<BR>06d9f724 0111de48 threadtest!RTCollector__CleanPage+0x54<BR>06d9f778 0111d8ab threadtest!RTCollector__CollectSomeInStateZero+0x562<BR>06d9f788 0111d549 threadtest!RTCollector__CollectSome+0x6e<BR>06d9f7cc 01117b8c threadtest!RTHeapRep__CollectEnough+0x9b<BR>06d9f80c 0111772a threadtest!RTAllocator__AllocTraced+0xd3<BR>06d9f848 01116d9b threadtest!RTAllocator__GetOpenArray+0x94<BR>06d9f86c 010f1ada threadtest!RTHooks__AllocateOpenArray+0x19<BR>06d9f8c8 01119ca4 threadtest!Main__AApply+0x46<BR>06d9f904 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> 10 Id: 1028.4cc Suspend: 2 Teb: 7ef97000 Unfrozen<BR>ChildEBP RetAddr<BR>WARNING: Stack unwind information not available. Following frames may be wrong.<BR>0664fdec 771c8cc8 ntdll!NtWaitForSingleObject+0x15<BR>0664fe14 011188ff ntdll!RtlIntegerToUnicodeString+0x20b<BR>0664fe2c 010f1d9b threadtest!ThreadWin32__LockMutex+0x52<BR>0664fe74 01119ca4 threadtest!Main__LApply+0x7d<BR>0664feb0 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 11 Id: 1028.b48 Suspend: 2 Teb: 7ef9a000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>06f1fe38 010f1d9b threadtest!ThreadWin32__LockMutex+0x52<BR>06f1fe80 01119ca4 threadtest!Main__LApply+0x7d<BR>06f1febc 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR> <BR> 12 Id: 1028.a0c Suspend: 2 Teb: 7ef94000 Unfrozen<BR>ChildEBP RetAddr<BR>...<BR>06b1fa98 6c2a016a kernel32!HeapFree+0x14<BR>06b1faac 0113328d MSVCR100!free+0x1c<BR>06b1fab8 01116e2e threadtest!Cstdlib__free+0xd<BR>06b1facc 011184fa threadtest!RTHooks__DisposeUntracedRef+0x2c<BR>06b1fae0 011185c0 threadtest!ThreadWin32__DelCriticalSection+0x2d<BR>06b1fb14 011188ef threadtest!ThreadWin32__InitMutex+0x6e<BR>06b1fb2c 010f1d9b threadtest!ThreadWin32__LockMutex+0x42<BR>06b1fb74 01119ca4 threadtest!Main__LApply+0x7d<BR>06b1fbb0 75e63677 threadtest!ThreadWin32__ThreadBase+0x25a<BR>...<BR><BR> <BR>Suggestions?<BR> <BR><BR>That last thread is a bit different, but I guess merely suggesting heavy stress.<BR> Init goes to Del only when another thread calls Init at about the same time on the same mutex.<BR> <BR> <BR>Maybe try user threads but with a smaller quanta?<BR>Maybe try a much older Win32 thread implementation?<BR>Maybe go back to uniproc? Just for anecdotal evidence?<BR>I'll try with noinc/nogen/paranoid on Win32 also.<BR> <BR> <BR> - Jay<BR><BR> <BR>
<HR id=ecxstopSpelling>
From: jay.krell@cornell.edu<BR>To: rcolebur@scires.com; m3devel@elegosoft.com<BR>Date: Mon, 7 Mar 2011 01:25:59 +0000<BR>Subject: Re: [M3devel] results of threadtest program on Windows7<BR><BR>
<STYLE>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
</STYLE>
Visual Studio should work.<BR>You just open the .exe you want to debug, and it should decide you have opened it because you want to debug it.<BR>Does it let you set breakpoints by typing in function names?<BR>e.g. main or cm3!main or threadtest!main.<BR><BR>windbg is also very good and a free download.<BR>e.g.<BR>\bin\x86\windbg threadtest<BR>bp threadtest!main<BR>bp threadtest!RTError__MsgS<BR>g<BR><BR> - Jay<BR><BR><BR>
<HR id=ecxstopSpelling>
From: rcolebur@SCIRES.COM<BR>To: m3devel@elegosoft.com<BR>Date: Sat, 5 Mar 2011 20:35:41 -0500<BR>Subject: Re: [M3devel] results of threadtest program on Windows7<BR><BR>
<STYLE>
.ExternalClass .ecxshape
{;}
</STYLE>
<STYLE>
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass div.ecxMsoNormal
{margin-bottom:.0001pt;font-size:12.0pt;font-family:'Times New Roman','serif';}
.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink
{color:blue;text-decoration:underline;}
.ExternalClass a:visited, .ExternalClass span.ecxMsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
.ExternalClass p
{margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:'Times New Roman','serif';}
.ExternalClass p.ecxecxmsonormal, .ExternalClass li.ecxecxmsonormal, .ExternalClass div.ecxecxmsonormal
{margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:'Times New Roman','serif';}
.ExternalClass p.ecxecxmsochpdefault, .ExternalClass li.ecxecxmsochpdefault, .ExternalClass div.ecxecxmsochpdefault
{margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:'Times New Roman','serif';}
.ExternalClass span.ecxecxmsohyperlink
{;}
.ExternalClass span.ecxecxmsohyperlinkfollowed
{;}
.ExternalClass span.ecxecxemailstyle19
{;}
.ExternalClass p.ecxecxmsonormal1, .ExternalClass li.ecxecxmsonormal1, .ExternalClass div.ecxecxmsonormal1
{margin-right:0in;margin-bottom:0in;margin-left:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:'Times New Roman','serif';}
.ExternalClass span.ecxecxmsohyperlink1
{color:blue;text-decoration:underline;}
.ExternalClass span.ecxecxmsohyperlinkfollowed1
{color:purple;text-decoration:underline;}
.ExternalClass span.ecxecxemailstyle191
{font-family:'Calibri','sans-serif';color:#1F497D;}
.ExternalClass p.ecxecxmsochpdefault1, .ExternalClass li.ecxecxmsochpdefault1, .ExternalClass div.ecxecxmsochpdefault1
{margin-right:0in;margin-left:0in;font-size:10.0pt;font-family:'Times New Roman','serif';}
.ExternalClass span.ecxecxapple-converted-space
{;}
.ExternalClass span.ecxEmailStyle29
{font-family:'Calibri','sans-serif';color:#1F497D;}
.ExternalClass .ecxMsoChpDefault
{font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;}
.ExternalClass div.ecxWordSection1
{page:WordSection1;}
</STYLE>
<DIV class=ecxWordSection1>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Jay:</SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> </SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt">I have Visual Studio Express installed. Can I use its debugger? If so, how do I make it work with cm3? Or, do you suggest something else?</SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> </SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Regards,</SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt">Randy</SPAN></P>
<P class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: rgb(31,73,125); FONT-SIZE: 11pt"> </SPAN></P>
<DIV>
<DIV style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: rgb(181,196,223) 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<P style="MARGIN-LEFT: 0.5in" class=ecxMsoNormal><B><SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">From:</SPAN></B><SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt"> jayk123@hotmail.com [mailto:jayk123@hotmail.com] <B>On Behalf Of </B>Jay K<BR><B>Sent:</B> Saturday, March 05, 2011 12:38 AM<BR><B>To:</B> Coleburn, Randy; m3devel@elegosoft.com<BR><B>Subject:</B> RE: [M3devel] results of threadtest program on Windows7</SPAN></P></DIV></DIV>
<P style="MARGIN-LEFT: 0.5in" class=ecxMsoNormal> </P>
<P style="MARGIN-BOTTOM: 12pt; MARGIN-LEFT: 0.5in; MARGIN-RIGHT: 0in" class=ecxMsoNormal><SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">Microsoft debuggers are freely downloadable. <BR><BR>Jay/phone</SPAN></P>
<DIV style="TEXT-ALIGN: center; MARGIN-LEFT: 0.5in" class=ecxMsoNormal align=center><SPAN style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">
<HR align=center SIZE=2 width="100%">
</SPAN></DIV></DIV> </body>
</html>