-
Notifications
You must be signed in to change notification settings - Fork 296
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
MetaModelica does not support strings larger than 2GB #10284
Comments
See also #10171. |
Do we really need to have MetaModelica on 32 bits? 32-bit or even 16-bit runtimes can make sense in an embedded context, but I don't think anybody will compile OMC on a 32-bits OS these days - what for? |
Strings seem to already store the length as 64 bits on 64-bit platforms, but some things seem to not be 64-bit yet. For example some of the string utility functions like So unfortunately I don't think it's quite as easy as just changing strings to be 64-bit, we'll have to at least change the way we use external C functions (or maybe easier to just make sure we don't use them to pass string lengths). But I wouldn't be surprised if there are other pitfalls when it comes to large strings too. |
Trying to read a 3.7G file: File:
Script: // readMoreThan2GBFile.mos
readFile("g.json"); getErrorString(); We get a funny error also called "Success":
|
Split the file into files less than 2GB
Script: readFile("xaa"); getErrorString(); At first it reads the file fine but then it dies when trying to quote the output as it goes over 2GB
|
Yes, trying to return a large string in a script will not work since |
I think some Windows calls are to blame, it seems that _wstat returns 0 or so. |
I just tried it on Linux, and |
I also tried on Linux, I don't even bother with Windows at this moment so I don't know why I said the Windows calls are to blame :) Yeah, is weird that it fails to read the file on Linux! |
The only thing it does is omc_stat which calls the Linux stat and it seems it gets a != 0. static char* SystemImpl__readFile(const char* filename)
{
char* buf;
int res;
FILE * file = NULL;
omc_stat_t statstr;
res = omc_stat(filename, &statstr);
if (res != 0) { |
I think the issue is rather the line further down:
res is an int here, so the comparison will fail when the size is larger than 2GB.
|
I closed this by mistake. We really need to use our own types like mmc_uint_t for sizes. |
Yes, you are right as the error is: "Error: Failed to read the entire file: g.json: Success" which is in that if. |
Nowadays is really not far fetched to read 2G+ files. We need to look everywhere in the compiler and fix this properly. |
We could perhaps try to compile with |
Gosh, this MLS 32-bit int thing is really, really bad. Talk about future-proof design... |
This, fortunately, might not be a concern any longer after #9399. Records and their members are converted appropriately if they are to be sent to external functions. On the other hand, |
Very good, we will take this one by one. I will start with a PR that fixes the string issues. |
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code - update bootstrapping sources (new C declarations needed)
With PR #10297 it works to generate a ~3GB JSON for the BR example. Now, truth is, that is a bit excessive and we should find ways to minimize the JSON output from getModelInstance as otherwise it will be slow and consume quite a bit of memory. |
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code - update bootstrapping sources (new C declarations needed)
Indeed. I thought that avoiding to flatten anything which is not parameters and (graphical) annotations was the way to go, as those are the only things that are needed for the GUI, but I understood from @perost that this is not as easy as it seems. Did I miss something? In that case, we could at least skip transferring the information about everything which is not parameters and annotations to the JSON file. @adrpo is that what you have in mind?
I would strongly suggest that we avoid merging such a PR onto master until we branched off 1.21.0-dev.beta1. This is really a dangerous change in the proximity of a release, I would like to avoid a litany of bugfix releases to repair indirect damage caused by 64 bit integers. We've been there already. Bottom line: handling strings > 2 GB is nice to have, but is not a critical feature. Having reasonably sized JSON files is 😅 |
For sure this will not be in the master any time soon, whenever I am fixing some things needed for this one I am also breaking other things it seems :) |
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code - update bootstrapping sources (new C declarations needed)
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code - update bootstrapping sources (new C declarations needed)
- use proper size types where needed in external C functions - use "modelica_integer" instead of "int" when generating MetaModelica code - update bootstrapping sources (new C declarations needed)
It seems that if the string size goes above 2GB the MetaModelica strings start to fail badly generating errors.
The text was updated successfully, but these errors were encountered: