Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault from @atomic operation on typed field (miscompilation?) #57190

Open
adienes opened this issue Jan 29, 2025 · 1 comment · May be fixed by #57208
Open

Segfault from @atomic operation on typed field (miscompilation?) #57190

adienes opened this issue Jan 29, 2025 · 1 comment · May be fixed by #57208
Labels
atomics compiler:codegen Generation of LLVM IR and native code regression 1.11 Regression in the 1.11 release

Comments

@adienes
Copy link
Contributor

adienes commented Jan 29, 2025

this MWE segfaults

mutable struct Atomic
    @atomic x::Int
end

function add_one!()
    @atomic (Atomic(0).x) += 1
end

add_one!() # segfaults

but note it works fine if either the ::Int is removed, or if the Atomic(0) is constructed before passing in

mutable struct Atomic
    @atomic x::Int
end

function add_one!(a)
    @atomic (a.x) += 1
end

add_one!(Atomic(0)) # works

bisected to #51720

@adienes adienes added atomics compiler:codegen Generation of LLVM IR and native code regression 1.11 Regression in the 1.11 release labels Jan 29, 2025
@vtjnash
Copy link
Member

vtjnash commented Jan 29, 2025

This is a bug in our AllocOptPass pass

frame #3: 0x0000000100febad0 libjulia-codegen.1.12.0.dylib`(anonymous namespace)::Optimizer::optimizeAll() [inlined] (anonymous namespace)::Optimizer::moveToStack(llvm::CallInst*, unsigned long, bool, llvm::AllocFnKind)::$_3::operator()(this=<unavailable>, user=0x00006000008ff810) const at llvm-alloc-opt.cpp:805:13 [opt]
   802 	            push_frame(gep, new_gep);
   803 	        }
   804 	        else {
-> 805 	            abort();
   806 	        }
   807 	    };
   808 	

(lldb) p user->dump()
  %7 = cmpxchg ptr addrspace(11) %4, i64 %5, i64 %6 seq_cst monotonic, align 8, !dbg !37, !tbaa !40, !alias.scope !35, !noalias !36

@gbaraldi gbaraldi linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
atomics compiler:codegen Generation of LLVM IR and native code regression 1.11 Regression in the 1.11 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants