#1 2015-01-07 09:14:13

berndvf
Member
Registered: 2013-03-08
Posts: 16

SetCurrentThreadName causes External Exception when debugging

Hi there,

I see that a call to SetCurrentThreadName was added to mORMot.pas recently (http://synopse.info/fossil/info/3919591 … 53a96e6c76). Every time I debug my application I now get an EExternalException on startup - is there any way I can turn this off? I understand it can be useful but it pops up even for a simple test application. Perhaps we can IFDEF it?

Thanks,
Bernd

Offline

#2 2015-01-07 09:21:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,552
Website

Re: SetCurrentThreadName causes External Exception when debugging

Weird.
On our side, SetCurrentThreadName() does not trigger any exception in the IDE.
We tried with Delphi 7, 2007, XE4 and XE7.

I've introduced NOSETTHREADNAME conditional, to be defined if you have issues when debugging your application.
See http://synopse.info/fossil/info/73ecde4f4a

Offline

#3 2015-01-07 09:59:25

berndvf
Member
Registered: 2013-03-08
Posts: 16

Re: SetCurrentThreadName causes External Exception when debugging

Great thanks. This was using Delphi 6 - I'll test with other Delphi versions.

Offline

#4 2016-05-24 20:51:01

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: SetCurrentThreadName causes External Exception when debugging

I use Delphi 7.1, and this was happening with my IDE too.

Offline

#5 2016-05-26 06:52:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,552
Website

Re: SetCurrentThreadName causes External Exception when debugging

It is an IDE bug/restriction, which occurs randomly.

Offline

#6 2019-06-23 09:02:56

Daniel
Member
Registered: 2016-12-08
Posts: 23

Re: SetCurrentThreadName causes External Exception when debugging

NOSETTHREADNAME conditional is defined by default in Synopse.inc and apparently no one uses it as it doesn't even compile without it any more.

Thread naming is quite handy feature for debugging and should be fixed and turned on by default, IMHO.
Surely the majority of users have no problem with it.

EDIT: In general it is better to have optional additional features as conditional that turns it *on*, rather that conditional that turns something *off*.
In case of NOSETTHREADNAME for example you have to modify Synopse.inc to comment out NOSETTHREADNAME

If it was simply SETTHREADNAME and it was commented out in Synopse.inc, you could simply define it in project options or another .inc file, without the need to modify Synopse.inc.

As a bonus this is more readable:
{$IFDEF SETTHREADNAME}
than this:
{$IFNDEF NOSETTHREADNAME}

Last edited by Daniel (2019-06-23 10:00:19)

Offline

#7 2019-06-23 17:57:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,552
Website

Re: SetCurrentThreadName causes External Exception when debugging

The logic was initially the reverse: set the thread name by default, and let a conditional disable it if the exception is not worth it.
At some point, I disabled it because I found it annoying for a particular case.
I guess I forgot to undefine it back.

So thread name will be turned ON by default by this commit: https://synopse.info/fossil/info/03733981ad

Offline

Board footer

Powered by FluxBB