Fix buffer overflow in Trace's JNI layer
There doesn't appear to be anything better than blindly make a buffer 4x the length of a jstring if a maximum buffer size is useful. So do that. This does slightly regress Trace's performance. Before: android.os.TracePerfTest:INSTRUMENTATION_STATUS: enabled_mean=14 INSTRUMENTATION_STATUS: enabled_median=14 INSTRUMENTATION_STATUS: enabled_min=14 INSTRUMENTATION_STATUS: enabled_standardDeviation=0 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: beginEndSection_mean=3087 INSTRUMENTATION_STATUS: beginEndSection_median=3059 INSTRUMENTATION_STATUS: beginEndSection_min=3020 INSTRUMENTATION_STATUS: beginEndSection_standardDeviation=75 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: counter_mean=1893 INSTRUMENTATION_STATUS: counter_median=1900 INSTRUMENTATION_STATUS: counter_min=1851 INSTRUMENTATION_STATUS: counter_standardDeviation=26 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: asyncBeginEnd_mean=4281 INSTRUMENTATION_STATUS: asyncBeginEnd_median=4306 INSTRUMENTATION_STATUS: asyncBeginEnd_min=4184 INSTRUMENTATION_STATUS: asyncBeginEnd_standardDeviation=65 INSTRUMENTATION_STATUS_CODE: -1 After: android.os.TracePerfTest:INSTRUMENTATION_STATUS: enabled_mean=16 INSTRUMENTATION_STATUS: enabled_median=16 INSTRUMENTATION_STATUS: enabled_min=16 INSTRUMENTATION_STATUS: enabled_standardDeviation=0 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: beginEndSection_mean=3869 INSTRUMENTATION_STATUS: beginEndSection_median=3864 INSTRUMENTATION_STATUS: beginEndSection_min=3840 INSTRUMENTATION_STATUS: beginEndSection_standardDeviation=21 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: counter_mean=2511 INSTRUMENTATION_STATUS: counter_median=2503 INSTRUMENTATION_STATUS: counter_min=2480 INSTRUMENTATION_STATUS: counter_standardDeviation=35 INSTRUMENTATION_STATUS_CODE: -1 .INSTRUMENTATION_STATUS: asyncBeginEnd_mean=5348 INSTRUMENTATION_STATUS: asyncBeginEnd_median=5344 INSTRUMENTATION_STATUS: asyncBeginEnd_min=5318 INSTRUMENTATION_STATUS: asyncBeginEnd_standardDeviation=28 INSTRUMENTATION_STATUS_CODE: -1 But it also works correctly and doesn't crash, and that seems worth it. Fixes: 133104515 Test: systrace still works, AtraceHostTest passes, verified Trace.beginSection of 4-byte utf8 octets showed up in systrace Change-Id: Ie2e31227d9380df4190f9bc09ecd67f8a982827f
Loading
Please register or sign in to comment