Skip to contentSkip to conversation

sanity.bbclass: Lower the length of TMPDIR limit to 400

PATCH In review [email protected] 2 participants 2 messages Dec 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sanity.bbclass: Lower the length of TMPDIR limit to 400

From: Changqing Li <[email protected]>

When TMPDIR has length 410, bitbake uninative-tarball will fail at
do_populate_sdk with error: Failed to open backup database:
"TMPDIR/work/x86_64-nativesdk-pokysdk-linux/uninative-tarball/1.0/sdk/image/var/lib/dnf/history.sqlite"

sqlite3 has a hardcode max pathname limit 512, refer [1], and there is a
check, refer [2], pathname + 8 > max path name limit(512) is not
allowed. So the pathname length need to <= 504. While, length of "TMPDIR/work/x86_64-nativesdk-pokysdk-linux/uninative-tarball/1.0/sdk/image/var/lib/dnf/history.sqlite" is 505, so error happened.

We had met similar issue [3], and refer the comments, upstream reject the change of the hardcode length, see [4][5].

This patch try to improve and workaround this issue by lower max TMPDIR length to 400, at least for distro name length <=13, the build can success.

[1] https://github.com/sqlite/sqlite/blob/master/src/os_unix.c#L180
[2] https://github.com/sqlite/sqlite/blob/master/src/pager.c#L4777
[3] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12374
[4] https://sqlite.org/cgi/src/tktview/c060923a5422590b3734
[5] https://sqlite.org/forum/forumpost/0b1b8b5116

---
 meta/classes-global/sanity.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes-global/sanity.bbclass +2 -2
index a0b2508e11..7b8a497d5a 100644
@@ -760,8 +760,8 @@ def check_sanity_version_change(status, d):
     if not oes_bb_conf:
         status.addresult('You are not using the OpenEmbedded version of conf/bitbake.conf. This means your environment is misconfigured, in particular check BBPATH.\n')
 
-    # The length of TMPDIR can't be longer than 410
-    status.addresult(check_path_length(tmpdir, "TMPDIR", 410))
+    # The length of TMPDIR can't be longer than 400
+    status.addresult(check_path_length(tmpdir, "TMPDIR", 400))
 
     # Check that TMPDIR isn't located on nfs
     status.addresult(check_not_nfs(tmpdir, "TMPDIR"))
Signature · 1 line
2.25.1
#1 lore raw

I don't object to the fix, I just want to point out that this seems to deal with the unfortunate case of "C programmer's disease":

C Programmer's Disease: n.

The tendency of the undisciplined C programmer to set arbitrary but supposedly generous static limits on table sizes (defined, if you're lucky, by constants in header files) rather than taking the trouble to do proper dynamic storage allocation. If an application user later needs to put 68 elements into a table of size 50, the afflicted programmer reasons that he or she can easily reset the table size to 68 (or even as much as 70, to allow for future expansion) and recompile. This gives the programmer the comfortable feeling of having made the effort to satisfy the user's (unreasonable) demands, and often affords the user multiple opportunities to explore the marvelous consequences of fandango on core. In severe cases of the disease, the programmer cannot comprehend why each fix of this kind seems only to further disgruntle the user.

http://www.catb.org/jargon/html/C/C-Programmers-Disease.html

Alex

Quoted 58 lines · Changqing Li via lists.openembedded.org

From: Changqing Li <[email protected]>

When TMPDIR has length 410, bitbake uninative-tarball will fail at
do_populate_sdk with error: Failed to open backup database:
"TMPDIR/work/x86_64-nativesdk-pokysdk-linux/uninative-tarball/1.0/sdk/image/var/lib/dnf/history.sqlite"

sqlite3 has a hardcode max pathname limit 512, refer [1], and there is a
check, refer [2], pathname + 8 > max path name limit(512) is not
allowed. So the pathname length need to <= 504. While, length of "TMPDIR/work/x86_64-nativesdk-pokysdk-linux/uninative-tarball/1.0/sdk/image/var/lib/dnf/history.sqlite" is 505, so error happened.

We had met similar issue [3], and refer the comments, upstream reject the change of the hardcode length, see [4][5].

This patch try to improve and workaround this issue by lower max TMPDIR length to 400, at least for distro name length <=13, the build can success.

[1] https://github.com/sqlite/sqlite/blob/master/src/os_unix.c#L180
[2] https://github.com/sqlite/sqlite/blob/master/src/pager.c#L4777
[3] https://bugzilla.yoctoproject.org/show_bug.cgi?id=12374
[4] https://sqlite.org/cgi/src/tktview/c060923a5422590b3734
[5] https://sqlite.org/forum/forumpost/0b1b8b5116

---
 meta/classes-global/sanity.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes-global/sanity.bbclass +2 -3
index a0b2508e11..7b8a497d5a 100644
@@ -760,8 +760,8 @@ def check_sanity_version_change(status, d):
     if not oes_bb_conf:
         status.addresult('You are not using the OpenEmbedded version of conf/bitbake.conf. This means your environment is misconfigured, in particular check BBPATH.\n')
 
-    # The length of TMPDIR can't be longer than 410
-    status.addresult(check_path_length(tmpdir, "TMPDIR", 410))
+    # The length of TMPDIR can't be longer than 400
+    status.addresult(check_path_length(tmpdir, "TMPDIR", 400))
 
     # Check that TMPDIR isn't located on nfs
     status.addresult(check_not_nfs(tmpdir, "TMPDIR"))
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#209146): https://lists.openembedded.org/g/openembedded-core/message/209146
Mute This Topic: https://lists.openembedded.org/mt/110339915/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-