Bug 10644

Summary: Libnss uses deprecated function readdir_r()
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Zeeshan Ali <zeeshan.ali>
Component: connectivityAssignee: Jussi Kukkonen <jku>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bugzilla.ga, meta.mr.watcher, meta.watcher, ross.burton
Version: unspecified   
Target Milestone: 2.1.3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Zeeshan Ali 2016-11-11 11:11:34 UTC
libnss in krogoth branch is version 3.21 and it fails to build against glibc 2.24 if warnings are treated as errors, since it uses the deprecated readdir_r. Suggest either patching nss on krogoth or updating it to >= 3.24.
Comment 1 Zeeshan Ali 2016-11-11 11:12:29 UTC
Downstream bug: https://at.projects.genivi.org/jira/browse/GDP-442
Comment 2 Ross Burton 2016-11-11 11:13:44 UTC
Are warnings treated as errors by default?  There's a reason we do our best to stop any recipe that does this.
Comment 3 Ross Burton 2016-11-11 11:15:37 UTC
Oh I see, genivi adds -Werror flags back and then is surprised when stuff stops working.

Looks like a simple fix Zeeshan, and you have a test environment.  Can you send a patch?
Comment 4 Jussi Kukkonen 2016-11-11 11:28:30 UTC
(In reply to comment #2)
> Are warnings treated as errors by default?  There's a reason we do our best
> to stop any recipe that does this.

"-Werror=deprecated-declarations" specifically seems like a bad idea. I don't object to fixing specific cases depending on the situation but the idea that we would make a promise to never use deprecated APIs in the build is not realistic.
Comment 5 Ross Burton 2016-11-11 11:33:39 UTC
Absolutely, out of all the warnings to make critical that is one I wouldn't have picked...
Comment 6 Gunnar A / gunnarx 2016-11-11 11:48:10 UTC
> Oh I see, genivi adds -Werror flags back and then is surprised when stuff stops working.

I see nothing in the bug report that indicates that anyone is "surprised"
Comment 7 Gunnar A / gunnarx 2016-11-11 11:53:44 UTC
> I don't object to fixing specific cases depending on the situation

That's all anyone can ask for - that you (we, together) evaluate this case.  The deprecation in glibc seems to be due to the implementation of readlink_r being buggy and not thread safe.  Some references in the downstream bug Zeeshan linked to as well as which NSS versions have it fixed.

>the idea that we would make a promise to never use deprecated APIs in the build is not realistic.

Agreed and I don't think anyone is asking for that.
Comment 8 Zeeshan Ali 2016-11-11 12:05:47 UTC
(In reply to comment #3)
> Oh I see, genivi adds -Werror flags back and then is surprised when stuff
> stops working.
> 
> Looks like a simple fix Zeeshan, and you have a test environment.  Can you
> send a patch?

Yeah, I'm on it.
Comment 9 Ross Burton 2016-11-11 12:08:19 UTC
Patch policy says that fixes go into master and are then backported, so can you verify what releases the upstream fix is integrated into as well please.
Comment 10 Zeeshan Ali 2016-11-11 12:10:33 UTC
(In reply to comment #9)
> Patch policy says that fixes go into master and are then backported, so can
> you verify what releases the upstream fix is integrated into as well please.

IIRC neither master nor morty needs a fix since they use nss 3.24.
Comment 11 Ross Burton 2016-11-11 12:11:27 UTC
Great, please mention that in the patch to krogoth.
Comment 12 Jussi Kukkonen 2016-11-11 12:17:55 UTC
Thanks zeenix.

(In reply to comment #7)
> The deprecation in glibc seems to be due to the implementation of readlink_r
> being buggy and not thread safe.

I think there's a mistake here though (in addition to the /readdir_r/readlink_r/ typo): readdir() itself is _not_ thread safe by spec. 

You may be right about the bugs though.
Comment 13 Zeeshan Ali 2016-11-11 13:33:37 UTC
Turns out that Werror is actually being set by the nss package itself for GCC versions >= 4.8:

coreconf/Werror.mk:

  ifndef NSS_ENABLE_WERROR
    ifeq ($(OS_TARGET),Android)
      # Android lollipop generates the following warning:
      # error: call to 'sprintf' declared with attribute warning:
      #   sprintf is often misused; please use snprintf [-Werror]
      # So, just suppress -Werror entirely on Android
      NSS_ENABLE_WERROR = 0
      $(warning OS_TARGET is Android, disabling -Werror)
    else
      ifeq ($(CC_NAME),clang)
        # Clang reports its version as an older gcc, but it's OK
        NSS_ENABLE_WERROR = 1
      else
        CC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion))
        ifneq (,$(filter 4.8 4.9,$(word 1,$(CC_VERSION)).$(word 2,$(CC_VERSION))))
          NSS_ENABLE_WERROR = 1
        endif
        ifeq (,$(filter 0 1 2 3 4,$(word 1,$(CC_VERSION))))
          NSS_ENABLE_WERROR = 1
        endif
        ifndef NSS_ENABLE_WERROR
          $(warning Unable to find gcc 4.8 or greater, disabling -Werror)
          NSS_ENABLE_WERROR = 0
        endif
      endif                                                                                                                                 
    endif
  endif #ndef NSS_ENABLE_WERROR
Comment 14 Zeeshan Ali 2016-11-11 14:27:31 UTC
Patch sent to list.
Comment 15 Jussi Kukkonen 2016-12-07 09:59:50 UTC
Commit is in akuster/krogoth-next.
Comment 16 Jussi Kukkonen 2017-06-29 15:45:25 UTC
Commit is in krogoth branch (probably has been for some time), closing this.

commit cef5f86f43415ce8ca720d62c3d3bb1cb8fadb74
Author: Zeeshan Ali <zeeshanak@gnome.org>
Date:   Mon Nov 14 10:40:54 2016 +0100

    nss: Disable warning on deprecated API usage
    
    nss itself enables Werror if gcc is version 4.8 of greater, which fails
    the build against new glibc (2.24) because of use of readdir_r(), which
    is now deprecated. Let's just disable warnings on deprecated API usage.
    
    https://bugzilla.yoctoproject.org/show_bug.cgi?id=10644
    
    (From OE-Core rev: 6df5997bc0a7f7af73f625b172f99964cfed9f6e)