Skip to content

Commit

Permalink
fix recover call missing without defer. check some nil deref.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunlee01 committed Mar 11, 2021
1 parent 75869fa commit 67ff775
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion scouterx/common/netdata/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ func StepsToBytes(steps []Step) []byte {
}
dout := NewDataOutputX(nil)
for _, step := range steps {
dout.WriteStep(step)
if step != nil {
dout.WriteStep(step)
}
}
return dout.Bytes()
}
Expand Down
22 changes: 11 additions & 11 deletions scouterx/strace/tracemain.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func StartTracingMode() {
}

func IsStream(ctx context.Context) bool {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
return false
}
Expand All @@ -39,7 +39,7 @@ func IsStream(ctx context.Context) bool {
}

func SetAsStream(ctx context.Context) bool {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
return false
}
Expand All @@ -52,7 +52,7 @@ func SetAsStream(ctx context.Context) bool {
}

func MarkAsError(ctx context.Context, errorMessage string) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
return
}
Expand All @@ -67,7 +67,7 @@ func MarkAsError(ctx context.Context, errorMessage string) {
}

func MarkAsErrorForcibly(ctx context.Context, errorMessage string) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
return
}
Expand All @@ -79,7 +79,7 @@ func MarkAsErrorForcibly(ctx context.Context, errorMessage string) {
}

func SetServiceNameForcibly(ctx context.Context, serviceName string) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
return
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func normalizeIp(ip string) string {
}

func EndHttpService(ctx context.Context, req *http.Request, res *http.Response) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
//TODO body (of specific service) profile from req.body

if res != nil {
Expand All @@ -209,7 +209,7 @@ func EndHttpService(ctx context.Context, req *http.Request, res *http.Response)
}

func StartService(ctx context.Context, serviceName, remoteIp string) (newCtx context.Context) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
ctx = context.Background()
}
Expand All @@ -223,13 +223,13 @@ func StartService(ctx context.Context, serviceName, remoteIp string) (newCtx con
}

func EndService(ctx context.Context) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
endAnyService(ctx)
}

func StartNewInheritanceService(ctx context.Context, parentTctx *netio.TraceContext) (newCtx context.Context, newTctx *netio.TraceContext) {
//TODO ctx를 전달받지 않아야 될 것 같긴한데...
common.ReportScouterPanic()
defer common.ReportScouterPanic()
if ctx == nil {
ctx = context.Background()
}
Expand Down Expand Up @@ -287,7 +287,7 @@ func inheritTctx(newTctx *netio.TraceContext, parentTctx *netio.TraceContext) *n
// myFunc(cascadeGoCtx)
//})
func GoWithTrace(ctx context.Context, serviceName string, func4Goroutine func(cascadeGoCtx context.Context)) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
newCtx, childTctx := startChildGoroutineService(ctx, serviceName)
go func() {
if childTctx != nil {
Expand Down Expand Up @@ -326,7 +326,7 @@ func startChildGoroutineService(ctx context.Context, serviceName string) (ctx4Go
}

func endChildGoroutineService(ctx context.Context) {
common.ReportScouterPanic()
defer common.ReportScouterPanic()
endAnyService(ctx)
}

Expand Down

0 comments on commit 67ff775

Please sign in to comment.