Each side of the language barrier maintains a map of reference numbers to objects. Each entry has a reference count that exactly matches the number of active proxy objects on the other side. When a reference crosses the barrier, the count is incremented and when a proxy finalizer is run, the count is decremented. If the count reaches 0, the reference number and its object are removed from the map. There is a possibility that a reference number is passed to the other side, and the last proxy is then immediately garbage collected and finalized. The reference counter then reaches 0 before the other side has converted the reference number to its object, crashing the program. This is possible in both Go/Java/ObjC but is most likely to happen in ObjC because its own automatic reference count runtime frees objects as soon as they are statically never referenced again. Fix the race by always incrementing the reference count before sending a reference across the barrier. When converting the reference back into an object on the other side, decrement the counter again. Only the new ObjC test fails without this fix, but I left the Java counterpart in for good measure. Change-Id: I92743aabec275b4a5b82b952052e7e284872ce02 Reviewed-on: https://go-review.googlesource.com/21311 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
// Package gomobile_bind is an autogenerated binder stub for package ignore.
|
|
// gobind -lang=go ignore
|
|
//
|
|
// File is generated by gobind. Do not edit.
|
|
package gomobile_bind
|
|
|
|
/*
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include "seq.h"
|
|
#include "ignore.h"
|
|
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
_seq "golang.org/x/mobile/bind/seq"
|
|
)
|
|
|
|
// suppress the error if seq ends up unused
|
|
var _ = _seq.FromRefNum
|
|
|
|
// skipped field S.F with unsupported type: *types.Interface
|
|
|
|
// skipped method S.Argument with unsupported parameter or return types
|
|
|
|
// skipped method S.Result with unsupported parameter or return types
|
|
|
|
// skipped method I.Argument with unsupported parameter or return types
|
|
|
|
// skipped method I.Result with unsupported parameter or return types
|
|
|
|
type proxyignore_I _seq.Ref
|
|
|
|
func (p *proxyignore_I) Bind_proxy_refnum__() int32 { return (*_seq.Ref)(p).Bind_IncNum() }
|
|
|
|
// skipped method I.Argument with unsupported parameter or result types
|
|
// skipped method I.Result with unsupported parameter or result types
|
|
// skipped variable V with unsupported type *types.Interface
|
|
|
|
// skipped variable Var with unsupported type *types.Interface
|
|
|
|
// skipped function Argument with unsupported parameter or result types
|
|
// skipped function Result with unsupported parameter or result types
|