[rust-dev] Impact of -ftrapv on Firefox

Daniel Micay danielmicay at gmail.com
Mon Jan 13 15:08:26 PST 2014


On Mon, Jan 13, 2014 at 6:42 AM, Robert O'Callahan <robert at ocallahan.org> wrote:
> On Mon, Jan 13, 2014 at 2:53 PM, Robert O'Callahan <robert at ocallahan.org>
> wrote:
>>
>> On Mon, Jan 13, 2014 at 2:22 PM, Daniel Micay <danielmicay at gmail.com>
>> wrote:
>>>
>>> -fsanitize=signed-integer-overflow: Signed integer overflow, including
>>> all the checks added by -ftrapv, and checking for overflow in signed
>>> division (INT_MIN / -1).
>>>
>>> Why not measure the impact of this on Firefox performance? We'll have
>>> a concrete answer about half of the picture (but not about the cost
>>> for unsigned or checks on overlong shifts and for division by zero).
>>
>>
>> That would give us neither an upper bound on overhead (due to excluding
>> unsigned), nor a lower bound (due to no range analysis or LLVM changes). But
>> it might be interesting...
>
>
> Just for fun I did a Firefox build with -ftrapv. The most surprising thing
> is that the browser actually worked, on Linux64 at least. Not so much on
> Linux32 and Mac. https://tbpl.mozilla.org/?tree=Try&rev=45b9932ca819
>
> The Talos performance results aren't exactly science, but it looks like the
> performance impact is negligible. For example, tp5o (page load time test)
> reported 285, central is around 280 (lower is better). Dromaeo-CSS reported
> 5408, whereas central is around 5500 (but noisy) (higher is better).
>
> Like I said, I don't really know what this means, but it sounds hopeful to
> me.
>
> Rob
> --
> Jtehsauts  tshaei dS,o n" Wohfy  Mdaon  yhoaus  eanuttehrotraiitny  eovni le
> atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o  Whhei csha iids  teoa
> stiheer :p atroa lsyazye,d  'mYaonu,r  "sGients  uapr,e  tfaokreg iyvoeunr,
> 'm aotr  atnod  sgaoy ,h o'mGee.t"  uTph eann dt hwea lmka'n?  gBoutt  uIp
> waanndt  wyeonut  thoo mken.o w

Is this with `clang`? I don't think `-ftrapv` actually works in `gcc`.

Simple test showing it doesn't work:

foo.c

```
#include <limits.h>

extern int bar;

int main(void) {
    int x = INT_MAX;
    int y = x + bar;
    return 0;
}
```

bar.c

```
int bar = 1;
```

gcc foo.c bar.c -ftrapv && ./a.out # no error
clang foo.c bar.c -ftrapv && ./a.out # zsh: illegal hardware instruction


More information about the Rust-dev mailing list