Bug 240022 - sem_wait broken by r350481
Summary: sem_wait broken by r350481
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: threads (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-threads mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-21 18:25 UTC by andrew
Modified: 2019-08-24 13:24 UTC (History)
2 users (show)

See Also:


Attachments
testcase (311 bytes, text/plain)
2019-08-21 19:31 UTC, andrew
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description andrew 2019-08-21 18:25:38 UTC
r350481 confuses _pthread_cancel_enter and _thr_cancel_enter, which take different parameters (int vs. struct pthread *). The result is that sem_wait, which calls _pthread_cancel_enter(1), segfaults because it ends up in _thr_cancel_enter(1).

This breaks postgresql (easily reproduced by running regression tests) though it ought to be easily testable otherwise. (Originally reported to me by tmunro)

Affects current and 12-stable.
Comment 1 andrew 2019-08-21 19:31:43 UTC
Created attachment 206762 [details]
testcase

Testcase.
Comment 2 commit-hook freebsd_committer 2019-08-21 19:54:11 UTC
A commit references this bug:

Author: kib
Date: Wed Aug 21 19:53:51 UTC 2019
New revision: 351349
URL: https://svnweb.freebsd.org/changeset/base/351349

Log:
  Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.

  PR:	240022
  Reported by:	Andrew Gierth <andrew@tao11.riddles.org.uk>
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 days

Changes:
  head/lib/libthr/thread/thr_cancel.c
  head/lib/libthr/thread/thr_init.c
  head/lib/libthr/thread/thr_private.h
Comment 3 andrew 2019-08-23 11:47:28 UTC
Confirmed that this fixes the postgresql tests for me.
Comment 4 commit-hook freebsd_committer 2019-08-24 12:52:38 UTC
A commit references this bug:

Author: kib
Date: Sat Aug 24 12:51:47 UTC 2019
New revision: 351451
URL: https://svnweb.freebsd.org/changeset/base/351451

Log:
  MFC r351349:
  Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.

  PR:	240022

Changes:
_U  stable/12/
  stable/12/lib/libthr/thread/thr_cancel.c
  stable/12/lib/libthr/thread/thr_init.c
  stable/12/lib/libthr/thread/thr_private.h