From owner-freebsd-bugs@freebsd.org Mon Jul 24 22:26:04 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 210C9DAA2C2 for ; Mon, 24 Jul 2017 22:26:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EF3D7F3DD for ; Mon, 24 Jul 2017 22:26:04 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v6OMQ3mL065187 for ; Mon, 24 Jul 2017 22:26:03 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 219399] System panics after several hours of 14-threads-compilation orgies using poudriere on AMD Ryzen... Date: Mon, 24 Jul 2017 22:26:03 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-STABLE X-Bugzilla-Keywords: patch X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: truckman@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jul 2017 22:26:04 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D219399 --- Comment #108 from Don Lewis --- (In reply to Nils Beyer from comment #91) I'm pretty sure that ryzen_segv_test is actually broken. The first iterati= on of the loop in the t2 threadx() is unlocked and there is no guarantee that = it will have initialized things before thread1() tries to use them. Try this patch: --- ryzen_segv_test.c.orig 2017-07-24 14:26:23.851846000 -0700 +++ ryzen_segv_test.c 2017-07-24 15:02:33.998102000 -0700 @@ -291,29 +291,32 @@ atomic_store(&flg, 0); } +void threadx_core() +{ + uint8_t offset; + uint32_t randval; + + offset =3D random() % 256; + randval =3D random(); + memset(func_set, 0, sizeof(func_set_t)); + memcpy(&func_set->func[offset], func_base, FUNC_BYTES); + func_set->offset =3D offset; + func_set->ret =3D randval; +} + void threadx(void *p) { uint8_t offset; uint32_t randval; int init =3D 0; - if(p !=3D NULL) { - init =3D 1; - } //usleep(1000); while(atomic_load(&flg)) { offset =3D random() % 256; randval =3D random(); - if(!init) { - lock_enter(); - } else { - if(func_set =3D=3D MAP_FAILED) { - fprintf(stderr, "mmap returns MAP_FAILED!\n= "); - return; - } - init =3D 0; - } + lock_enter(); + // threadx_core(); memset(func_set, 0, sizeof(func_set_t)); memcpy(&func_set->func[offset], func_base, FUNC_BYTES); func_set->offset =3D offset; @@ -330,8 +333,7 @@ { int64_t loops; pthread_t t1, t2, t3; -#ifdef _MSC_VER -#else +#if !defined(_MSC_VER) && !defined(__FreeBSD__) cpu_set_t cpuset; int cpu; #endif @@ -349,19 +351,23 @@ n_cpus =3D sysconf(_SC_NPROCESSORS_ONLN); func_set =3D mmap (NULL, sizeof(func_set_t), PROT_READ | PROT_WRITE= | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #endif + if(func_set =3D=3D MAP_FAILED) { + fprintf(stderr, "mmap returns MAP_FAILED!\n"); + exit (1); + } atomic_store(&flg, 1); atomic_store(&locked, 1); srandom(time(NULL) + pid); // You should confirm assembly of generated code, just in case the compiler reorders mfence instruction + threadx_core(); mfence(); // Assure that flags are stored properly pthread_create(&t1, NULL, (void*)thread1, &loops); - pthread_create(&t2, NULL, (void*)threadx, (void*)1); + pthread_create(&t2, NULL, (void*)threadx, NULL); pthread_create(&t3, NULL, (void*)threadx, NULL); -#ifdef _MSC_VER -#else +#if !defined(_MSC_VER) && !defined(__FreeBSD__) cpu =3D random() % n_cpus; CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); --=20 You are receiving this mail because: You are the assignee for the bug.=