[haiku-commits] Re: haiku: hrev53233 - src/system/kernel/debug src/kits/storage src/system/kernel src/kits/app headers/private/kernel

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 6 Jul 2019 13:23:11 +0200

Am 05/07/2019 um 18:05 schrieb waddlesplash:

On Fri, Jul 5, 2019 at 9:16 AM Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> wrote:
That change doesn't look particularly sane. The moment the read lock is
put away, you mustn't access the structure anymore.

There is already Team::Get() which correctly acquires a reference before
losing the lock.

Acquiring a reference, using the team, and then dropping the reference
is a much more costly operation than simply getting the team in the
first place. The goal here is to use a function like this when the
team structure is needed perhaps only for one operation (as you can
see in the next commit, I'm using it to retrieve the uids for
permissions checks.)

Huh? I can't really follow your logic here: you MUST NOT access the structure without a reference, and without the lock being held. One of those two things must be true, no matter how expensive it is.

The follow up commit you mention [1?] is broken, as it potentially accesses freed memory.

Perhaps we should make a function to just get the euid of a specific team?

That sounds like a much better idea.

Bye,
   Axel.

[1] https://git.haiku-os.org/haiku/commit/?id=6f0aa00c6be763a5e0d95fb8e55a19a080101cbd

Other related posts: