sccn / liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
Other
107 stars 63 forks source link

Garbage data in strings #126

Closed cboulay closed 3 years ago

cboulay commented 3 years ago

When using recent lsl.dll (either the 1.14.1b2 release I just made, or built from source locally), I often (within the first 5 strings) end up with garbage data in the marker. e.g.: [b'Test-1-2-3 is the time s\x8f\xc8+r 6']

This never happens with the release binaries from 1.14.0.

I'll try to pin down the commit.

cboulay commented 3 years ago

I suppose if I scanned the commit messages more closely then I could have spotted it immediately. Anyway, here's the output of git bisect

b3c5886b11f7aa3a9025901c371faca271dde948 is the first bad commit
commit b3c5886b11f7aa3a9025901c371faca271dde948
Author: Tristan Stenner <ttstenner@gmail.com>
Date:   Mon Mar 22 14:01:18 2021 +0100

    Fix pulling string samples with embedded NULL bytes

 src/lsl_inlet_c.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
cboulay commented 3 years ago

I reverted that commit now HEAD seems to work OK. I made a beta release just to confirm the CI-provided binaries were also OK.

https://github.com/sccn/liblsl/commit/4710977495d0b01e40e2cfb60ff9f9c20c547452

@tstenner I hope you can find another solution to whatever problem that commit was trying to fix. Let me know if you need help testing.

cboulay commented 3 years ago

I redid the original commit but added '\0' at the final char. So far it's good. https://github.com/sccn/liblsl/commit/679667f40b427439f436d8632d16fedbd215b3ec

tstenner commented 3 years ago

Thanks for fixing this.

malloc mostly returns zeroed memory, unless your libc is lazy, so on my test machines the last char was already 0. This had already happened to me back then in 2006, but I didn't think of it now.