From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Stefan Weil <sw@weilnetz.de>,
Roman Bolshakov <r.bolshakov@yadro.com>,
Alexander Graf <agraf@csgraf.de>,
QEMU Developers <qemu-devel@nongnu.org>,
Peter Maydell <peter.maydell@linaro.org>
Subject: Re: macOS (Big Sur, Apple Silicon) 'make check' fails in test-crypto-tlscredsx509
Date: Tue, 2 Feb 2021 16:50:59 +0000 [thread overview]
Message-ID: <20210202165059.GQ4168502@redhat.com> (raw)
In-Reply-To: <6d360ded-f8b6-d08b-b4fc-af8c52554a58@redhat.com>
On Tue, Feb 02, 2021 at 08:50:24AM -0600, Eric Blake wrote:
> On 2/1/21 11:19 PM, Roman Bolshakov wrote:
>
> > After a session of debugging I believe there's an issue with Clang 12.
> > Here's a test program (it reproduces unexpected ASN1_VALUE_NOT_VALID
> > from _asn1_time_der() in libtasn1):
> >
> > #include <stdio.h>
> >
> > static int func2(char *foo) {
> > fprintf(stderr, "%s:%d foo: %p\n", __func__, __LINE__, foo);
> > if (foo == NULL) {
> > fprintf(stderr, "%s:%d foo: %p\n", __func__, __LINE__, foo);
> > return 1;
> > }
> > return 0;
> > }
> >
> > int func1(char *foo) {
> > int counter = 0;
> > if (fprintf(stderr, "IO\n") > 0)
> > counter += 10;
> > fprintf(stderr, "%s:%d foo: %p counter %d\n", __func__, __LINE__, foo, counter);
> > if(!func2(foo + counter)) {
>
> This line has unspecified behavior in the C standard. Adding an integer
> to a pointer is only well-specified if the pointer is to an array and
> the integer is within the bounds or the slot just past the array. But
> since you called func1(NULL), foo is NOT pointing to an array, and
> therefore foo+counter points to garbage, and the compiler is free to
> optimize it at will.
>
> > fprintf(stderr, "good\n");
> > return 0;
> > } else {
> > fprintf(stderr, "broken\n");
> > return 1;
> > }
> > }
> >
> > int main() {
> > char *foo = NULL;
> > return func1(foo);
> > }
> >
> >
> > What return value would you expect from the program?
>
> Because the code is not strictly compliant to the C standard, I'm not
> sure what to expect.
Roman invented this example to illustrate the problem with libtasn1,
so I wonder if this suggests that libtasn1 is relying on undefined
C behaviour too.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2021-02-02 16:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-26 16:32 macOS (Big Sur, Apple Silicon) 'make check' fails in test-crypto-tlscredsx509 Peter Maydell
2021-01-26 16:36 ` Daniel P. Berrangé
2021-01-26 16:41 ` Peter Maydell
2021-01-27 12:17 ` Daniel P. Berrangé
2021-01-27 12:35 ` Christian Schoenebeck
2021-01-27 12:38 ` Daniel P. Berrangé
2021-01-27 16:44 ` Stefan Weil
2021-01-27 16:53 ` Daniel P. Berrangé
2021-01-27 17:05 ` Stefan Weil
2021-01-27 18:17 ` Daniel P. Berrangé
2021-01-27 18:56 ` Stefan Weil
2021-01-27 18:59 ` Daniel P. Berrangé
2021-01-27 19:42 ` Stefan Weil
2021-01-27 20:57 ` Stefan Weil
2021-01-29 8:43 ` Roman Bolshakov
2021-01-29 9:53 ` Daniel P. Berrangé
2021-02-02 5:19 ` Roman Bolshakov
2021-02-02 14:19 ` qemu_oss--- via
2021-02-02 14:50 ` Eric Blake
2021-02-02 16:35 ` qemu_oss--- via
2021-02-02 17:14 ` Eric Blake
2021-02-02 20:31 ` Stefan Weil
2021-02-02 20:50 ` Stefan Weil
2021-02-03 10:00 ` Daniel P. Berrangé
2021-02-02 16:50 ` Daniel P. Berrangé [this message]
2021-02-03 14:28 ` Roman Bolshakov
2021-02-02 5:46 ` 罗勇刚(Yonggang Luo)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210202165059.GQ4168502@redhat.com \
--to=berrange@redhat.com \
--cc=agraf@csgraf.de \
--cc=eblake@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.