The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,858 other subscribers

Never ever put OutpugDebugString in code that is meant to run on production systems

Posted by jpluimers on 2018/12/18

I just saw this code in the Delphi RTL enabled for RELEASE builds of the procedure TThreadPool.TQueueWorkerThread.Execute; code:

{$IFDEF MSWINDOWS}
    OutputDebugString(PChar(Format('Thread Exiting: %d', [ThreadId])));
{$ENDIF}

Never, ever do this.

If you code review code that contains it: ensure it has some kind of compile time DEBUG conditional around it.

–jeroen

12 Responses to “Never ever put OutpugDebugString in code that is meant to run on production systems”

  1. baka0815's avatar

    baka0815 said

    Why?
    I understand that you should us compile time conditionals,but what is so bad about that?

    • jpluimers's avatar

      jpluimers said

      See the reply to Luca for more background information.

      Indeed: always have a conditional define around it that is never turned on by default;

  2. Luca's avatar

    Luca said

    Sorry, can you explain why? It’s slow or dangerous?

  3. LEIF UNEUS's avatar

    LEIF UNEUS said

    From Rio back to at least XE8.

  4. edwinyzh's avatar

    edwinyzh said

    Nice find Jeroen. Which version of it?

    • jpluimers's avatar

      jpluimers said

      My guess is all. Since them disabling my MVP was done by just deleting the account that also held my Tech-Partner bits, I don’t have a full history of Delphi versions any more.

Leave a reply to baka0815 Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.