[fpc-devel] SYSUTILS UTF8String Memory Bug
rpzrpzrpz at gmail.com
Sat Aug 9 20:06:02 CEST 2014
I have been getting some pretty strange errors on Lazarus 1.2.4/FreePascal
2.6.4 on windows 8.1 x64
It looks like some internal system memory cache is croaking while waiting
for a free fixed memory chunk.
This is a 2 threaded program using TThread, so the notion of a memory seg
fault while "waiting" means the system cache
is apparently not thread safe.
The code passes thru the SYSUTILS_RIGHTSTR many times before faulting, so
I sent another request for anybody to provide a tip at having the stack
trace actually fill in the #1 ?? at :0 entries
in the trace and that would be helpful now.
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.
We clearly have a call to SYSUTILS.rightstr( ).
Here is the stack trace of the memory exception:
#0 SYSTEM_WAITFREE_FIXED$PMEMCHUNK_FIXED$POSCHUNK at :0
#1 ?? at :0
#2 SYSUTILS_RIGHTSTR$ANSISTRING$LONGINT$$ANSISTRING at :0
#3 LEFTPAD(0x4dbf890 'DE26', 4, 48 '0', 0x0) at
32, 0x0) at C:\pdev\rpzlib\rpzcrc16.pas:69
#5 TRPZUDPFRAME__RXPUMP(100, <error reading variable>) at
#6 TRPZUDPSRV__EXECWRAPPER(<error reading variable>) at
#7 TRPZUDPSRV__EXECUTE(<error reading variable>) at
#8 CLASSES_THREADPROC$POINTER$$LONGINT at :0
#9 SYSTEM_THREADMAIN$POINTER$$LONGINT at :0
#10 KERNEL32!CreateWaitableTimerA at :0
#11 ?? at :0
#12 ?? at :0
#13 ?? at :0
#14 ?? at :0
Now when I run the same test using cmem as the memory manager, I get the
following exception violoatoin:
#0 fpc_ansistr_decr_ref at :0
#1 ?? at :0
#2 TAPPLICATION__PROCESSASYNCCALLQUEUE(<error reading variable>) at
#3 TAPPLICATION__IDLE(true, <error reading variable>) at
#4 TAPPLICATION__HANDLEMESSAGE(<error reading variable>) at
#5 TAPPLICATION__RUNLOOP(<error reading variable>) at
#6 TWIDGETSET__APPRUN(0x422b50 <TAPPLICATION__RUNLOOP>, <error reading
variable>) at .\include\interfacebase.inc:54
#7 TAPPLICATION__RUN(<error reading variable>) at
#8 main at rpztestudphv.lpr:29
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.
The lines in question in .\include\application.inc:1079 are as follows:
// call event
This Event variable is a pointer to a function with a single pointer to
Anybody got some ideas about this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel