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

printf crashes with ValueError when integers are large #2107

Open
ale5000-git opened this issue Oct 25, 2024 · 2 comments
Open

printf crashes with ValueError when integers are large #2107

ale5000-git opened this issue Oct 25, 2024 · 2 comments

Comments

@ale5000-git
Copy link

ale5000-git commented Oct 25, 2024

Oils 0.23.0 installed with brew install --quiet oils-for-unix.

Currently this works: printf '%u\n' '9223372036854775807'
but this: printf '%u\n' '18446744073709551615'
instead give this error: libc++abi: terminating due to uncaught exception of type ValueError*

I think it is better if the code check what is really requested.
For "%d" and "%i" I think it should be cast to "long long",
instead for "%u", "%o" and "%x" it should be cast to "unsigned long long"
so that it will allow to use the full unsigned range.

@andychu
Copy link
Contributor

andychu commented Oct 28, 2024

Thanks for the report! I reproduced this

andychu pushed a commit that referenced this issue Oct 28, 2024
Also check for overflow in 'trap'.

It's already done to an extent in 'ulimit'.

This is part of #2107.
@andychu andychu changed the title Please allow full unsigned ranges in printf printf crashes with ValueError when integers are large Oct 28, 2024
@andychu
Copy link
Contributor

andychu commented Oct 28, 2024

I fixed Oils to check bounds

Unfortunately it doesn't distinguish between signed and unsigned now, so these are errors

We're looking into:

(details on Zulip)

Thanks for the report!

  printf %d 18446744073709551616                                                                                                           
         ^                                                           
[ -c flag ]:1: fatal: Integer too big: 18446744073709551616          
                                                                     
                                                                                                                                           
                                                                     
  printf %d -18446744073709551616                                                                                                          
         ^                                                           
[ -c flag ]:1: fatal: Integer too big: -18446744073709551616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants