1. 06 9月, 2018 1 次提交
    • R
      define and use internal macros for hidden visibility, weak refs · 9b95fd09
      Rich Felker 提交于
      this cleans up what had become widespread direct inline use of "GNU C"
      style attributes directly in the source, and lowers the barrier to
      increased use of hidden visibility, which will be useful to recovering
      some of the efficiency lost when the protected visibility hack was
      dropped in commit dc2f368e, especially
      on archs where the PLT ABI is costly.
      9b95fd09
  2. 05 9月, 2018 6 次提交
  3. 03 9月, 2018 1 次提交
  4. 02 9月, 2018 1 次提交
  5. 01 9月, 2018 2 次提交
    • R
      always terminate by SIGABRT when abort is called · 9b14ad54
      Rich Felker 提交于
      Linux makes this surprisingly difficult, but it can be done. the trick
      here is using the fact that we control the implementation of sigaction
      to prevent changing the disposition of SIGABRT to anything but SIG_DFL
      after abort has tried and failed to terminate the process simply by
      calling raise(SIGABRT).
      9b14ad54
    • R
      optimize raise not to make a syscall for getting tid · 0b4c92b7
      Rich Felker 提交于
      assuming signals are blocked, which they are here, the tid in the
      thread structure is always valid and cannot change out from under us.
      0b4c92b7
  6. 30 8月, 2018 7 次提交
    • R
      prevent perror from clobbering stderr's orientation · cff4b910
      Rich Felker 提交于
      this requirement is specified by POSIX.
      cff4b910
    • R
      prevent psignal/psiginfo from clobbering stderr orientation, errno · cd8d8309
      Rich Felker 提交于
      these functions are specified to write to stderr but not set its
      orientation, presumably so that they can be used in programs operating
      stderr in wide mode. also, they are not allowed to clobber errno on
      success. save and restore to meet the requirement.
      
      psiginfo is reduced to a think wrapper around psignal, since it
      already behaved the same. if we want to add more detailed siginfo
      printing at some point this will need refactoring.
      cd8d8309
    • R
      make vfprintf set stream orientation even for zero-length output · a43a7b21
      Rich Felker 提交于
      if no output is produced, no underlying fwrite will ever be called,
      but byte-oriented printf functions are still required to set the
      orientation of the stream to byte-oriented. call __towrite explicitly
      if the FILE is not already in write mode.
      a43a7b21
    • R
      re-fix vfprintf temporary buffer logic · f1791f42
      Rich Felker 提交于
      commit b5a8b289 setup the write buffer
      bound pointers for the temporary buffer manually to fix a buffer
      overflow issue, but in doing so, caused vfprintf on unbuffered files
      never to call __towrite, thereby failing to set the stream orientation
      to byte-oriented, failing to clear any prior read mode, and failing to
      produce an error when the stream is not writable.
      
      revert the inline setup of the bounds pointers and instead zero them,
      so that the underlying fwrite code will call __towrite to set them up.
      f1791f42
    • R
      fix missing flush of stderr at exit if it was put in buffered mode · ddc947ed
      Rich Felker 提交于
      commit 0b80a7b0 added the ability to
      set application-provided stdio FILE buffers, adding the possibility
      that stderr might be buffered at exit time, but __stdio_exit did not
      have code to flush it.
      
      this regression was not present in any release.
      ddc947ed
    • R
      fix async thread cancellation on sh-fdpic · 35cd7c09
      Rich Felker 提交于
      if __cp_cancel was reached via __syscall_cp, r12 will necessarily
      still contain a GOT pointer (for libc.so or for the static-linked main
      program) valid for entering __cancel. however, in the case of async
      cancellation, r12 may contain any scratch value; it's not necessarily
      even a valid GOT pointer for the code that was interrupted.
      
      unlike in commit 0ec49dab where the
      corresponding issue was fixed for powerpc64, there is fundamentally no
      way for fdpic code to recompute its GOT pointer. so a new mechanism is
      introduced for cancel_handler to write a GOT register value into the
      interrupted context on archs where it is needed.
      35cd7c09
    • R
      fix async thread cancellation on powerpc64 · 0ec49dab
      Rich Felker 提交于
      entering the local entry point for __cancel from __cp_cancel is valid
      if __cp_cancel was reached from __syscall_cp, since both are in libc
      and share the same TOC pointer, but it is not valid if __cp_cancel was
      reached when cancel_handler rewrote the program counter for
      asynchronous cancellation of code outside libc.
      
      to ensure __cancel is entered with a valid TOC pointer, recompute the
      correct value in a PC-relative manner before jumping.
      0ec49dab
  7. 29 8月, 2018 10 次提交
    • A
      vfwprintf: honor field width with 'c' format type · 9cdaf1a8
      A. Wilcox 提交于
      9cdaf1a8
    • R
      fix several values reported by sysconf · d41cdef9
      Rich Felker 提交于
      - REALTIME_SIGNALS is supposed to be version-valued
      - DELAYTIMER_MAX was wrongly using the min allowed max
      - unavailable compilation environments wrongly used 0 instead of -1
      d41cdef9
    • R
      fix return value of system on failure to spawn child process · 1d297a28
      Rich Felker 提交于
      the value 0x7f00 (as if by _exit(127)) is specified only for the case
      where the child is created but then fails to exec the shell, since
      traditional fork+exec implementations do not admit reporting an error
      via errno in this case without additional machinery. it's unclear
      whether an implementation not subject to this failure mode needs to
      emulate it; one could read the standard as requiring that. if so,
      additional code will need to be added to map posix_spawn errors into
      the form system is expected to return. but for now, returning -1 to
      indicate an error is significantly better behavior than always
      reporting failures as if the shell failed to exec after fork.
      1d297a28
    • R
      set stream orientations in open_[w]memstream · b152d575
      Rich Felker 提交于
      fundamentally there is no good reason these functions need to set an
      orientation (morally it should be possible to write a wchar_t[] memory
      stream using byte functions, or a char[] memory stream using wide
      functions), but it's a part of the specification that they do. aside
      from being able to inspect the orientation with fwide, failure to set
      the orientation in open_wmemstream is observable if the locale changes
      between open_wmemstream and the first operation on the stream; this is
      because the encoding rule (locale) for the stream is required to be
      bound at the time the stream becomes wide-oriented.
      
      for open_wmemstream, call fwide to avoid duplicating the logic for
      binding the encoding rule. for open_memstream it suffices just to set
      the mode field in the FILE struct.
      b152d575
    • R
      make fmemopen's w+ mode truncate the buffer · f66022dd
      Rich Felker 提交于
      the w+ mode is specified to "truncate the buffer contents". like most
      of fmemopen, exactly what this means is underspecified. mode w and w+
      of course implicitly 'truncate' the buffer if a write from the initial
      position is flushed, so in order for this part of the text about w+
      not to be spurious, it should be interpreted as requiring something
      else, and the obvious reasonable interpretation is that the truncation
      is immediately visible if you attempt to read from the stream or the
      buffer before writing/flushing.
      
      this interpretation agrees with reported conformance test failures.
      f66022dd
    • R
      set errno when fileno is called on a FILE with no underlying fd · b39b47ba
      Rich Felker 提交于
      this is a POSIX requirement.
      
      also remove the gratuitous locking shenanigans and simply access f->fd
      under control of the lock. there is no advantage to not doing so, and
      it made the correctness non-obvious at best.
      b39b47ba
    • R
      reject invalid arguments to pthread_barrierattr_setpshared · baf95a5a
      Rich Felker 提交于
      this is a POSIX requirement.
      baf95a5a
    • S
      rewrite __aeabi_read_tp in asm · 056f9d81
      Szabolcs Nagy 提交于
      __aeabi_read_tp used to call c code, but that was incorrect as the
      arm runtime abi specifies special pcs for this function: it is only
      allowed to clobber r0, ip, lr and cpsr.
      
      maintainer's note: the old code explicitly saved and restored all
      general-purpose registers which are call-clobbered in the normal
      calling convention, so it's unlikely that any real-world compilers
      produced code that could break. however theoretically they could have
      chosen to use floating point registers, in which case the caller's
      values of those registers would be clobbered.
      056f9d81
    • R
      fix dubious char signedness check in limits.h · cdbbcfb8
      Rich Felker 提交于
      commit 201995f3 introduced a hack
      utilizing the signedness of character constants at the preprocessor
      level to avoid depending on the gcc-specific __CHAR_UNSIGNED__ predef.
      while this trick works on gcc and presumably other compilers being
      used, it's not clear that the behavior it depends on is actually
      conforming. C11 6.4.4.4 ¶10 defines character constants as having type
      int, and 6.10.1 ¶4 defines preprocessor #if arithmetic to take place
      in intmax_t or uintmax_t, depending on the signedness of the integer
      operand types, and it is specified that "this includes interpreting
      character constants".
      
      if character literals had type char and just promoted to int, it would
      be clear that when char is unsigned they should behave as uintmax_t at
      the preprocessor level. however, as written the text of the standard
      seems to require that character constants always behave as intmax_t,
      corresponding to int, at the preprocessor level.
      
      since there is a good deal of ambiguity about the correct behavior and
      a risk that compilers will disagree or that an interpretation may
      mandate a change in the behavior, do not rely on it for defining
      CHAR_MIN and CHAR_MAX correctly. instead, use the signedness of the
      value (as opposed to the type) of '\xff', which will be positive if
      and only if plain char is unsigned. this behavior is clearly
      specified, and the specific case '\xff' is even used in an example,
      under 6.4.4.4 of the standard.
      cdbbcfb8
    • R
      fix deadlock in async thread self-cancellation · 060ed936
      Rich Felker 提交于
      with async cancellation enabled, pthread_cancel(pthread_self())
      deadlocked due to pthread_kill holding killlock which is needed by
      pthread_exit.
      
      this could be solved by making pthread_kill block signals around the
      critical section, at least when the target thread is itself, but the
      issue only arises for cancellation, and otherwise would just be
      imposing unnecessary cost.
      
      instead just have pthread_cancel explicitly check for async
      self-cancellation and call pthread_exit(PTHREAD_CANCELED) directly
      rather than going through the signal machinery.
      060ed936
  8. 28 8月, 2018 1 次提交
    • A
      time: fix incorrect DST offset when using POSIX timezones without DST · 92c52644
      A. Wilcox 提交于
      This manifests itself in mktime if tm_isdst = 1 and the current TZ= is
      a POSIX timezone specification. mktime would see that tm_isdst was set
      to 0 by __secs_to_zone, and subtract 'oppoff' (dst_off) - gmtoff from
      the resultant time. This meant that mktime returned a time that was
      exactly double the GMT offset of the desired timezone when tm_isdst
      was = 1.
      92c52644
  9. 24 8月, 2018 3 次提交
    • S
      fix tls access on arm targets before armv6k · c06c1eb6
      Szabolcs Nagy 提交于
      commit 610c5a85 changed the thread
      pointer setup so tp points at the end of the pthread struct on arm,
      but failed to update __aeabi_read_tp so it was off by 8.
      
      this broke tls access in code that is compiled with -mtp=soft, which
      is the default when target arch is pre armv6k or thumb1.
      
      maintainer's note: no release versions are affected.
      c06c1eb6
    • R
      fix missing strerror text for EMULTIHOP · f4542fdf
      Rich Felker 提交于
      this is an obsolete error code from RFS, an obsolete predecessor of
      NFS. POSIX documents it only as "Reserved", but maintains the
      requirement that it be defined. as long as it is defined, it needs a
      string for strerror to produce; the one chosen matches glibc and
      documentation from other language runtimes I could find.
      f4542fdf
    • R
      fix printf precision specifier for hex floats on non-ld80 archs · cfa0a54c
      Rich Felker 提交于
      the code to perform rounding to the desired precision wrongly assumed
      the long double mantissa was an integral number of nibbles (hex
      digits) in length. this is true for 80-bit extended precision (64-bit
      mantissa) but not for double (53) or quad (113).
      
      scale the rounding value by 1<<(LDBL_MANT_DIG%4) to compensate.
      cfa0a54c
  10. 23 8月, 2018 2 次提交
    • R
      getopt: update optarg and optind correctly on missing argument · 6aeb131b
      Rich Felker 提交于
      the text of the specification for getopt's handling of options that
      require an argument, which requires updating optarg and optind, does
      not exclude the error case where the end of the argument list has been
      reached. in that case, it is expected that optarg be assigned
      argv[argc] (normally null) and optind be incremented by 2, resulting
      in a value of argc+1.
      6aeb131b
    • R
      fix FP_ILOGB0 and FP_ILOGBNAN definitions to be valid for use in #if · 184ef36f
      Rich Felker 提交于
      commit 98c9af50 wrongly claimed they
      do not need to be valid for such usage, but the last sentence of C11
      7.1.4 ¶1 imposes a broad requirement that all macros specified as
      integer constant expressions also need to be valid for #if.
      
      simply write the value out explicitly. there is no value here in
      pretending that the width of int will vary.
      184ef36f
  11. 21 8月, 2018 1 次提交
    • R
      remove erroneous SYMLINK_MAX definition from limits.h, pathconf · 767f7a10
      Rich Felker 提交于
      POSIX requires the symlink function to fail with ENAMETOOLONG if the
      link contents to be written exceed SYMLINK_MAX in length, but neither
      Linux nor our syscall wrapper code enforce this. the value 255 for
      SYMLINK_MAX is not meaningful and does not seem to have been motivated
      by anything except perhaps a wrong assumption that a definition was
      mandatory. it has been present (though moving through bits to
      top-level limits.h) since the beginning of the project history.
      
      [f]pathconf is entitled to return -1 as the limit for conf names for
      which there is no hard limit, with the usual POSIX note that an
      indefinite limit does not imply an infinite limit. in principle we
      might should report a limit for filesystems that impose one, but such
      functionality is not currently present for any of the pathconf limits,
      and adding it is beyond the scope of fixing the incorrect limit.
      767f7a10
  12. 18 8月, 2018 1 次提交
  13. 17 8月, 2018 1 次提交
    • R
      fix pthread_create return value with PTHREAD_EXPLICIT_SCHED · 91e1e29d
      Rich Felker 提交于
      due to moved code, commit b8742f32
      inadvertently used the return value of __clone, rather than the return
      value of SYS_sched_setscheduler in the new thread, to check whether it
      needed to report failure. since a successful __clone returns the tid
      of the new thread, which is never zero, this caused pthread_create
      always to return with an invalid error number in the code path for
      PTHREAD_EXPLICIT_SCHED.
      
      this regression was not present in any releases.
      91e1e29d
  14. 08 8月, 2018 1 次提交
    • R
      fix sign of strftime %z output with offsets <1 hour west of UTC · 1ad81388
      Rich Felker 提交于
      the sign character produced came from the sign of tm_gmtoff/3600 as an
      integer division, which is zero for negative offsets smaller in
      magnitude than 3600. instead of printing the hours and minutes as
      separate fields, print them as a single value of the form
      hours*100+minutes, which naturally has the correct sign.
      1ad81388
  15. 03 8月, 2018 1 次提交
    • R
      fix musl-gcc wrapper to be compatible with default-pie gcc toolchains · 7dad9c21
      Rich Felker 提交于
      the specfile for the wrapper was written assuming output is pie only
      if -pie appears on the command line. recent (and older patched)
      versions of gcc can be configured to produce pie output by default,
      adn when used with such a toolchain, the wrapper linked the wrong
      startfiles (crt*) containing pic-incompatible code.
      
      rather than trying to figure out gcc's default, simply always use the
      pic-compatible start files.
      7dad9c21
  16. 28 7月, 2018 1 次提交
    • R
      make pthread_attr_init honor defaults set by pthread_setattr_default_np · 14992d43
      Rich Felker 提交于
      this fixes a major gap in the intended functionality of
      pthread_setattr_default_np. if application/library code creating a
      thread does not pass a null attribute pointer to pthread_create, but
      sets up an attribute object to change other properties while leaving
      the stack alone, the created thread will get a stack with size
      DEFAULT_STACK_SIZE. this makes pthread_setattr_default_np useless for
      working around stack overflow issues in such applications, and leaves
      a major risk of regression if previously-working code switches from
      using a null attribute pointer to an attribute object.
      
      this change aligns the behavior more closely with the glibc
      pthread_setattr_default_np functionality too, albeit via a different
      mechanism. glibc encodes "default" specially in the attribute object
      and reads the actual default at thread creation time. with this
      commit, we now copy the current default into the attribute object at
      pthread_attr_init time, so that applications that query the properties
      of the attribute object will see the right values.
      14992d43