[Libreoffice] OSL_ASSERT - remove backtrace or make abort

Lubos Lunak l.lunak at suse.cz
Tue Apr 19 09:21:17 PDT 2011


 Hello,

 I'd like to remove the backtrace printing from OSL_ASSERT and friends, or, 
even better and if possible, make these functions work properly, i.e. abort 
on failure (I'm not really holding my breath on the second one, but refusing 
that one will at least support the first one).

 When building with debug >= 1, the majority of debug output for me is 
backtraces from debug functions like OSL_ASSERT that uselessly pollute the 
output (I added one OSL_ASSERT last week and it took me several days to 
notice the assertion was always false and the message got lost in all the 
noise around).

 First of all, the backtraces are actually useless even on their own, because 
with today's Linux toolchain backtrace() or dladdr() simply do not work for 
most functions - things like hidden visibility prevent it from working and 
who builds without that these days? That alone could be a good reason for 
removing the backtrace printing, but I find them useless in general. There 
are two ways to look at OSL_ASSERT and friends:

1) they are misnamed debug functions (which is presumably what they really are 
now). Every properly brought up assert function aborts if the condition is 
false, but these are more like debug messages or warnings - OSL_ASSERT 
doesn't assert that much, OSL_ENSURE doesn't ensure anything, they just print 
the error message (and the annoying backtrace) and then return like if 
nothing were nothing wrong. Now, if there's nothing really that wrong, what's 
the point of printing the huge backtrace like if something important 
happened, right? In this case it'd be also nice to get somewhen to renaming 
them to OSL_DEBUG or something so that it doesn't confuse people who expect a 
real assert.

2) they are assert functions, they just don't work right and should be fixed 
to make the app abort and fall flat on its face when the assertion is not 
true (in practice, flip the default on $SAL_DIAGNOSE_ABORT). I expect this 
wouldn't be a simple change, as this would at this time probably mean nobody 
would be able to successfully run LO for some time :), so that'd require a 
transitional period, e.g. similar to how compile warnings are fixed to make 
compilation with -Werror possible. No idea how much effort this would be, 
it's the technically right way, but I don't know if it'd be worth it.

 Opinions?

-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list