[Development] QtCore missing check for memory allocation

Oswald Buddenhagen oswald.buddenhagen at theqtcompany.com
Thu Feb 26 20:54:32 CET 2015


On Thu, Feb 26, 2015 at 10:25:42AM -0800, Thiago Macieira wrote:
> On Wednesday 25 February 2015 20:07:58 Oswald Buddenhagen wrote:
> > as ulf pointed out, a rather trivial wrapper which ensures deterministic
> > behavior is hardly a burden.
> 
> And I disagree that it's hardly a burden. I am saying it is overhead.
> 
> Let me put it this way: who's going to write the unit tests to ensure we get 
> coverage for all those conditionals? Any volunteers?
> 
which conditionals? the malloc wrapper would throw/qFatal (depending on
the build configuration). your dream of never-failing malloc would be a
reality.
or we "just" use new() everywhere. this one already has said wrapper.

regarding replacing the malloc implementation ... is it possible to link
an implementation that would actually throw?

> > > The only reliable way of causing a segfault is raise(SIGSEGV). You can't
> > > reliably trigger a memory problem because, by the very definition of it,
> > > the compiler is allowed to assume it doesn't happen.
> > 
> > you can assign to a volatile pointer and deref it. the compiler is not
> > allowed to optimize that away. we established that much last time we
> > discussed this topic.
> 
> Sorry, the compiler *is* allowed to remove undefined behaviour because, by the 
> very definition of undefined behaviour, ANYTHING can happen, including 
> absolutely nothing.
> 
then explain edd2d9bd0a7f5dbe059aea0902d519b728acc01a.

> > > > [...] Q_CHECK_PTR should mean "If the pointer is 0 either throw
> > > > an exception or abort right away. Don't just continue."
> > > 
> > > I understand your arguments, but I still disagree we should act.
> > 
> > well, and i say you are wrong.  see the problem with this kind of
> > argumentation?
> 
> We've both exposed our technical argumentation for our suggestions but
> arrived at no consensus.
> 
you missed the point. you didn't provide arguments, only an opinion (at
the point of the discussion this quote refers to). it isn't constructive
to state your position without backing it up. if you stand by your
previously made arguments, post links, or refer to a search engine
(possibly suggesting keywords). not everyone witnessed the previous
discussions, or remembers them.



More information about the Development mailing list