[Lazarus] Debugger stops in c dll even when no breakpoint set

Luca Olivetti luca at wetron.es
Thu Oct 28 14:01:17 CEST 2021


I'm using a quite complex c dll (pascal headers here: 
https://github.com/fluisgirardi./fpopen62541).
For logging purposes, this dll can call a function but it needs to 
support varargs, so I wrote a simple c source 
(https://github.com/fluisgirardi/fpopen62541/blob/main/pascallog/pascallog.c), 
compiled into a dll, that writes the message in a buffer then calls a 
pascal function without varargs.

The problem is that every time the main dll calls the function 
UA_Log_Pascal_clear (which just frees the pointer passed to it), the 
debugger stops inside the function

ntdll!RtlpNtMakeTemporaryKey

even with no breakpoints set.

This is under win32, lazarus 2.0.12, fpc 3.2.0. the debugger is gdb 8.2 
(I don't remember where I got it).

It's quite annoying since it disrupts my debugging session, any way to 
avoid it?

The stack trace is

#0 ntdll!RtlpNtMakeTemporaryKey at :0
#1 ntdll!RtlImageRvaToVa at :0
#2 ntdll!EtwSetMark at :0
#3 ntdll!RtlpNtMakeTemporaryKey at :0
#4 ntdll!EtwSetMark at :0
#5 wcsnicmp at :0
#6 msvcrt!free at :0
#7 ?? at :0
#8 UA_Log_Pascal_clear(0x6b74a28) at D:\open62541\extlog\pascallog.c:53
#9 UA_ClientConfig_clear(0x100000) at 
\home\travis\build\open62541\open62541\src\client\ua_client.c:75
#10 UA_Client_delete(0x72dec78) at 
\home\travis\build\open62541\open62541\src\client\ua_client.c:103
#11 TOPCUARFID__DISCONNECT(0x2dec150) at opcuarfid.pas:1129
#12 TOPCUARFID__CHECKSTATUSCODE(0xbb4c18 'Error en UA_Client_connec'..., 
2158886912, 0x2dec150) at opcuarfid.pas:1200
#13 TOPCUARFID__CONNECT(0x314076c '192.168.1.46', 0x2dec150) at 
opcuarfid.pas:1102
#14 TRF185C__EXECUTE(0x28c4e0) at rf185c.pas:214
#15 CLASSES$_$TSTRINGLIST_$__$$_SORT at :0
#16 ?? at :0
#17 _FPC_except_safecall at :0
#18 ?? at :0
#19 KERNEL32!BaseThreadInitThunk at :0
#20 ntdll!RtlInitializeExceptionChain at :0
#21 ntdll!RtlInitializeExceptionChain at :0
#22 ?? at :0

and this is what the assembler window shows:

77045A9F 90                       nop
77045AA0 90                       nop
77045AA1 8bff                     mov    %edi,%edi
77045AA3 55                       push   %ebp
77045AA4 8bec                     mov    %esp,%ebp
77045AA6 64a118000000             mov    %fs:0x18,%eax
77045AAC 8b4030                   mov    0x30(%eax),%eax
77045AAF 80780200                 cmpb   $0x0,0x2(%eax)
77045AB3 7417                     je     0x77045acc 
<ntdll!RtlpNtMakeTemporaryKey+14541>
77045AB5 8b4508                   mov    0x8(%ebp),%eax
77045AB8 c605a510067701           movb   $0x1,0x770610a5
77045ABF a3a0100677               mov    %eax,0x770610a0
77045AC4 cc                       int3
77045AC5 c605a510067700           movb   $0x0,0x770610a5 <<<<here
77045ACC 5d                       pop    %ebp
77045ACD c20400                   ret    $0x4
77045AD0 90                       nop
77045AD1 90                       nop
77045AD2 90                       nop
77045AD3 90                       nop
77045AD4 90                       nop
77045AD5 8bff                     mov    %edi,%edi
77045AD7 55                       push   %ebp
77045AD8 8bec                     mov    %esp,%ebp
77045ADA 83ec1c                   sub    $0x1c,%esp
77045ADD 56                       push   %esi
77045ADE 8b7510                   mov    0x10(%ebp),%esi
77045AE1 57                       push   %edi

Bye
-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007


More information about the lazarus mailing list