[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] UBSAN flags
From: |
Greg Chicares |
Subject: |
Re: [lmi] UBSAN flags |
Date: |
Mon, 6 Jun 2022 23:46:41 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
On 6/6/22 21:57, Vadim Zeitlin wrote:
> On Mon, 6 Jun 2022 18:59:13 +0000 Greg Chicares <gchicares@sbcglobal.net>
> wrote:
[...]
> GC> Can you reproduce the 'actuarial_table_test' problem?
>
> I can't compile this file with -O3 because I get this error:
[...hearty snip...]
> I'm not sure what's going on here and I'm not sure if this is the
> same as the "illegal memory operation" mentioned above or not.
Yes, that seems the same as the messages I get.
> FWIW, if I
> change -O3 to -O2 for this file compilation, then it compiles fine and the
> resulting test runs without any errors.
Same here.
> But this error definitely looks
> worrisome, so I'll look into it unless you already understand what is it
> about -- if so, please let me know.
I have no idea at all. In the stack traces, I see nothing that
pertains to lmi except for the inclusion of standard headers
and this one line:
inlined from ‘std::vector<double> {anonymous}::table_256(int, int)’ at
actuarial_table_test.cpp:188:13:
where line 188 is:
v.insert(v.end(), qult + age - 10, qult + nult);
In table_256(), 'qsel' indeed has 213 = 71 * 3 elements. Similarly,
121 - 13 + 1 equals 109, and 'qult' does have 109 elements. These
arrays can't be overflowing any reasonable implementation limits.
It seems wise to add this assertion:
LMI_ASSERT(0 <= duration && duration <= 3);
+ LMI_ASSERT(10 <= age && age <= 80);
but it never fires. Because it never fires, this:
v.insert(v.end(), qult + age - 10, qult + nult);
looks valid, and in particular
qult + age - 10 // must be a valid "begin"
qult + nult // must be a valid (one-past-the-end) "end"
The test passes with the 'safestdlib' build type, which uses
-O0 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
so the "debug" version of libstdc++ considers this code valid.
It still passes if I change -O0 to -O2, and even if I change
it to -O3.
Dare we consider the possibility that UBSan is malfunctioning?
- Re: [lmi] Unit tests hygiene, Greg Chicares, 2022/06/03
- Re: [lmi] Unit tests hygiene, Vadim Zeitlin, 2022/06/03
- [lmi] UBSAN flags [Was: Unit tests hygiene], Greg Chicares, 2022/06/03
- Re: [lmi] UBSAN flags, Vadim Zeitlin, 2022/06/03
- Re: [lmi] UBSAN flags, Greg Chicares, 2022/06/03
- Re: [lmi] UBSAN flags, Vadim Zeitlin, 2022/06/04
- Re: [lmi] UBSAN flags, Greg Chicares, 2022/06/04
- Re: [lmi] UBSAN flags, Greg Chicares, 2022/06/06
- Re: [lmi] UBSAN flags, Vadim Zeitlin, 2022/06/06
- Re: [lmi] UBSAN flags,
Greg Chicares <=
- Re: [lmi] UBSAN flags, Vadim Zeitlin, 2022/06/06
- Re: [lmi] UBSAN flags, Greg Chicares, 2022/06/07