Skip to content

Heap2Local bug on cmpxchng #8850

Description

@kripken
(module
 (rec
  (type $0 (sub (shared (array v128))))
  (type $1 (sub (shared (struct (field (mut (ref null $1)))))))
  (type $2 (shared (func (param (ref $5)) (result i32))))
  (type $3 (sub (func (param f64) (result contref))))
  (type $4 (sub (shared (struct (field i32) (field i8) (field (ref null $8)) (field (mut (ref (shared any)))) (field i32)))))
  (type $5 (func (param v128 f64) (result (ref null $1))))
  (type $6 (sub $0 (shared (array v128))))
  (type $7 (sub (shared (array v128))))
  (type $8 (sub $4 (shared (struct (field i32) (field i8) (field (ref null $8)) (field (mut (ref (shared any)))) (field i32)))))
  (type $9 (sub $4 (shared (struct (field i32) (field i8) (field (ref $8)) (field (mut (ref (shared any)))) (field i32) (field (mut (ref null (shared extern))))))))
  (type $10 (shared (func (param (ref null $5) f64 (ref null $3) i64 (ref $2) nullcontref (ref null $1)) (result (ref null $4) i32 (ref null $4) (ref $9) (ref null $11)))))
  (type $11 (sub $9 (shared (struct (field i32) (field i8) (field (ref $8)) (field (mut (ref (shared any)))) (field i32) (field (mut (ref null (shared extern))))))))
 )
 (export "func_482" (func $0))
 (@binaryen.js.called)
 (func $0 (type $5) (param $0 v128) (param $1 f64) (result (ref null $1))
  (local $2 (ref $1))
  (struct.atomic.rmw.xchg acqrel acqrel $1 0
   (local.tee $2
    (struct.new_default $1)
   )
   (struct.new $1
    (struct.atomic.rmw.cmpxchg acqrel acqrel $1 0
     (local.get $2)
     (struct.new_default $1)
     (struct.new_default $1)
    )
   )
  )
 )
)
$ bin/wasm-opt -all --fuzz-exec w.wat --heap2local
[fuzz-exec] export func_482
[fuzz-exec] note result: func_482 => null
[fuzz-exec] export func_482
[fuzz-exec] note result: func_482 => object(null)
[fuzz-exec] comparing func_482
values not identical! shared [ref (type $struct.0 (sub (shared (struct (field (mut (ref null $struct.0))))))) shared nullref] != shared nullref
[fuzz-exec] optimization passes changed results

This looks related to a worry we had back here:

#8491 (comment)

@tlively perhaps worth revisiting that, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions