cmarty
Posts: 38
Joined: Thu Jul 19, 2012 7:23 am
Location: Czech Republic

How to free unused dispmanx layer (in case of SIGSEGV)

Thu Sep 07, 2017 10:57 am

Hello.
I have opengl app (using openframeworks).
I try to solve the situation when my program receive SIGSEGV (or for debug purpose I send him SIGSEGV signal) the program do not free dispmanx layer (resource) and last state of this dispmanx layer is still present on display. When I run program again the old dispmanx layer is still present and new dispmanx layer is created. Is there any way how I can remove, delete the old unused dispmanx layer/resource ?
For list of active dispmanx layers i use command "vcgencmd dispmanx_list"

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17880
Joined: Sat Jul 30, 2011 7:41 pm

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Thu Sep 07, 2017 11:50 am

Trap the SIG, do the dispmanx deallocation in the handler?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

Martin Frezman
Posts: 1021
Joined: Mon Oct 31, 2016 10:05 am

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Thu Sep 07, 2017 11:56 am

jamesh wrote:
Thu Sep 07, 2017 11:50 am
Trap the SIG, do the dispmanx deallocation in the handler?
Well, yes, but i assume the question is more: How do i do this after the fact? I.e., what if it has already happened?

Also:

Code: Select all

$ vcgencmd dispmanx_list 
error=1 error_msg="Command not registered"
$
If this post appears in the wrong forums category, my apologies.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 17880
Joined: Sat Jul 30, 2011 7:41 pm

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Thu Sep 07, 2017 12:32 pm

Martin Frezman wrote:
Thu Sep 07, 2017 11:56 am
jamesh wrote:
Thu Sep 07, 2017 11:50 am
Trap the SIG, do the dispmanx deallocation in the handler?
Well, yes, but i assume the question is more: How do i do this after the fact? I.e., what if it has already happened?

Also:

Code: Select all

$ vcgencmd dispmanx_list 
error=1 error_msg="Command not registered"
$
Nothing possible 'after it has happened' I suspect, without updated firmware. Big red switch time.But will double check with the dispmanx experts.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

blackshard83
Posts: 67
Joined: Fri Jan 10, 2014 8:31 am

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Tue Sep 26, 2017 11:51 am

AFAIK there is no documented way for a process to get the handle to a dispmanx layer of another process, so you can't free it after the leak.

Though I never tried to store the dispmanx handles somewhere (maybe on the filesystem) and let another process pick them up and do the calls to free them. From a process separation point of view dispmanx should not allow such thing, although it should automatically clean the garbage when the process dies... :roll:

Martin Frezman
Posts: 1021
Joined: Mon Oct 31, 2016 10:05 am

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Tue Sep 26, 2017 12:46 pm

Though I never tried to store the dispmanx handles somewhere (maybe on the filesystem) and let another process pick them up and do the calls to free them.
This sounds like a good exercise for the OP - given that he has, in his possession, a program that can crash, leaving a layer still visible. It sounds like he has most of what he needs at his fingertips.

All you need to do is add code to write out the handle to a file before the crash.
If this post appears in the wrong forums category, my apologies.

jwatte
Posts: 188
Joined: Sat Aug 13, 2011 7:28 pm

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Wed Oct 18, 2017 2:14 am

last state of this dispmanx layer is still present on display
Are you sure the process has actually died? If you check for it with "ps aux | grep <procname>" is it still alive?
It sounds like a pretty bad driver bug if somehow the OS lets resources stay allocated after a process goes away.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4435
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: How to free unused dispmanx layer (in case of SIGSEGV)

Wed Oct 18, 2017 8:53 am

Checking the firmware source there is handling for the VCHIQ service closing, and it does free up all resources.
As a quick test, taking hello_dispmanx and inserting a div0 before the sleep, the overlay comes up, and is then cleared up as the app. It is going through that VCHIQ service closing handler.

"vcgencmd dispmanx_list" was added to the firmware in September 2015. Are you running very old firmware? What does "vcgencmd version" report?
"vcgencmd commands" will list all the available commands that are registered.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 3 guests