Skip to content

pointer to pointer crashes __sync_lock_release backend #12412

@llvmbot

Description

@llvmbot
Bugzilla Link 12040
Resolution FIXED
Resolved on Mar 15, 2012 20:48
Version trunk
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic

Extended Description

This bug affects: Apple clang version 3.1 (tags/Apple/clang-318.0.45) (based on LLVM 3.1svn)

Kyoto's Cabinet (http://fallabs.com/kyotocabinet/) kcthread.cc/SpinLock
uses a void* pointer to embed several kinds of locks depending of the platform.

If __sync_bool_compare_and_swap is avaliable it uses _sync_bool_compare_and_swap(&opq,0, 1) as a lock mechanism.

This won't compile in clang++ (but compiles on gcc) because the last elements are int and &opq_ is void**. Casting the argumets to void*

__sync_bool_compare_and_swap(&opq_, (void*)0, (void*)1)

makes clang accept the program but the backend crash with:

fatal error: error in backend: Cannot select: 0x106ed2510: i64,ch = AtomicSwap
      0x7ff8084ce648, 0x106ed2610, 0x106eac710
      [ID=5]
  0x106ed2610: i64,ch = CopyFromReg 0x7ff8084ce648, 0x106eac010 [ORD=940] [ID=4]
    0x106eac010: i64 = Register %vreg0 [ORD=940] [ID=1]
  0x106eac710: i64 = Constant<0> [ID=2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions