Re: [libgpiod] [PATCH 5/5] bindings: cxx: Workaround --success run

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



czw., 8 sie 2019 o 20:41 Alexander Stein <alexander.stein@xxxxxxxxxxx>
napisał(a):
>
>  On Thursday, August 8, 2019, 5:27:14 PM CEST Bartosz Golaszewski wrote:
> > śr., 7 sie 2019 o 21:51 Alexander Stein <alexander.stein@xxxxxxxxxxx>
> > 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@xxxxxxxxxxx>
> > > ---
> > > 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
>
>
>

Hardening of argument validation in the core library (checking of
NULL-pointers, etc.) has been on my TODO list for some time now. It
seems I'll finally have to do it.

Thanks for the patches, all applied!

Bartosz




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux