Bug 248420 - benchmarks/blogbench: rand()-related crash
Summary: benchmarks/blogbench: rand()-related crash
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Fernando Apesteguía
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-01 23:23 UTC by sigsys
Modified: 2020-08-11 17:02 UTC (History)
2 users (show)

See Also:
jmohacsi: maintainer-feedback+
fernape: merge-quarterly+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sigsys 2020-08-01 23:23:17 UTC
blogbench uses rand() from multiple threads which crashes due to PRNG state corruption.  The previous rand() implementation apparently had a simpler state which did not cause crashes (but probably was still being corrupted by concurrent use).

Patch switches it to arc4random(), which is thread-safe (but slower).

Index: benchmarks/blogbench/Makefile
===================================================================
--- benchmarks/blogbench/Makefile	(revision 543925)
+++ benchmarks/blogbench/Makefile	(working copy)
@@ -18,6 +18,10 @@
 
 OPTIONS_DEFINE=	DOCS
 
+post-patch:
+	@${REINPLACE_CMD} -Ee 's|[[:<:]]rand\(|arc4random(|g' \
+		"${WRKSRC}"/src/*.[ch]
+
 post-install:
 	${MKDIR} ${STAGEDIR}${DOCSDIR}
 	${INSTALL_DATA} ${WRKSRC}/${PORTDOCS} ${STAGEDIR}${DOCSDIR}
Comment 1 Fernando Apesteguía freebsd_committer 2020-08-05 17:37:49 UTC
(In reply to sigsys from comment #0)
Awaiting for maintainer response. I wonder how relevant this port is. It seems pretty abandoned, the WWW does not work (https://www.pureftpd.org/project/blogbench) and it was last updated 5 years ago...
Comment 2 sigsys 2020-08-06 05:39:43 UTC
(In reply to Fernando Apesteguía from comment #1)
Yeah. But it's very simple to use to stress test a FS and AFAIK it Just Works (well it used to before this problem) even though it's abandoned.

Open/Net/DragonflyBSD still have packages for it so it can be used to try to compare performance between them. Seems like Linux distros generally don't have it. There probably won't be much demand for it.

Only reason I know of it is that it got used a bunch to benchmark Dragonfly's own FS years ago and the name is easy to remember.
Comment 3 Janos Mohacsi 2020-08-11 15:06:24 UTC
I approve the patch.
Comment 4 commit-hook freebsd_committer 2020-08-11 16:59:51 UTC
A commit references this bug:

Author: fernape
Date: Tue Aug 11 16:59:12 UTC 2020
New revision: 544699
URL: https://svnweb.freebsd.org/changeset/ports/544699

Log:
  benchmarks/blogbench: fix rand()-related crash

  blogbench uses rand(3) unsafely from different threads which leads to crashes.
  Use arc4random(3) instead.

  Bump PORTREVISION

  While here, relocate USES variable.

  PR:	248420
  Submitted by:	sigsys@gmail.com
  Approved by:	jmohacsi@bsd.hu (maintainer)
  MFH:	2020Q3 (runtime fix)

Changes:
  head/benchmarks/blogbench/Makefile
Comment 5 commit-hook freebsd_committer 2020-08-11 17:01:53 UTC
A commit references this bug:

Author: fernape
Date: Tue Aug 11 17:01:50 UTC 2020
New revision: 544701
URL: https://svnweb.freebsd.org/changeset/ports/544701

Log:
  MFH: r544699

  benchmarks/blogbench: fix rand()-related crash

  blogbench uses rand(3) unsafely from different threads which leads to crashes.
  Use arc4random(3) instead.

  Bump PORTREVISION

  While here, relocate USES variable.

  PR:	248420
  Submitted by:	sigsys@gmail.com
  Approved by:	jmohacsi@bsd.hu (maintainer)

  Approved by:	ports-secteam (blanket, runtime fix)

Changes:
_U  branches/2020Q3/
  branches/2020Q3/benchmarks/blogbench/Makefile
Comment 6 Fernando Apesteguía freebsd_committer 2020-08-11 17:02:45 UTC
Committed,

Thanks!