Coder Social home page Coder Social logo

Comments (11)

ivmai avatar ivmai commented on June 16, 2024

Not observed on commit 9f6bc3b or earlier (build: https://app.travis-ci.com/github/ivmai/libatomic_ops/jobs/609611344).
Commit 418dfb5 seems to be the 1st one the issue could be reproduced at (with some occurrence rate).

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Build: https://app.travis-ci.com/github/ivmai/libatomic_ops/jobs/612448219
Source: master (e106a87)

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Build: https://app.travis-ci.com/github/ivmai/libatomic_ops/jobs/612743595
Source: master (42684a2)

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Source: master (42684a2)
Reproduced on cfarm203.
Compiler: gcc (Debian 13.2.0-6) 13.2.0

cd out && cmake -DCMAKE_BUILD_TYPE=MinSizeRel -Denable_assertions=ON -Denable_atomic_intrinsics=OFF -Dbuild_tests=ON -Denable_werror=ON -Werror=dev .. && cmake --build . && ctest

Or:
gcc -Isrc -D AO_DISABLE_GCC_ATOMICS -Os tests/test_atomic.c -lpthread && ./a.out

Or:
gcc -Isrc -D AO_DISABLE_GCC_ATOMICS -Os -D AO_PREFER_GENERALIZED -D AO_GENERALIZE_ASM_BOOL_CAS tests/test_atomic.c -lpthread && ./a.out

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Not reproduced with clang.
Not reproduced with -O0, -O1, -O2, -O3.

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Looks like an issues in the compiler (gcc), The potential workaround is to avoid "static" for counter1 variable (in tests/test_atomic.c). Diff of asm (generated by gcc -I src -D AO_DISABLE_GCC_ATOMICS -Os -S tests/test_atomic.c):

--- test_atomic.s
+++ test_atomic-after-workaround.s
@@ -470,7 +470,8 @@
 	cmpwi 3,3,1
 	.cfi_register 65, 0
 	.cfi_offset 70, 8
-	bl _savegpr0_28
+	bl _savegpr0_27
+	.cfi_offset 27, -40
 	.cfi_offset 28, -32
 	.cfi_offset 29, -24
 	.cfi_offset 30, -16
@@ -517,28 +518,29 @@
 	li 3,0
 	lwz 12,8(1)
 	mtcrf 24,12
-	b _restgpr0_28
+	b _restgpr0_27
 	.cfi_restore 31
 	.cfi_restore 30
 	.cfi_restore 29
 	.cfi_restore 28
+	.cfi_restore 27
 	.cfi_restore 65
 	.cfi_restore 70
 .L32:
 	.cfi_restore_state
 	mr 3,28
 	bl AO_load_acquire
-	ld 5,8(31)
+	ld 27,8(31)
 	mr 30,3
 	mr 3,28
-	std 5,112(1)
 	bl AO_load_acquire
-	ld 5,112(1)
+	cmpld 0,30,27
+	ld 5,8(31)
 	mr 6,3
-	cmpld 0,30,5
 	ble 0,.L35
 	addis 4,2,.LC7@toc@ha
 	mr 6,30
+	mr 5,27
 	addi 4,4,.LC7@toc@l
 .L40:
 	addis 9,2,.LC5@toc@ha
@@ -554,7 +556,7 @@
 	addi 4,4,.LC8@toc@l
 	b .L40
 	.long 0
-	.byte 0,0,0,3,128,4,0,0
+	.byte 0,0,0,3,128,5,0,0
 	.cfi_endproc
 .LFE57:
 	.size	acqrel_thr,.-.L.acqrel_thr
@@ -4960,6 +4962,7 @@
 .LFE62:
 	.size	main,.-.L.main
 	.globl junk
+	.globl counter1
 	.section	".data"
 	.align 3
 	.set	.LANCHOR1,. + 0

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Hello @sharkcz, could you please look at this issue? Seems to be a bug in gcc on ppc64.
I have prepared a W/A but i have not analyzed the asm code diff.

from libatomic_ops.

sharkcz avatar sharkcz commented on June 16, 2024

Hi @ivmai , does it need some special options/defines set to expose the issue? Our CI using Fedora 38 with gcc-13.2.1-4.fc38.ppc64le (snapshot from the gcc13 branch) hasn't seen it.

from libatomic_ops.

ivmai avatar ivmai commented on June 16, 2024

Exactly, you could reproduce it in 2 ways:
Type
git checkout 20390d7~1 && gcc -Isrc -D AO_DISABLE_GCC_ATOMICS -Os tests/test_atomic.c -lpthread && ./a.out

Or
git checkout 20390d7~1 && ./configure && make check CC=gcc CFLAGS_EXTRA="-D AO_DISABLE_GCC_ATOMICS -Os"

from libatomic_ops.

sharkcz avatar sharkcz commented on June 16, 2024

Thanks, reproduced.

from libatomic_ops.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.