Skip to contentSkip to conversation

Raise when filename of lockfile is too long to avoid infinite loop

PATCH In review Manuel Leonhardt 1 participant 2 messages Oct 31, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Raise when filename of lockfile is too long to avoid infinite loop

When a filename is passed to bb.utils.lockfile, which is longer than the filesystem can handle (usually more than 255 characters), an OSError with errno ENAMETOOLONG is thrown. Previously, this was not handled, which resulted in the function being trapped in an infinite loop.

This situation can happen easily when sharing an sstate cache with SSTATE_MIRROR via HTTP/S. The function generate_sstatefn in sstate.bbclass tries to reduce sstate filenames to less than 255 characters, however this function does not honor the ".lock" suffix added to the sstate file's name when it's downloaded from a http mirror in the pstaging_fetch function. Consequently, when the filename of the sstate file has more than 250 characters and ".lock" is added to the file's name the above described ENAMETOOLONG error is thrown, which causes populate tasks to hang indefinitely.

---
 lib/bb/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/utils.py +1 -1
index 70634910..d3b8d8ce 100644
@@ -487,7 +487,7 @@ def lockfile(name, shared=False, retry=True, block=False):
                     return lf
             lf.close()
         except OSError as e:
-            if e.errno == errno.EACCES:
+            if e.errno in (errno.EACCES, errno.ENAMETOOLONG):
                 logger.error("Unable to acquire lock '%s', %s",
                              e.strerror, name)
                 sys.exit(1)

--
2.33.1

_______________________________________________________
Manuel
Leonhardt
Softwareentwickler
​
ARRI
Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Herbert-Bayer-Str. 10,
80807
München
www.arri.com

+49 89 3809-1719
[email protected]

​
Get all the latest information from www.arri.com, Facebook, Twitter, Instagram and YouTube.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918 Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477 Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

​

#1 lore raw

This will only fix the error handling with long filenames. However, future changes might consider changing the control flow here, i.e., fail on all OSErrors except for those cases intended for the mode of operation.

See also https://lists.openembedded.org/g/openembedded-core/message/157691, where generate_sstatefn in sstate.bbclass is adapted to consider the .lock suffix when shorten filenames.