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

[Bug]: ParseCTraceContext may be not memory-safe #32742

Open
1 task done
longjiquan opened this issue Apr 30, 2024 · 1 comment
Open
1 task done

[Bug]: ParseCTraceContext may be not memory-safe #32742

longjiquan opened this issue Apr 30, 2024 · 1 comment
Assignees
Labels
kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@longjiquan
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- Milvus version:
- Deployment mode(standalone or cluster):
- MQ type(rocksmq, pulsar or kafka):    
- SDK version(e.g. pymilvus v2.0.0rc2):
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

func ParseCTraceContext(ctx context.Context) C.CTraceContext {
span := trace.SpanFromContext(ctx)
traceID := span.SpanContext().TraceID()
spanID := span.SpanContext().SpanID()
return C.CTraceContext{
traceID: (*C.uint8_t)(unsafe.Pointer(&traceID[0])),
spanID: (*C.uint8_t)(unsafe.Pointer(&spanID[0])),
traceFlags: (C.uint8_t)(span.SpanContext().TraceFlags()),
}
}

Expected Behavior

spanID and traceID are local variables inner ParseCTraceContext, they may be garbage collected after return their address, so it's not safe to use them in cgo code.

Steps To Reproduce

No response

Milvus Log

No response

Anything else?

No response

@longjiquan longjiquan added kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 30, 2024
@longjiquan
Copy link
Contributor Author

/unassign @yanliang567
/assign @czs007 @congqixia

@sre-ci-robot sre-ci-robot assigned congqixia and czs007 and unassigned yanliang567 Apr 30, 2024
congqixia added a commit to congqixia/milvus that referenced this issue Apr 30, 2024
congqixia added a commit to congqixia/milvus that referenced this issue May 6, 2024
congqixia added a commit to congqixia/milvus that referenced this issue May 6, 2024
sre-ci-robot pushed a commit that referenced this issue May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Issues or changes related a bug needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants