MIOpen icon indicating copy to clipboard operation
MIOpen copied to clipboard

User database file corrupted under Windows

Open stmuxa opened this issue 6 years ago • 6 comments

If you guys will eventually support Windows platform, it is better to use ios::binary openmode here: https://github.com/ROCmSoftwarePlatform/MIOpen/blob/7a1833b9e645848b470fdb3e279aa2423f60282c/src/db.cpp#L267 https://github.com/ROCmSoftwarePlatform/MIOpen/blob/7a1833b9e645848b470fdb3e279aa2423f60282c/src/db.cpp#L276 Here we have a problem with new line characters, it's 2 bytes under Windows (vs 1 byte under Unix), each database record update introduces 1 byte shift, hence database becomes corrupted without ios::binary.

stmuxa avatar Sep 04 '19 12:09 stmuxa

It is better to open text files in text mode. You have to configure git properly I guess. https://help.github.com/en/articles/configuring-git-to-handle-line-endings

atamazov avatar Sep 04 '19 14:09 atamazov

I was talking about user db. It has nothing to do with git.

stmuxa avatar Sep 04 '19 14:09 stmuxa

Here is what I saw: Consider text file:

AAA<CRLF>
BBB<CRLF>

(where <CRLF> is a newline under windows platform) and inside this call https://github.com/ROCmSoftwarePlatform/MIOpen/blob/7a1833b9e645848b470fdb3e279aa2423f60282c/src/db.cpp#L287 you want to copy first line from stream from to stream to, and pos->begin = 5 points to the beginning of the second line (in bytes). You use ifstream::read function to do so: from.read(buffer, 5);. This extracts 5 characters from stream from, but <CRLF> is replaced by \n. So, the buffer contents after read is AAA\nB (5 chars). This is what I was talking about,

stmuxa avatar Sep 04 '19 15:09 stmuxa

Now I see, thanks for the explanation.

atamazov avatar Sep 04 '19 15:09 atamazov

@stmuxa Please check if this is still an issue with latest ROCm 6.1.1? If not, please close ticket. Thanks!

ppanchad-amd avatar Jun 03 '24 20:06 ppanchad-amd

@ppanchad-amd I am not a part of a team anymore. Please, contact repo owner.

stmuxa avatar Jun 04 '24 07:06 stmuxa

The issue has been fixed with this PR: https://github.com/ROCm/MIOpen/pull/2515

taylding-amd avatar Oct 15 '24 18:10 taylding-amd