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

Fix unsafe use of reflect.StringHeader/SliceHeader. #186

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

lthibault
Copy link
Collaborator

Fixes #185.

Benchmarks appear unaffected:

Before

BenchmarkTextMovementBetweenSegments-8              3560            294538 ns/op             336 B/op          4 allocs/op
BenchmarkMarshal-8                               2444696               505.8 ns/op           264 B/op          3 allocs/op
BenchmarkUnmarshal-8                             2159962               546.9 ns/op           192 B/op          3 allocs/op
BenchmarkUnmarshal_Reuse-8                       3018286               400.3 ns/op             0 B/op          0 allocs/op
BenchmarkDecode-8                                    349           3509860 ns/op         273.52 MB/s     2880309 B/op      40002 allocs/op
BenchmarkDecode_Reuse-8                              747           1591190 ns/op         603.32 MB/s         400 B/op          3 allocs/op
BenchmarkGrowth_SingleSegment-8                      162           7450082 ns/op         140.75 MB/s     4343128 B/op         10 allocs/op
BenchmarkGrowth_MultiSegment-8                       100          10165517 ns/op         103.15 MB/s     1648600 B/op         21 allocs/op
BenchmarkSmallMessage_SingleSegment-8            1720398               787.7 ns/op        91.41 MB/s        1352 B/op          5 allocs/op
BenchmarkSmallMessage_MultiSegment-8             2121964               561.8 ns/op       128.16 MB/s        1216 B/op          4 allocs/op

After

BenchmarkTextMovementBetweenSegments-8              4106            327906 ns/op             336 B/op          4 allocs/op
BenchmarkMarshal-8                               2297775               505.6 ns/op           264 B/op          3 allocs/op
BenchmarkUnmarshal-8                             2256856               532.1 ns/op           192 B/op          3 allocs/op
BenchmarkUnmarshal_Reuse-8                       3046434               385.7 ns/op             0 B/op          0 allocs/op
BenchmarkDecode-8                                    360           3294106 ns/op         291.43 MB/s     2880312 B/op      40002 allocs/op
BenchmarkDecode_Reuse-8                              708           1671720 ns/op         574.26 MB/s         400 B/op          3 allocs/op
BenchmarkGrowth_SingleSegment-8                      153           7366270 ns/op         142.35 MB/s     4343126 B/op         10 allocs/op
BenchmarkGrowth_MultiSegment-8                       100          10015142 ns/op         104.70 MB/s     1648598 B/op         21 allocs/op
BenchmarkSmallMessage_SingleSegment-8            1688142               705.4 ns/op       102.07 MB/s        1352 B/op          5 allocs/op
BenchmarkSmallMessage_MultiSegment-8             1987764               607.4 ns/op       118.54 MB/s        1216 B/op          4 allocs/op

@zenhack zenhack merged commit e33fd93 into main Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid use of reflect.SliceHeader and reflect.StringHeader could lead to memory corruption
2 participants