netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Thomas Haller <thaller@redhat.com>
Cc: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [nft PATCH v4 4/6] py: fix exception during cleanup of half-initialized Nftables
Date: Wed, 16 Aug 2023 18:03:41 +0200	[thread overview]
Message-ID: <ZNzzXYeE8iTnL6mK@orbyte.nwl.cc> (raw)
In-Reply-To: <20230803193940.1105287-9-thaller@redhat.com>

On Thu, Aug 03, 2023 at 09:35:20PM +0200, Thomas Haller wrote:
> When we create a Nftables instance against an older library version,
> we might not find a symbol and fail with an exception when initializing
> the context object.
> 
> Then, __del__() is still called, but resulting in a second exception
> because self.__ctx is not set. Avoid that second exception.
> 
>     $ python -c 'import nftables; nftables.Nftables()'
>     Traceback (most recent call last):
>       File "<string>", line 1, in <module>
>       File "/data/src/nftables/py/nftables.py", line 90, in __init__
>         self.nft_ctx_input_get_flags = lib.nft_ctx_input_get_flags
>                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>       File "/usr/lib64/python3.11/ctypes/__init__.py", line 389, in __getattr__
>         func = self.__getitem__(name)
>                ^^^^^^^^^^^^^^^^^^^^^^
>       File "/usr/lib64/python3.11/ctypes/__init__.py", line 394, in __getitem__
>         func = self._FuncPtr((name_or_ordinal, self))
>                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>     AttributeError: /lib64/libnftables.so.1: undefined symbol: nft_ctx_input_get_flags
>     Exception ignored in: <function Nftables.__del__ at 0x7f6315a2c540>
>     Traceback (most recent call last):
>       File "/data/src/nftables/py/nftables.py", line 166, in __del__
>         self.nft_ctx_free(self.__ctx)
>         ^^^^^^^^^^^^^^^^^
>     AttributeError: 'Nftables' object has no attribute 'nft_ctx_free'
> 
> Signed-off-by: Thomas Haller <thaller@redhat.com>

Reviewed-by: Phil Sutter <phil@nwl.cc>

  reply	other threads:[~2023-08-16 16:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 19:35 [nft PATCH v4 0/6] add input flags and "no-dns"/"json" flags Thomas Haller
2023-08-03 19:35 ` [nft PATCH v4 1/6] src: add input flags for nft_ctx Thomas Haller
2023-08-16 15:49   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 2/6] src: add input flag NFT_CTX_INPUT_NO_DNS to avoid blocking Thomas Haller
2023-08-08 13:24   ` Phil Sutter
2023-08-08 20:05     ` Thomas Haller
2023-08-09 10:20       ` Phil Sutter
2023-08-09 19:17         ` Thomas Haller
2023-08-10  7:45           ` Phil Sutter
2023-08-10  8:43             ` Thomas Haller
2023-08-16 16:01               ` Phil Sutter
2023-08-18  9:45                 ` Thomas Haller
2023-08-16 16:02   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 3/6] src: add input flag NFT_CTX_INPUT_JSON to enable JSON parsing Thomas Haller
2023-08-16 16:02   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 4/6] py: fix exception during cleanup of half-initialized Nftables Thomas Haller
2023-08-16 16:03   ` Phil Sutter [this message]
2023-08-03 19:35 ` [nft PATCH v4 5/6] py: extract flags helper functions for set_debug()/get_debug() Thomas Haller
2023-08-16 16:04   ` Phil Sutter
2023-08-03 19:35 ` [nft PATCH v4 6/6] py: add Nftables.{get,set}_input() API Thomas Haller
2023-08-08 14:04   ` Phil Sutter
2023-08-08 20:07     ` Thomas Haller
2023-08-16 16:10   ` Phil Sutter
2023-08-18  9:45     ` Thomas Haller

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=ZNzzXYeE8iTnL6mK@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=thaller@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).