Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Issue 2949833006: Mac a11y: Fix AXTextMarker leaks. (Closed)

Created:
3 years, 6 months ago by tapted
Modified:
3 years, 6 months ago
Reviewers:
dmazzoni
CC:
chromium-reviews, aboxhall+watch_chromium.org, nektar+watch_chromium.org, jam, yuzo+watch_chromium.org, dougt+watch_chromium.org, darin-cc_chromium.org, aleventhal+watch_chromium.org, dtseng+watch_chromium.org, mac-reviews_chromium.org, je_julie, dmazzoni+watch_chromium.org, chrome-apps-syd-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Mac a11y: Fix AXTextMarker leaks. We have to rely on undocumented APIs for VoiceOver on Mac. AXTextMarkerCreate() copies from the buffer it's provided, and doesn't retain it. AXTextMarkerRangeCreate() adds a retain count to the pair of AXTextMarker it's provided, so CreatePositionFromTextMarker must do a CFRelease. BUG=735793 Review-Url: https://codereview.chromium.org/2949833006 Cr-Commit-Position: refs/heads/master@{#481463} Committed: https://chromium.googlesource.com/chromium/src/+/1ed607555484664fd396c3422d02f5c40470b9a8

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -9 lines) Patch
M content/browser/accessibility/browser_accessibility_cocoa.mm View 1 chunk +8 lines, -9 lines 0 comments Download

Messages

Total messages: 17 (11 generated)
tapted
Hi Dominic, please take a look
3 years, 6 months ago (2017-06-22 05:00:00 UTC) #6
dmazzoni
lgtm
3 years, 6 months ago (2017-06-22 05:04:19 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2949833006/1
3 years, 6 months ago (2017-06-22 06:27:20 UTC) #11
commit-bot: I haz the power
Committed patchset #1 (id:1) as https://chromium.googlesource.com/chromium/src/+/1ed607555484664fd396c3422d02f5c40470b9a8
3 years, 6 months ago (2017-06-22 06:30:50 UTC) #15
chromium-reviews
+// AXTextMarkerCreate copies from data buffer given to it. > id CreateTextMarker(AXPlatformPositionInstance position) { > ...
3 years, 6 months ago (2017-06-22 15:55:31 UTC) #16
tapted
3 years, 6 months ago (2017-06-22 23:48:38 UTC) #17
Message was sent while issue was closed.
On 23 June 2017 at 01:55, Nektarios Paisios <nektar@google.com> wrote:

> +// AXTextMarkerCreate copies from data buffer given to it.
>
> id CreateTextMarker(AXPlatformPositionInstance position) {
> AXTextMarkerRef text_marker = AXTextMarkerCreate(
> - kCFAllocatorDefault, reinterpret_cast<const UInt8*>(position.release()),
> + kCFAllocatorDefault, reinterpret_cast<const UInt8*>(position.get()),
>
>
> What's the difference? Doesn't |Release| return a pointer to the buffer
> with the text marker same as |Get|?
> Reason I used Release instead of Get is to make ownership transfer
> explicit so that no code that might later be added to the function will be
> tempted to use the unique_ptr again.
>

There isn't a way for the private API (i.e. AXTextMarkerCreate) to take
ownership -- it only supports copying. So we still need the unique_ptr in
|position| to free its copy, which it won't do after release().

This does mean that we have always been copying a unique_ptr, which is not
meant to be copyable. It still works fine, since AXPosition is just
plain-old-data apart from the vtable pointer (which is static).

Note the copy being done internally by AXTextMarkerCreate is balanced by
the memcpy when we take it back out in CreatePositionFromTextMarker.

I'm exploring a more explicit approach in the follow-up that doesn't copy
the vtable pointer --
https://codereview.chromium.org/2940923003/diff/140001/ui/accessibility/platf...
. But I didn't want to mix in the fix for the leak in the refactor.


> How do I find these bugs out so that I don't repeat them in the future?
>
> Is there a tool for this?
>

Instruments.app is what I used - there are notes and repro steps in the
linked bug, http://crbug.com/735793 . But Instruments is very information
dense - I tried to extract a textual report in the style of ASAN and could
not. Also we don't run the lsan leak checker on Mac -- only Linux. Mac
doesn't support lsan and valgrind stop supporting Mac a long time ago (we
once did have a valgrind bot). We are _finally_ moving our bots past XCode
5 now that the OS on all the VMs is upgraded, so we may be able to figure
out some way to invoke Instruments.app from the command line and run it on
the bots.

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698