[CDRIVER-2010] ISO8601 test fails with GCC 7 Created: 31/Jan/17 Updated: 03/May/17 Resolved: 22/Mar/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libbson |
| Affects Version/s: | 1.5.3 |
| Fix Version/s: | 1.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | Backlog - C Driver Team |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853483, "libbson: ftbfs with GCC-7"
In the Debian build log, the last test that succeeds is "/endian/swap64", so the test that fails must be the next one, "/bson/iso8601/utc". I rewrote the ISO8601 parser for GCC 7 is unreleased. I think we just need to fix this before Debian Buster with GCC 7 arrives, or other GCC 7 distributions. It's possible it's a new GCC bug that will be resolved without us. |
| Comments |
| Comment by Petr Pisar [ 13/Feb/17 ] | |||||||||
|
This is a patch I use for 1.6.0. I think you can remove CHAR_BIT and TYPE_BIT macros then. | |||||||||
| Comment by Petr Pisar [ 09/Feb/17 ] | |||||||||
|
Attached patch fixes it for time_t type as seen in libbson-1.5.0. With int64_t in libbson-1.6.0 you can use INT64_MAX and INT64_MIN from stdint.h directly. | |||||||||
| Comment by A. Jesse Jiryu Davis [ 08/Feb/17 ] | |||||||||
|
Brilliant Petr, thank you! | |||||||||
| Comment by Petr Pisar [ 08/Feb/17 ] | |||||||||
|
This caused by new GCC optimizations that finds a possible signed integer overflow in this piece of code:
and thus optimizes it out or deletes all you data or whatever undefined behavior you can imagine. This can be identified by compiling the code with -fsanitize=undefined compiler option and then it reports (output for libbson-1.5.3 with signed time_t, but should be the same for int64_t):
The for-loop multiplies lo variable 63 times, that means it goes up to 1*2^63 but maximal representable value is 2^63-1. |