-
Notifications
You must be signed in to change notification settings - Fork 14
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
TTString: Assess moving back to a type alias of std::string #339
Comments
One dangling question needs to be resolved: it does not appear that Laurent's work was ever merged.It is on a branch called "windows-string-rewrite3-cstring". But Windows is now working correctly on the dev branch with the vector TTString if I understand correctly. Do I understand correctly? |
On Mon, Mar 2, 2015 at 2:43 PM, Timothy Place notifications@github.com
Yes. About the problem here, as far as I know, on Windows passing C++ stuff To "solve" this headache, Qt release binaries built against the two or Jean-Michaël Celerier |
Note: before we close this ticket out we should also prune these old branches from the repository: remotes/origin/windows-string-rewrite |
There are a couple of places where we will have changes in behavior as a result of this. So we are unfortunately not going to be 100% backward compatible. Nevertheless, the benefits of being standards-compliant outweigh the cost of some short term pain on edge cases that may or may-not exist. Here is one example (I had to modify our unit tests to pass): A second place where there could be edge cases (I once again had to modify our unit tests to pass) is in number elements used to store a string. In our custom-coded std::vector derivative we stored the NULL termination in an extra byte. Again, hopefully there aren't too many places this will impact. One place it has impacted heavily is in weird NodeLib code which had to work around the NULL termination byte. So I've been needing to remove those hacks now. They were caught by unit tests -- any cases not caught by unit tests will be a problem however... |
This looks like something we would do quite frequently in the unit tests themselves, right? I am thinking of how we post things to the console. -Nathan
|
At some point in the past TTString was a typedef of std::string. Life was good.
We had super difficult problems on Windows and based-on nebulous information floating around the internet we decided the memory corruption could be coming from TTString as it crossed DLL boundaries -- perhaps std::vector would be safer because the storage memory internally is guaranteed to be contiguous according the C++ standard itself.
As a result of the above work the problem moved elsewhere. Which proves nothing. And we still had a problem. In fact, there is a no guarantee when using different compilers or compiler settings about passing any of the STL containers across DLL boundaries. That means the current TTString isn't really safer than the old TTString -- it's just different. Laurent rewrote based on C-strings and did manage to stop the crashes. For reference: the email thread for the above is called "Jamoma on Windows" on the jamoma-devel list.
And furthermore, as @jcelerier wrote to jamoma-devel ( "Regarding TTString" ), the current C++ standard (section 21.4.1) states that "The char-like objects in a basic_string object shall be stored
contiguously".
We have three options (at least):
My ( @tap ) assessment:
If people use difference compilers and compiler settings for different libs I suspect they are going to be totally hosed. There are lots of places (not just TTString) where memory layout and such is going to become a problem. Unless we want to rewrite all of Jamoma with a C API then we need to accept that all of Jamoma must be compiled with the same compiler and compiler settings to be used.
Therefore, we should move back to std::string.
The text was updated successfully, but these errors were encountered: