[knewstuff] Respect global variable
ClosedPublic

Authored by anthonyfieroni on Dec 3 2017, 1:37 PM.

Details

Summary

If engine is a part of global allocated object d_func *potentially* can be freed before engine, it will cause a crash in such application.
getCache has a 2 potential problems:

  1. s_caches can significantly increase its size
  2. call after destroyed shared pointer will return a nullptr

Diff Detail

Repository
R304 KNewStuff
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
anthonyfieroni created this revision.Dec 3 2017, 1:37 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 3 2017, 1:37 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
anthonyfieroni requested review of this revision.Dec 3 2017, 1:37 PM
mpyne accepted this revision.Dec 6 2017, 11:42 PM
mpyne added a subscriber: mpyne.

I think the change looks good. But if the cache here is holding a *weak* pointer to a Cache then every user of this s_cache should be checking for null pointers each time, right? We can do the improved lifetime checking here but I think it would also have worked fine to check weak pointers before using them. Though maybe weak pointers were just there to avoid circular references?

This revision is now accepted and ready to land.Dec 6 2017, 11:42 PM
In D9128#176957, @mpyne wrote:

Though maybe weak pointers were just there to avoid circular references?

Yes, it's look like.

mpyne added a comment.Dec 11 2017, 3:02 AM

OK, if no one else has objections I'd say to commit.

This revision was automatically updated to reflect the committed changes.