Skip to content

Probable race condition in error reporting of dataCallbacks #45

@mtrmac

Description

@mtrmac

These are WIP notes, just to have a thing to link to:

As a part of a larger problem where I see go test -count=1000 . hanging, I have noticed, on macOS

% go test -count=10000 -run TestData_callback_reading
--- FAIL: TestData_callback_reading (0.00s)
    data_test.go:135: interrupted system call
--- FAIL: TestData_callback_reading (0.00s)
    data_test.go:135: interrupted system call
--- FAIL: TestData_callback_reading (0.00s)
    data_test.go:135: operation timed out
FAIL

It doesn’t always fail but it does fail fairly frequently.

The immediate cause seems to be that the err != nil (errno != 0) check happens before checking n >= 0; the errno value has unspecified contents in that case.

That should be easy to fix…


… but:

Looking at the implementation, this is a Go call intermediating through GPGME and gogpgme_readfunc to another Go call — and that uses gpgme_err_set_errno (essentially an assignment to errno) to return an error state. I don’t see that there is any guarantee that the goroutine running gogpgme_readfunc will not be moved to another thread between the assignment and the return.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions