Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check exponent value can be expressed in uint64_t #1623

Merged
merged 1 commit into from
Nov 20, 2020

Commits on Nov 20, 2020

  1. Check exponent value can be expressed in uint64_t

    Undefined Sanitizer found the following error.
    
    ```
    sudo ./src/bpftrace -e 'BEGIN {@ = 1e30;}'
    /home/ubuntu/work/bpftrace/src/utils.cpp:809:10: runtime error: 1e+30 is outside the range of representable values of type 'unsigned long'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ubuntu/work/bpftrace/src/utils.cpp:809:10 in
    Attaching 1 probe...
    ^C
    
    @: 0
    ```
    
    To fix this, in the parse_exponent(), check the exponent value and if
    it's bigger than uint64_t'x max value, throw exception. The Lexer then
    make an error.
    
    Now it becomes
    
    ```
    % sudo ./src/bpftrace -e 'BEGIN {@ = 1e30;}'
    stdin:1:12-16: ERROR: 1e30 is too big for uint64_t
    BEGIN {@ = 1e30;}
               ~~~~
    stdin:1:12-17: ERROR: syntax error, unexpected ;
    BEGIN {@ = 1e30;}
               ~~~~~
    ```
    mmisono committed Nov 20, 2020
    Configuration menu
    Copy the full SHA
    c5ce110 View commit details
    Browse the repository at this point in the history