xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Opened 22 months ago

Closed 22 months ago

Last modified 6 months ago

#2451 closed defect (worksforme)

platform/xposix/appindicator_tray.py leaks a file descriptor in set_icon_from_data

Reported by: aerusso Owned by: aerusso
Priority: major Milestone: 4.0
Component: client Version: 3.0.x
Keywords: file descriptor leak Cc:

Description

When a new temporary file is created,

self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir)[1]

a file is opened (and its file descriptor is assigned to the [0] element of that tuple). That file is actually immediately clobbered---it is not used except to avoid races.

That file descriptor can just be immediately closed:

fd,self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir)   
os.close(fd)

This works (on Linux) and resolves the leak. It resolves an issue that looks like an unresponsive client (in my case right clicking just showed a blank box, with the colored border expected around windows). It failed with an error message like unable to create file descriptor or unable to open file (I've forgotten the exact wording).

Change History (6)

comment:1 Changed 22 months ago by Antoine Martin

Owner: changed from Antoine Martin to aerusso

Thanks, applied in r24161.

How about r24162 instead?

comment:2 Changed 22 months ago by aerusso

Do you think there is any merit in handling, e.g., out of space errors?

fd, self.tmp_filename = tempfile.mkstemp(prefix="tray", suffix=".png", dir=tmp_dir)
try:
    log("set_icon_from_data%s using temporary file %s",
        ("%s pixels" % len(pixels), has_alpha, w, h, rowstride), self.tmp_filename)
    os.write(fd, png_data)
finally:
    os.close(fd)
os.fchmod(fd, 0o644)

(Beware untested code.)

comment:3 Changed 22 months ago by Antoine Martin

Do you think there is any merit in handling, e.g., out of space errors?

r24165 should handle any errors in the section handling IO.

comment:4 Changed 22 months ago by Antoine Martin

Resolution: worksforme
Status: newclosed

comment:5 Changed 22 months ago by Antoine Martin

Milestone: 3.14.0

comment:6 Changed 6 months ago by migration script

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2451

Note: See TracTickets for help on using tickets.