<div dir="ltr"><div>I have been getting some pretty strange errors on Lazarus 1.2.4/FreePascal 2.6.4 on windows 8.1 x64<br><br></div><div>It looks like some internal system memory cache is croaking while waiting for a free fixed memory chunk.<br>
<br></div><div>This is a 2 threaded program using TThread, so the notion of a memory seg fault while "waiting" means the system cache<br></div><div>is apparently not thread safe.<br><br></div><div>The code passes thru the SYSUTILS_RIGHTSTR many times before faulting, so it <br>
</div><div><br></div><div>I sent another request for anybody to provide a tip at having the stack trace actually fill in the #1 ?? at :0 entries<br>in the trace and that would be helpful now.<br></div><div><br></div><div>
This is the first time that the problem is squarely inside system.pas/sysutils.pas on the call stack. There are no other dependencies like references to global memory, etc.<br><br></div><div>We clearly have a call to SYSUTILS.rightstr( ). <br>
</div><div><br></div>Here is the stack trace of the memory exception:<br><div><br>#0 SYSTEM_WAITFREE_FIXED$PMEMCHUNK_FIXED$POSCHUNK at :0<br>#1 ?? at :0<br>#2 SYSUTILS_RIGHTSTR$ANSISTRING$LONGINT$$ANSISTRING at :0<br>#3 LEFTPAD(0x4dbf890 'DE26', 4, 48 '0', 0x0) at C:\pdev\rpzlib\rpzstring.pas:349<br>
#4 RPZCHKSUMPTR4(0x2dc251 '^i'#31'{66h'#7'O'#150#195'n3BD'#166#243#162'~'#188#184#171'7'#218'E'#227'3!v'#206'L'#179'[ENDE26]', 32, 0x0) at C:\pdev\rpzlib\rpzcrc16.pas:69<br>
#5 TRPZUDPFRAME__RXPUMP(100, <error reading variable>) at C:\pdev\rpzlib\rpzudpframe.pas:401<br>#6 TRPZUDPSRV__EXECWRAPPER(<error reading variable>) at C:\pdev\rpzlib\rpzudpsrv.pas:228<br>#7 TRPZUDPSRV__EXECUTE(<error reading variable>) at C:\pdev\rpzlib\rpzudpsrv.pas:171<br>
#8 CLASSES_THREADPROC$POINTER$$LONGINT at :0<br>#9 SYSTEM_THREADMAIN$POINTER$$LONGINT at :0<br>#10 KERNEL32!CreateWaitableTimerA at :0<br>#11 ?? at :0<br>#12 ?? at :0<br>#13 ?? at :0<br>#14 ?? at :0<br><br></div><div>Now when I run the same test using cmem as the memory manager, I get the following exception violoatoin:<br>
<br>#0 fpc_ansistr_decr_ref at :0<br>#1 ?? at :0<br>#2 TAPPLICATION__PROCESSASYNCCALLQUEUE(<error reading variable>) at .\include\application.inc:1079<br>#3 TAPPLICATION__IDLE(true, <error reading variable>) at .\include\application.inc:389<br>
#4 TAPPLICATION__HANDLEMESSAGE(<error reading variable>) at .\include\application.inc:1273<br>#5 TAPPLICATION__RUNLOOP(<error reading variable>) at .\include\application.inc:1405<br>#6 TWIDGETSET__APPRUN(0x422b50 <TAPPLICATION__RUNLOOP>, <error reading variable>) at .\include\interfacebase.inc:54<br>
#7 TAPPLICATION__RUN(<error reading variable>) at .\include\application.inc:1393<br>#8 main at rpztestudphv.lpr:29<br><br><br></div><div>So with the memory manager changed out, the exception now occurs in the GUI main thread instead of the TThread and clearly the fpc_ansistr_decr_ref function is failing.<br>
<br></div><div>The lines in question in .\include\application.inc:1079 are as follows:<br></div><div><br> // call event<br> Event(Data);<br><br></div><div>This Event variable is a pointer to a function with a single pointer to integer argument.<br>
<br></div><div>Anybody got some ideas about this?<br><br></div><div>Cheers,<br><br>Marco<br></div><div><br></div><div><br></div></div>