Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@mailbox.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod] [PATCH 5/5] bindings: cxx: Workaround --success run
Date: Thu, 08 Aug 2019 20:41:52 +0200	[thread overview]
Message-ID: <6061947.U0Wa8ctkoo@kongar> (raw)
In-Reply-To: <CAMRc=McmKs=5ToTRLgQ_f30DRtqq-57OZRw-EnL1gm_M1kqUXQ@mail.gmail.com>

 On Thursday, August 8, 2019, 5:27:14 PM CEST Bartosz Golaszewski wrote:
> śr., 7 sie 2019 o 21:51 Alexander Stein <alexander.stein@mailbox.org>
> napisał(a):
> >
> > If run with --success, all expressions are evaluated and printed out.
> > But REQUIRE_FALSE(chip) tries to iterate over the chip resulting in this
> > backtrace:
> > #0  gpiod_chip_num_lines (chip=chip@entry=0x0) at ../../lib/core.c:235
> > #1  gpiod_line_iter_new (chip=0x0) at ../../lib/iter.c:140
> > #2  gpiod::(anonymous namespace)::make_line_iter (chip=0x0) at ../../../bindings/cxx/iter.cpp:29
> > #3  gpiod::line_iter::line_iter (this=0x7fffffffd690, owner=...) at ../../../bindings/cxx/iter.cpp:109
> > #4  Catch::rangeToString<gpiod::chip> (range=...) at /usr/include/catch2/catch.hpp:1959
> > [...]
> >
> > Workaround by forcing catch2 to call gpiod::chip::operator bool().
> >
> > Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
> > ---
> > This actually looks like a flaw in the binding itself that the
> > gpiod::line_iter can't cope with an empty gpiod::chip.
> >
> 
> Do you want to submit a patch that fixes that? Otherwise I can fix it.
> I think that simply throwing an exception on empty chip is enough,
> right?

Reading that backtrace today, the actual problem is gpiod_chip_num_lines deferencing the nullptr.
There are 2 possibilities:
* if gpiod_chip is NULL in gpiod_line_iter_new(), return NULLL iter as well (which will raise an exception on line iter.cpp:31)
* return an iter with num_lines = 0

Can't rate the 2nd one if this will raise other problems.

Best regards,
Alexander




  reply	other threads:[~2019-08-08 18:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 19:51 [libgpiod] [PATCH 1/5] bindings: cxx: Use 'upstream' include path Alexander Stein
2019-08-07 19:51 ` [libgpiod] [PATCH 2/5] bindings: cxx: Try using pkg-config to detect catch2 Alexander Stein
2019-08-07 19:51 ` [libgpiod] [PATCH 3/5] bindings: cxx: Split out catch's main() Alexander Stein
2019-08-07 19:51 ` [libgpiod] [PATCH 4/5] bindings: cxx: Fix compile errors Alexander Stein
2019-08-08 15:25   ` Bartosz Golaszewski
2019-08-08 15:37     ` Bartosz Golaszewski
2019-08-07 19:51 ` [libgpiod] [PATCH 5/5] bindings: cxx: Workaround --success run Alexander Stein
2019-08-08 15:27   ` Bartosz Golaszewski
2019-08-08 18:41     ` Alexander Stein [this message]
2019-08-09  6:55       ` Bartosz Golaszewski

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=6061947.U0Wa8ctkoo@kongar \
    --to=alexander.stein@mailbox.org \
    --cc=brgl@bgdev.pl \
    --cc=linux-gpio@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox