Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

LogDebug


#1

Hi,

After switching to the latest version I’ve come across a (strange) access violation exception when using the ‘LogDebug’ method.

In one of my Delphi projects I’m using a TXSLPageProducer to transform xml using xslt. The xslt file is loaded at runtime and then logged using the following statements.

[code]// Loading…
xsltDeclaratieFilter.LoadFromFile(ExpandFileName(FDeclaratieFiltersPad + aFilter));

// Logging…
SiMain.LogDebug('Declaratie filter: ’ + #13 + ‘%s’, [xsltDeclaratieFilter.XML.Text]);[/code]

This all went well before the switch to version 2, but now I get an access violation somewhere in the stringy depths of the delphi ‘System’ unit and the CPU window appears.

When I use the ‘LogString’ method the contents of the PageProducer are logged correctly, so I do have a workaround.

Any Idea’s?

FYI, the exception text:

Project xxx.exe faulted with message: ‘access violation at 0x7c9377c9: write of address 0x00030fa0’. Process Stopped. Use Step or Run to continue.


#2

Hello Gerben,

Thanks for reporting this error. It looks like a problem with Delphi’s WideFormat function rather than directly with LogDebug. With the transition to Unicode and WideStrings in SmartInspect v2.0, we also switched from Format to WideFormat and it seems that WideFormat is not as bug free as its non-Unicode counterpart. We are looking into ways to fix this (probably by shipping a custom WideFormat implementation). Sorry for the inconvenience.

To workaround the problem in this particular case I suggest using the standard LogDebug function and not the overloaded variant which accepts the format string:


#3

Hi,

Just like the workaround I already mentioned, using the LogDebug method without the format option seems to be working fine too.

By the way, as long as I use regular delphi strings the LogDebug method works fine, even with the format option.


#4

Hi Gerben,

WideFormat seems to have a bug on older Delphi versions with long strings. We will see what we can do in this regard. By the way, as an alternative to using LogDebug in this particular case, you could also use LogText with the lvDebug level:

This is simpler to use since there’s no need to concatenate the string yourself. The string ‘Declaratie filter’ is used as title for the message and xsltDeclaratieFilter.XML.Text as attached data.