* [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
@ 2022-06-09 12:47 bugzilla
2022-06-09 15:25 ` Stephen Hemminger
2022-11-16 9:37 ` bugzilla
0 siblings, 2 replies; 7+ messages in thread
From: bugzilla @ 2022-06-09 12:47 UTC (permalink / raw)
To: dev
https://bugs.dpdk.org/show_bug.cgi?id=1030
Bug ID: 1030
Summary: rte_malloc() and rte_free() get stuck when used with
signal handler
Product: DPDK
Version: 22.03
Hardware: All
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: core
Assignee: dev@dpdk.org
Reporter: sarosh.arif@emumba.com
Target Milestone: ---
Created attachment 205
--> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
calls rte_malloc and rte_free in the handler and main code
I have a dpdk based application which uses rte_malloc() and rte_free()
frequently in it's main code. The general method to close the application is
though sending SIGINT. The application has a signal handler written for cleanup
purposes before closing the application. The handler also uses rte_free() to
release some of the memory during cleanup. The application gets stuck in a
deadlock.
Upon investigation I found out that both rte_free() and rte_malloc() use
rte_spinlock_lock() function to place a lock on heap. While this lock is placed
and the application receives SIGINT, it goes into the handler without releasing
the lock. Since the handler itself calls rte_free() which tries to acquire the
lock it gets stuck.
I have attached a sample application to reproduce this problem.
Steps to reproduce this problem:
1. compile the code provided in attachment with any version of dpdk
2. run the compiled binary
3. press ctrl+c till the prints stop
Actual Results:
The application gets stuck in either rte_free() or rte_malloc()
Expected Results:
Application should allocate and free the memory without getting stuck
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-09 12:47 [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler bugzilla
@ 2022-06-09 15:25 ` Stephen Hemminger
2022-06-10 6:04 ` Sarosh Arif
2022-11-16 9:37 ` bugzilla
1 sibling, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2022-06-09 15:25 UTC (permalink / raw)
To: bugzilla; +Cc: dev
On Thu, 09 Jun 2022 12:47:43 +0000
bugzilla@dpdk.org wrote:
> https://bugs.dpdk.org/show_bug.cgi?id=1030
>
> Bug ID: 1030
> Summary: rte_malloc() and rte_free() get stuck when used with
> signal handler
> Product: DPDK
> Version: 22.03
> Hardware: All
> OS: Linux
> Status: UNCONFIRMED
> Severity: normal
> Priority: Normal
> Component: core
> Assignee: dev@dpdk.org
> Reporter: sarosh.arif@emumba.com
> Target Milestone: ---
>
> Created attachment 205
> --> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
> calls rte_malloc and rte_free in the handler and main code
>
> I have a dpdk based application which uses rte_malloc() and rte_free()
> frequently in it's main code. The general method to close the application is
> though sending SIGINT. The application has a signal handler written for cleanup
> purposes before closing the application. The handler also uses rte_free() to
> release some of the memory during cleanup. The application gets stuck in a
> deadlock.
>
>
> Upon investigation I found out that both rte_free() and rte_malloc() use
> rte_spinlock_lock() function to place a lock on heap. While this lock is placed
> and the application receives SIGINT, it goes into the handler without releasing
> the lock. Since the handler itself calls rte_free() which tries to acquire the
> lock it gets stuck.
>
>
> I have attached a sample application to reproduce this problem.
>
>
> Steps to reproduce this problem:
>
> 1. compile the code provided in attachment with any version of dpdk
> 2. run the compiled binary
> 3. press ctrl+c till the prints stop
>
> Actual Results:
> The application gets stuck in either rte_free() or rte_malloc()
>
> Expected Results:
> Application should allocate and free the memory without getting stuck
>
rte_malloc and rte_free are not async sigsafe()
but then again regular glibc is not either.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-09 15:25 ` Stephen Hemminger
@ 2022-06-10 6:04 ` Sarosh Arif
2022-06-11 16:25 ` Mattias Rönnblom
0 siblings, 1 reply; 7+ messages in thread
From: Sarosh Arif @ 2022-06-10 6:04 UTC (permalink / raw)
To: bugzilla; +Cc: dev, Stephen Hemminger
On Thu, Jun 9, 2022 at 8:26 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Thu, 09 Jun 2022 12:47:43 +0000
> bugzilla@dpdk.org wrote:
>
> > https://bugs.dpdk.org/show_bug.cgi?id=1030
> >
> > Bug ID: 1030
> > Summary: rte_malloc() and rte_free() get stuck when used with
> > signal handler
> > Product: DPDK
> > Version: 22.03
> > Hardware: All
> > OS: Linux
> > Status: UNCONFIRMED
> > Severity: normal
> > Priority: Normal
> > Component: core
> > Assignee: dev@dpdk.org
> > Reporter: sarosh.arif@emumba.com
> > Target Milestone: ---
> >
> > Created attachment 205
> > --> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
> > calls rte_malloc and rte_free in the handler and main code
> >
> > I have a dpdk based application which uses rte_malloc() and rte_free()
> > frequently in it's main code. The general method to close the application is
> > though sending SIGINT. The application has a signal handler written for cleanup
> > purposes before closing the application. The handler also uses rte_free() to
> > release some of the memory during cleanup. The application gets stuck in a
> > deadlock.
> >
> >
> > Upon investigation I found out that both rte_free() and rte_malloc() use
> > rte_spinlock_lock() function to place a lock on heap. While this lock is placed
> > and the application receives SIGINT, it goes into the handler without releasing
> > the lock. Since the handler itself calls rte_free() which tries to acquire the
> > lock it gets stuck.
> >
> >
> > I have attached a sample application to reproduce this problem.
> >
> >
> > Steps to reproduce this problem:
> >
> > 1. compile the code provided in attachment with any version of dpdk
> > 2. run the compiled binary
> > 3. press ctrl+c till the prints stop
> >
> > Actual Results:
> > The application gets stuck in either rte_free() or rte_malloc()
> >
> > Expected Results:
> > Application should allocate and free the memory without getting stuck
> >
>
> rte_malloc and rte_free are not async sigsafe()
>
Oh, I did not know that. This should be mentioned in the documentation.
> but then again regular glibc is not either.
Memory allocated with glibc malloc() is freed by itself upon closing
the application. My application runs as a secondary process, and it
needs to use rte_malloc() specifically because the memory should be
shared between the two processes. If I don't free it upon closure it
would just be leaked. Is there any other solution for it?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-10 6:04 ` Sarosh Arif
@ 2022-06-11 16:25 ` Mattias Rönnblom
2022-06-13 9:48 ` Sarosh Arif
0 siblings, 1 reply; 7+ messages in thread
From: Mattias Rönnblom @ 2022-06-11 16:25 UTC (permalink / raw)
To: Sarosh Arif, bugzilla; +Cc: dev, Stephen Hemminger
On 2022-06-10 08:04, Sarosh Arif wrote:
> On Thu, Jun 9, 2022 at 8:26 PM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
>>
>> On Thu, 09 Jun 2022 12:47:43 +0000
>> bugzilla@dpdk.org wrote:
>>
>>> https://bugs.dpdk.org/show_bug.cgi?id=1030
>>>
>>> Bug ID: 1030
>>> Summary: rte_malloc() and rte_free() get stuck when used with
>>> signal handler
>>> Product: DPDK
>>> Version: 22.03
>>> Hardware: All
>>> OS: Linux
>>> Status: UNCONFIRMED
>>> Severity: normal
>>> Priority: Normal
>>> Component: core
>>> Assignee: dev@dpdk.org
>>> Reporter: sarosh.arif@emumba.com
>>> Target Milestone: ---
>>>
>>> Created attachment 205
>>> --> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
>>> calls rte_malloc and rte_free in the handler and main code
>>>
>>> I have a dpdk based application which uses rte_malloc() and rte_free()
>>> frequently in it's main code. The general method to close the application is
>>> though sending SIGINT. The application has a signal handler written for cleanup
>>> purposes before closing the application. The handler also uses rte_free() to
>>> release some of the memory during cleanup. The application gets stuck in a
>>> deadlock.
>>>
>>>
>>> Upon investigation I found out that both rte_free() and rte_malloc() use
>>> rte_spinlock_lock() function to place a lock on heap. While this lock is placed
>>> and the application receives SIGINT, it goes into the handler without releasing
>>> the lock. Since the handler itself calls rte_free() which tries to acquire the
>>> lock it gets stuck.
>>>
>>>
>>> I have attached a sample application to reproduce this problem.
>>>
>>>
>>> Steps to reproduce this problem:
>>>
>>> 1. compile the code provided in attachment with any version of dpdk
>>> 2. run the compiled binary
>>> 3. press ctrl+c till the prints stop
>>>
>>> Actual Results:
>>> The application gets stuck in either rte_free() or rte_malloc()
>>>
>>> Expected Results:
>>> Application should allocate and free the memory without getting stuck
>>>
>>
>> rte_malloc and rte_free are not async sigsafe()
>>
> Oh, I did not know that. This should be mentioned in the documentation.
Is there anything except <rte_atomic.h> that is/should be async-signal-safe?
>> but then again regular glibc is not either.
> Memory allocated with glibc malloc() is freed by itself upon closing
> the application. My application runs as a secondary process, and it
> needs to use rte_malloc() specifically because the memory should be
> shared between the two processes. If I don't free it upon closure it
> would just be leaked. Is there any other solution for it?
The standard solution is that the signal handler using some appropriate,
async-signal-safe way talks to the main thread, which then goes on to
cleanly terminate the application.
A write() to an fd, or an atomic store to a flag are two options.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-11 16:25 ` Mattias Rönnblom
@ 2022-06-13 9:48 ` Sarosh Arif
2022-10-05 17:30 ` Stephen Hemminger
0 siblings, 1 reply; 7+ messages in thread
From: Sarosh Arif @ 2022-06-13 9:48 UTC (permalink / raw)
To: Mattias Rönnblom; +Cc: bugzilla, dev, Stephen Hemminger
Thank you for help, I'll do it this way.
On Sat, Jun 11, 2022 at 9:25 PM Mattias Rönnblom <hofors@lysator.liu.se> wrote:
>
> On 2022-06-10 08:04, Sarosh Arif wrote:
> > On Thu, Jun 9, 2022 at 8:26 PM Stephen Hemminger
> > <stephen@networkplumber.org> wrote:
> >>
> >> On Thu, 09 Jun 2022 12:47:43 +0000
> >> bugzilla@dpdk.org wrote:
> >>
> >>> https://bugs.dpdk.org/show_bug.cgi?id=1030
> >>>
> >>> Bug ID: 1030
> >>> Summary: rte_malloc() and rte_free() get stuck when used with
> >>> signal handler
> >>> Product: DPDK
> >>> Version: 22.03
> >>> Hardware: All
> >>> OS: Linux
> >>> Status: UNCONFIRMED
> >>> Severity: normal
> >>> Priority: Normal
> >>> Component: core
> >>> Assignee: dev@dpdk.org
> >>> Reporter: sarosh.arif@emumba.com
> >>> Target Milestone: ---
> >>>
> >>> Created attachment 205
> >>> --> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
> >>> calls rte_malloc and rte_free in the handler and main code
> >>>
> >>> I have a dpdk based application which uses rte_malloc() and rte_free()
> >>> frequently in it's main code. The general method to close the application is
> >>> though sending SIGINT. The application has a signal handler written for cleanup
> >>> purposes before closing the application. The handler also uses rte_free() to
> >>> release some of the memory during cleanup. The application gets stuck in a
> >>> deadlock.
> >>>
> >>>
> >>> Upon investigation I found out that both rte_free() and rte_malloc() use
> >>> rte_spinlock_lock() function to place a lock on heap. While this lock is placed
> >>> and the application receives SIGINT, it goes into the handler without releasing
> >>> the lock. Since the handler itself calls rte_free() which tries to acquire the
> >>> lock it gets stuck.
> >>>
> >>>
> >>> I have attached a sample application to reproduce this problem.
> >>>
> >>>
> >>> Steps to reproduce this problem:
> >>>
> >>> 1. compile the code provided in attachment with any version of dpdk
> >>> 2. run the compiled binary
> >>> 3. press ctrl+c till the prints stop
> >>>
> >>> Actual Results:
> >>> The application gets stuck in either rte_free() or rte_malloc()
> >>>
> >>> Expected Results:
> >>> Application should allocate and free the memory without getting stuck
> >>>
> >>
> >> rte_malloc and rte_free are not async sigsafe()
> >>
> > Oh, I did not know that. This should be mentioned in the documentation.
>
> Is there anything except <rte_atomic.h> that is/should be async-signal-safe?
>
> >> but then again regular glibc is not either.
> > Memory allocated with glibc malloc() is freed by itself upon closing
> > the application. My application runs as a secondary process, and it
> > needs to use rte_malloc() specifically because the memory should be
> > shared between the two processes. If I don't free it upon closure it
> > would just be leaked. Is there any other solution for it?
>
> The standard solution is that the signal handler using some appropriate,
> async-signal-safe way talks to the main thread, which then goes on to
> cleanly terminate the application.
>
> A write() to an fd, or an atomic store to a flag are two options.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-13 9:48 ` Sarosh Arif
@ 2022-10-05 17:30 ` Stephen Hemminger
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2022-10-05 17:30 UTC (permalink / raw)
To: Sarosh Arif; +Cc: Mattias Rönnblom, bugzilla, dev
On Mon, 13 Jun 2022 14:48:45 +0500
Sarosh Arif <sarosh.arif@emumba.com> wrote:
> Thank you for help, I'll do it this way.
>
> On Sat, Jun 11, 2022 at 9:25 PM Mattias Rönnblom <hofors@lysator.liu.se> wrote:
> >
> > On 2022-06-10 08:04, Sarosh Arif wrote:
> > > On Thu, Jun 9, 2022 at 8:26 PM Stephen Hemminger
> > > <stephen@networkplumber.org> wrote:
> > >>
> > >> On Thu, 09 Jun 2022 12:47:43 +0000
> > >> bugzilla@dpdk.org wrote:
> > >>
> > >>> https://bugs.dpdk.org/show_bug.cgi?id=1030
> > >>>
> > >>> Bug ID: 1030
> > >>> Summary: rte_malloc() and rte_free() get stuck when used with
> > >>> signal handler
> > >>> Product: DPDK
> > >>> Version: 22.03
> > >>> Hardware: All
> > >>> OS: Linux
> > >>> Status: UNCONFIRMED
> > >>> Severity: normal
> > >>> Priority: Normal
> > >>> Component: core
> > >>> Assignee: dev@dpdk.org
> > >>> Reporter: sarosh.arif@emumba.com
> > >>> Target Milestone: ---
> > >>>
> > >>> Created attachment 205
> > >>> --> https://bugs.dpdk.org/attachment.cgi?id=205&action=edit
> > >>> calls rte_malloc and rte_free in the handler and main code
> > >>>
> > >>> I have a dpdk based application which uses rte_malloc() and rte_free()
> > >>> frequently in it's main code. The general method to close the application is
> > >>> though sending SIGINT. The application has a signal handler written for cleanup
> > >>> purposes before closing the application. The handler also uses rte_free() to
> > >>> release some of the memory during cleanup. The application gets stuck in a
> > >>> deadlock.
> > >>>
> > >>>
> > >>> Upon investigation I found out that both rte_free() and rte_malloc() use
> > >>> rte_spinlock_lock() function to place a lock on heap. While this lock is placed
> > >>> and the application receives SIGINT, it goes into the handler without releasing
> > >>> the lock. Since the handler itself calls rte_free() which tries to acquire the
> > >>> lock it gets stuck.
> > >>>
> > >>>
> > >>> I have attached a sample application to reproduce this problem.
> > >>>
> > >>>
> > >>> Steps to reproduce this problem:
> > >>>
> > >>> 1. compile the code provided in attachment with any version of dpdk
> > >>> 2. run the compiled binary
> > >>> 3. press ctrl+c till the prints stop
> > >>>
> > >>> Actual Results:
> > >>> The application gets stuck in either rte_free() or rte_malloc()
> > >>>
> > >>> Expected Results:
> > >>> Application should allocate and free the memory without getting stuck
> > >>>
> > >>
> > >> rte_malloc and rte_free are not async sigsafe()
> > >>
> > > Oh, I did not know that. This should be mentioned in the documentation.
> >
> > Is there anything except <rte_atomic.h> that is/should be async-signal-safe?
> >
> > >> but then again regular glibc is not either.
> > > Memory allocated with glibc malloc() is freed by itself upon closing
> > > the application. My application runs as a secondary process, and it
> > > needs to use rte_malloc() specifically because the memory should be
> > > shared between the two processes. If I don't free it upon closure it
> > > would just be leaked. Is there any other solution for it?
> >
> > The standard solution is that the signal handler using some appropriate,
> > async-signal-safe way talks to the main thread, which then goes on to
> > cleanly terminate the application.
> >
> > A write() to an fd, or an atomic store to a flag are two options.
Patch is pending (why is it not merged?) to describe what is signal safe.
https://patchwork.dpdk.org/project/dpdk/patch/20220711230448.557715-1-stephen@networkplumber.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler
2022-06-09 12:47 [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler bugzilla
2022-06-09 15:25 ` Stephen Hemminger
@ 2022-11-16 9:37 ` bugzilla
1 sibling, 0 replies; 7+ messages in thread
From: bugzilla @ 2022-11-16 9:37 UTC (permalink / raw)
To: dev
https://bugs.dpdk.org/show_bug.cgi?id=1030
Thomas Monjalon (thomas@monjalon.net) changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from Thomas Monjalon (thomas@monjalon.net) ---
Resolved in http://git.dpdk.org/dpdk/commit/?id=8f8e8f0226
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-16 9:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 12:47 [Bug 1030] rte_malloc() and rte_free() get stuck when used with signal handler bugzilla
2022-06-09 15:25 ` Stephen Hemminger
2022-06-10 6:04 ` Sarosh Arif
2022-06-11 16:25 ` Mattias Rönnblom
2022-06-13 9:48 ` Sarosh Arif
2022-10-05 17:30 ` Stephen Hemminger
2022-11-16 9:37 ` bugzilla
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).