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

missing ellipsis when printing ConsString with undersized buffer #49

Open
davepacheco opened this issue Nov 12, 2015 · 0 comments
Open
Labels

Comments

@davepacheco
Copy link
Contributor

When you print most strings in mdb_v8, if the buffer is too small, it will truncate the output and insert a "[...]" to indicate that there's more output not shown. It doesn't always do this, though. I'm fixing a lot of these cases under issue #35, but while testing those changes I found another case that's not working properly that I'm not addressing in that change. The information below describes the behavior with my changes for #35, but the behavior is similarly incorrect before my changes.

I believe the issue is that when you have a ConsString of, say, str1 and str2, and the buffer size is exactly large enough to hold "str1", but not "str2", then we'll just print "str1" (and no ellipsis). Similarly, if the buffer size is large enough to hold "str1" and one character of "str2", then you'll get str1 plus "[" (as in the first part of "[...]"). The problem is basically that we don't consider truncation at all when processing ConsStrings. We only consider it when processing external strings, sequential strings, and sliced strings. As a result, we write out the whole first string without checking if we're nearing the end of the buffer, and then we may not have room left to write out even a whole ellipsis marker.

To be concrete, I found this string value in a jobsupervisor core that I've been using for testing:

> b44f39d5::v8str -v -N 0t16 
str b44f39d5: cons of b44f39c1 and a702721d
str b44f39c1: cons of b44f39ad and ade408b1
str b44f39ad: cons of b44f3921 and b44f3999
str b44f3921: cons of b44f38d1 and b44f390d
str b44f38d1: cons of b44f3881 and b44f38bd
str b44f3881: cons of b44f386d and a702721d
str b44f386d: cons of b44f3859 and a70299c1
str b44f3859: cons of bf4c54c9 and a700c369
str bf4c54c9: length 12 chars, slice 0 length -1 (actually 0 length 12)
str a700c369: length 1 chars, slice 0 length -1 (actually 0 length 1)
str a70299c1: length 9 chars, slice 0 length -1 (actually 0 length 9)
str a702721d: length 2 chars, slice 0 length -1 (actually 0 length 2)
str b44f38bd: cons of b44f38a9 and a702721d
str b44f38a9: cons of b44f3895 and b52586cd
str b44f3895: cons of bd0d3005 and a7019ab9
str bd0d3005: length 12 chars, slice 0 length -1 (actually 0 length 12)
str a7019ab9: length 2 chars, slice 0 length -1 (actually 0 length 2)
str b52586cd: slice of bd08b7e1 from 0 of length 16
str bd08b7e1: length 23 chars, slice 0 length 16 (actually 0 length 16)
str a702721d: length 2 chars, slice 0 length -1 (actually 0 length 2)
str b44f390d: cons of b44f38f9 and a702721d
str b44f38f9: cons of b44f38e5 and bf4ae931
str b44f38e5: cons of bd08bdbd and a7019ab9
str bd08bdbd: length 14 chars, slice 0 length -1 (actually 0 length 14)
str a7019ab9: length 2 chars, slice 0 length -1 (actually 0 length 2)
str bf4ae931: length 2 chars, slice 0 length -1 (actually 0 length 2)
str a702721d: length 2 chars, slice 0 length -1 (actually 0 length 2)
str b44f3999: cons of b44f3985 and a702721d
str b44f3985: cons of ade40825 and b44f3971
str ade40825: length 6 chars, slice 0 length -1 (actually 0 length 6)
str b44f3971: cons of b44f395d and fdef1a19
str b44f395d: cons of b44f3949 and bf4c54f9
str b44f3949: cons of b44f3935 and a700c369
str b44f3935: cons of bf4c54e1 and bf486ed1
str bf4c54e1: length 12 chars, slice 0 length -1 (actually 0 length 12)
str bf486ed1: length 4 chars, slice 0 length -1 (actually 0 length 4)
str a700c369: length 1 chars, slice 0 length -1 (actually 0 length 1)
str bf4c54f9: length 8 chars, slice 0 length -1 (actually 0 length 8)
str fdef1a19: length 4 chars, slice 0 length -1 (actually 0 length 4)
str a702721d: length 2 chars, slice 0 length -1 (actually 0 length 2)
str ade408b1: length 24 chars, slice 0 length -1 (actually 0 length 24)
str a702721d: length 2 chars, slice 0 length -1 (actually 0 length 2)
"HTTP/1.1 404 "

The whole string looks like this:

> b44f39d5::v8str -N 0t1024
"HTTP/1.1 404 Not Found\r\nContent-Type: application/json\r\nContent-Length: 60\r\nDate: Wed, 29 Apr 2015 17:11:33 GMT\r\nConnection: keep-alive\r\n\r\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant