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

Parser unable to handle large floating point numbers #3389

Closed
2 of 5 tasks
sharathvemula opened this issue Mar 11, 2022 · 3 comments
Closed
2 of 5 tasks

Parser unable to handle large floating point numbers #3389

sharathvemula opened this issue Mar 11, 2022 · 3 comments
Labels
solution: invalid the issue is not related to the library

Comments

@sharathvemula
Copy link

When parsing JSON which has large floating point numbers, I'm observing program crash.

Please describe the steps to reproduce the issue.

  1. Make the repo locally
  2. Extract the Failure_repro.zip attached and place the test.cpp file in json/include/ folder.
  3. Compile using g++ -I. Test.cpp
  4. Parse a JSON file whose name is provided using command line arguments using

Can you provide a small but working code example?

ifstream json_file(argv[1])
auto j3 = json::parse(json_file)

Also, please check Test.cpp attached.

What is the expected behavior?

JSON should be parsed with no crash.

And what is the actual behavior instead?

The cpp file with the above code content crashed with error.

Which compiler and operating system are you using?

  • Compiler: gcc 9.4.0
  • Operating system: Ubuntu 20.04.3 LTS

Which version of the library did you use?

  • latest release version 3.10.5

  • other release - please state the version: ___
    Failure_repro.zip

  • the develop branch

If you experience a compilation error: can you compile and run the unit tests?

  • yes
  • no - please copy/paste the error message below
@nlohmann
Copy link
Owner

What is the error/exception message?

@nlohmann
Copy link
Owner

@nlohmann
Copy link
Owner

Your example well-exceeds any 64-bit number type. The library will throw

[json.exception.out_of_range.406] number overflow parsing '...' 

in this case which is the expected and documented behavior.

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants