-
Notifications
You must be signed in to change notification settings - Fork 11
read()/write() buffers sometimes not printed correctly #42
Comments
Hi. I investigated on the code. First, the bug does not occur everytime, I would say it occurs 1/30 of the time when we are not lucky. Regarding the code, I think the following:
More particularly, I think this snippet cause the problem: if e.Typ == 0 && i+e.ContNr < len(events) {
for j := 0; j < e.ContNr; j++ {
param := events[i+1+j].Param
paramIdx := events[i+1+j].ParamIdx
argsStr[paramIdx] = ¶m
}
i += e.ContNr
} Indeed, we do not check the type of So, I would suggest to change it like this: diff --git a/pkg/straceback/event.go b/pkg/straceback/event.go
index 7f942fc..ff96e1d 100644
--- a/pkg/straceback/event.go
+++ b/pkg/straceback/event.go
@@ -139,10 +139,16 @@ func eventsToString(events []Event) (ret string) {
switch e.Typ {
case 0:
var argsStr [6]*string
- if e.Typ == 0 && i+e.ContNr < len(events) {
+ if i+e.ContNr < len(events) {
for j := 0; j < e.ContNr; j++ {
- param := events[i+1+j].Param
- paramIdx := events[i+1+j].ParamIdx
+ continuedEvent := events[i + 1 + j]
+
+ if continuedEvent.Typ != 2 {
+ continue
+ }
+
+ param := continuedEvent.Param
+ paramIdx := continuedEvent.ParamIdx
ret += fmt.Sprintf("Cont.type: %d Param: %s ParamIdx: %d ", events[i+1+j].Typ, param, paramIdx)
argsStr[paramIdx] = ¶m
} But I am not sure this would suffice as I was not able to test it thoroughly. Best regards. |
I think it is a good idea to check the type of the event before processing it. But I don't think it would fix this:
Example (source):
If you add the test It seems the root cause is that all events for cpu#0 are present twice in the array. This would cause the printing problem because the second "write" event would be consumed by eventsToString() while trying to get the "cont" event. Then, the 2 "cont" events are printed out of context. |
Closing as |
Following the instructions from demo-traceloop.md, I sometimes have this problem:
"3*7*2\n"
) is printed on a separate line.3
.The text was updated successfully, but these errors were encountered: