#3 warning while building fl_wrapper.c on Ubuntu 20.04

Open
opened 4 years ago by amery · 4 comments
amery commented 4 years ago
Owner

sde-build-tools complains while building fl_wrapper.so and then it hangs

-> Building tools.cross/lib/fl_wrapper.so (/lib/x86_64-linux-gnu/libc.a).
fl_wrapper.c: In function 'readlink_from':
fl_wrapper.c:120:2: warning: passing argument 2 to restrict-qualified parameter aliases with argument 1 [-Wrestrict]
  120 |  if ((l = readlink(buf, buf, buf_len)) < 0)
      |  ^~
fl_wrapper.c: In function 'make_file_absolute.part.0':
fl_wrapper.c:312:37: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=]
  312 |   snprintf(absfile, PATH_MAX, "%s/%s", cwd, file);
      |                                     ^
In file included from /usr/include/stdio.h:867,
                 from fl_wrapper.h:40,
                 from fl_wrapper.c:45:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output 2 or more bytes (assuming 4097) into a destination of size 4096
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fl_wrapper.c: In function 'handle_fileat_access_after':
fl_wrapper.c:327:37: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=]
  327 |   snprintf(absfile, PATH_MAX, "%s/%s", cwd, file);
      |                                     ^
In file included from /usr/include/stdio.h:867,
                 from fl_wrapper.h:40,
                 from fl_wrapper.c:45:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output 2 or more bytes (assuming 4097) into a destination of size 4096
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-> Testing tools.cross/lib/fl_wrapper.so.

Ubuntu 20.04/x86_64 host

sde-build-tools complains while building fl_wrapper.so and then it _hangs_ ``` -> Building tools.cross/lib/fl_wrapper.so (/lib/x86_64-linux-gnu/libc.a). fl_wrapper.c: In function 'readlink_from': fl_wrapper.c:120:2: warning: passing argument 2 to restrict-qualified parameter aliases with argument 1 [-Wrestrict] 120 | if ((l = readlink(buf, buf, buf_len)) < 0) | ^~ fl_wrapper.c: In function 'make_file_absolute.part.0': fl_wrapper.c:312:37: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=] 312 | snprintf(absfile, PATH_MAX, "%s/%s", cwd, file); | ^ In file included from /usr/include/stdio.h:867, from fl_wrapper.h:40, from fl_wrapper.c:45: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output 2 or more bytes (assuming 4097) into a destination of size 4096 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fl_wrapper.c: In function 'handle_fileat_access_after': fl_wrapper.c:327:37: warning: '__builtin___snprintf_chk' output may be truncated before the last format character [-Wformat-truncation=] 327 | snprintf(absfile, PATH_MAX, "%s/%s", cwd, file); | ^ In file included from /usr/include/stdio.h:867, from fl_wrapper.h:40, from fl_wrapper.c:45: /usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output 2 or more bytes (assuming 4097) into a destination of size 4096 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -> Testing tools.cross/lib/fl_wrapper.so. ``` Ubuntu 20.04/x86_64 host
Poster
Owner

after solving the get_expanded issue, it doesn't hang but fails

-> Testing tools.cross/lib/fl_wrapper.so.
!> Detected a problem with the flist wrapper lib on your system.
!> Please specify another flist-creation system in your build configuration.
after solving the `get_expanded` issue, it doesn't hang but fails ``` -> Testing tools.cross/lib/fl_wrapper.so. !> Detected a problem with the flist wrapper lib on your system. !> Please specify another flist-creation system in your build configuration. ```
Poster
Owner

I didn't notice initially, but the main problem lies in

-> Building tools.cross/lib/fl_wrapper.so (/lib/x86_64-linux-gnu/libc.a).

sde-build-tools was fixed to prevent us from choosing a .a, and fl_wrapper.c improved to be more careful about the buffers and so prevent the warnings on this ticket.

both fixes merged to master

I didn't notice initially, but the main problem lies in ``` -> Building tools.cross/lib/fl_wrapper.so (/lib/x86_64-linux-gnu/libc.a). ``` `sde-build-tools` was fixed to prevent us from choosing a `.a`, and `fl_wrapper.c` improved to be more careful about the buffers and so prevent the warnings on this ticket. both fixes merged to `master`
amery closed this issue 4 years ago
Poster
Owner

on multilib hosts it's getting confused.

-> Building tools.cross/lib/fl_wrapper.so (/lib32/libc-2.31.so).
on multilib hosts it's getting confused. ``` -> Building tools.cross/lib/fl_wrapper.so (/lib32/libc-2.31.so). ```
amery reopened this issue 4 years ago
Poster
Owner

I reworked the code using ldd $SHELL... but I still don't know if we can trust that approach in further stages.

diff --git a/bin/sde-build-tools b/bin/sde-build-tools                  
index d2752a0..91b27ff 100755                                          
--- a/bin/sde-build-tools                                              
+++ b/bin/sde-build-tools
@@ -286,10 +286,21 @@ if [ ! -f $TOOLSDIR/.lastupdate ] ; then
        # Flist Wrapper Library
        #
        if [ "$SDECFG_FLIST" = "flwrapper" ] ; then
-               FLWRAPPER_LIBC=$(ls -1 \
-                       "$xroot"/lib*/{*/,}libc[.-]* 2> /dev/null |
-                       grep -v '\.a$' | grep '\.so' |
-                       sort -V | head -n1 )
+
+               find_libc_so() {
+                       # TODO: when is this criteria valid?
+                       # $SHELL's libc           
+                       if ldd /proc/$$/exe | grep 'libc[.-]' |
+                               sed -e 's:.* \(/[^ ]\+\) .*:\1:' | head -n1; then
+                               return
+                       fi
+
+                       # TODO: scan "$xroot"/lib*/{*/,}libc[.-]*
+               }
+
+               FLWRAPPER_LIBC=$(find_libc_so)
+               unset find_libc_so
+
                if [ ! -f "$FLWRAPPER_LIBC" ]; then
                        abort 'Unable to detect /lib/libc.* for flwrapper'
                fi
I reworked the code using `ldd $SHELL`... but I still don't know if we can trust that approach in further stages. ```diff diff --git a/bin/sde-build-tools b/bin/sde-build-tools index d2752a0..91b27ff 100755 --- a/bin/sde-build-tools +++ b/bin/sde-build-tools @@ -286,10 +286,21 @@ if [ ! -f $TOOLSDIR/.lastupdate ] ; then # Flist Wrapper Library # if [ "$SDECFG_FLIST" = "flwrapper" ] ; then - FLWRAPPER_LIBC=$(ls -1 \ - "$xroot"/lib*/{*/,}libc[.-]* 2> /dev/null | - grep -v '\.a$' | grep '\.so' | - sort -V | head -n1 ) + + find_libc_so() { + # TODO: when is this criteria valid? + # $SHELL's libc + if ldd /proc/$$/exe | grep 'libc[.-]' | + sed -e 's:.* \(/[^ ]\+\) .*:\1:' | head -n1; then + return + fi + + # TODO: scan "$xroot"/lib*/{*/,}libc[.-]* + } + + FLWRAPPER_LIBC=$(find_libc_so) + unset find_libc_so + if [ ! -f "$FLWRAPPER_LIBC" ]; then abort 'Unable to detect /lib/libc.* for flwrapper' fi ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.