Thunar NDEBUG and _thunar_assert macros

Jannis Pohlmann jannis at xfce.org
Sat Nov 8 16:52:50 CET 2014


Hi,

On Fri, 7 Nov 2014 19:47:25 +0000
Alistair Buxton <a.j.buxton at gmail.com> wrote:

> What is happening here is that thunar_file_is_directory is segfaulting
> if file is NULL.
> 
> Code: http://git.xfce.org/xfce/thunar/tree/thunar/thunar-file.c#n2544
> 
> From a first look at this function, it's impossible for it to
> segfault. It is two lines, and the first line should return false if
> file is NULL.
> 
> But there's a problem, in thunar-private.h:
> 
> http://git.xfce.org/xfce/thunar/tree/thunar/thunar-private.h#n28
> 
> What this block of code does is turn all those checks into null ops if
> you do a release build.
> 
> It looks to me like what has happened here is those macros were
> originally meant for debugging, but later people have relied on them
> to catch errors, not realising they don't work in release mode. So in
> release mode Thunar will just go ahead and use an invalid pointer.

Correc, the macros exist to catch programming errors and are no-ops in
release builds to improve performance, the assumption being that if we
catch the programming errors during development and testing, those
checks are no longer required in the release.

An optimistic assumption, perhaps, given that we aren't testing
systematically.

Anyway, the problem here is not the macros being left out, the problem
is that something calls thunar_file_is_directory() with a broken file
pointer, so that is what needs to be fixed. The macros don't need to
change because they are not the crash cause.

  - Jannis


More information about the Xfce4-dev mailing list