Re: Fwd: Bug#1050663: dar option --on-fly-isolate creates catalogue with broken slice_layout
Denis Corbin <[email protected]> Tue, 5 Sep 2023 23:27:33 +0200
| Newsgroups | gmane.comp.sysutils.backup.dar.support |
|---|---|
| Message-ID | <[email protected]> |
On 05/09/2023 21:59, Thomas wrote:
> Hi Denis!
>
Hi Thomas :)
[...]
>> In the slice_layout::older_sar_than_v8 (as well as some others) are public
>> and are either:
>> - initialized by the caller code (sar, macro_tools, ...) before calling
>> slice_layout::write() to write this to an dar backup
>
> I don't think this is the case. I got hunting with printf and a couple
> of compiler runs.
>
> My findings (as usual with DAR v2.7.11 and g++ 13):
>
> I dumped older_sar_than_v8 and tmp directly after the tmp ternary
> operator line like so:
>
> ,---- [ slice_layout.cpp ]
> | char tmp = older_sar_than_v8 ? OLDER_THAN_V8 : V8;
> | printf("older_sar_than_v8: >%d<, tmp: >%d<\n", older_sar_than_v8, tmp);
> `----
>
> I expected to see
> * for older_sar_than_v8: 0 or 1
> * for tmp: 56 or 55
>
> I get with dar_static --create ...:
> older_sar_than_v8: >88<, tmp: >-32<
> older_sar_than_v8: >88<, tmp: >-32<
> I interpret 88 as not initialized and -32 as a random number.
>
> If I initialize older_sar_than_v8 in slice_layout.hpp with true I get:
> older_sar_than_v8: >1<, tmp: >55<
> older_sar_than_v8: >1<, tmp: >55<
>
> If I initialize older_sar_than_v8 in slice_layout.hpp with false I get:
> older_sar_than_v8: >0<, tmp: >56<
> older_sar_than_v8: >0<, tmp: >56<
>
> I would say the default value comes trough and is not changed on the
> way. With a initialized older_sar_than_v8 the ternary operator works
> like a charm.
Yes, you are right and I came to the same conclusion!
By the way for the fun, the slice_layout class is used at two places:
- sar header (where the older_sar_than_v8 value is important and used)
- header_version (where this field has no importance! It must just have
a valid value written in the archive)
The first (sar) manages the slicing of a backup and has no problem here,
this class properly initialized the slice_layout object (object being
used like a C struct with added methods).
The second (header_version) is dropped at the beginning and at the end
of a backup and contains some global information on the backup (this is
the archive header/trailer described in the documentation). A
slice_layout is eventually included within that header_version, only for
isolated catalogues and then contains the slicing information of the
archive of reference (mainly to be able to have -Tslice option working
with isolated catalogues). Where from the problem to only be seen for
isolated catalogues, for normal backup there is no slice_layout included
in the archive header/trailer (aka header_version... yes, it was only an
archive header, long long ago...).
> Therefore I think older_sar_than_v8 is not initialized during
> dar_static --create... and the optimizer does with tmp whatever it
> wants.
>
> Fun fact:
> With my patch and no initialization the compiler handles it "better". 88
> is interpreted like "true" in the if-clause and we get at least
> char('7'):
> older_sar_than_v8: >88<, tmp: >55<
> older_sar_than_v8: >88<, tmp: >55<
yes, I would have expected 88 to be considered as a positive (= non-zero
value)... Weird thing from gcc here...
>
> Hope this helps.
>
> Tom
>
>
Thank you for you investigations!
Cheers,
Denis
OpenPGP_signature
(application/pgp-signature, 840 B) - not displayed