-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
saving structure in v7 format with compression #251
Comments
Thanks for reporting. That's rather unexpected given the age of v1.5.12. Can you share the code how you created the MAT files? Did you run git bisect to find the bad commit? |
I did not use git bisect, I rebuilt matio on different tags to find the last working version.
Files generated using matio 1.5.9 can be read back in 1.5.9 or 1.5.27 but files generated using 1.5.27 cannot be read in 1.5.9 nor 1.5.27, that is why I incriminated the save. Without compression, I can save and load files without trouble. |
Thanks for the details! Do you mind to run git bisect to find the bad commit as in your other issue? I do hope that it will be easier for you than guessing by me because of the many changes between 1.5.9 and 1.5.12. Thank you! |
I am afraid I cannot reproduce without the driving Scilab code. The following vanilla Matio test code produces a 100% binary identical MAT file to your valid structS-matio-1.5.9.mat - tested with current abe00b8 on Win (little endian) with MSVC. mat_t *mat;
char output_name[256];
int version[3];
Mat_GetLibraryVersion(version, version + 1, version + 2);
snprintf(output_name, 256, "structS-matio-%d.%d.%d.mat", version[0], version[1], version[2]);
mat = Mat_CreateVer(output_name, "MATLAB 5.0 MAT-file, Platform: x86_64-pc-windows, Created by: libmatio v1.5.9 on Thu Jun 13 16:06:30 2024\x0A", MAT_FT_MAT5);
if (mat) {
const wchar_t *str = L"logiciel";
const double age[1] = { 30.0 };
const size_t num_fields = 2;
const char *fieldnames[2] = { "type", "age" };
size_t dims[2];
matvar_t *matvar, *struct_matvar;
dims[0] = 1; dims[1] = 1;
struct_matvar = Mat_VarCreateStruct("structS", 2, dims, fieldnames, num_fields);
dims[0] = 1; dims[1] = 8;
matvar = Mat_VarCreate(fieldnames[0], MAT_C_CHAR, MAT_T_UINT16, 2, dims, (void *)str, 0);
Mat_VarSetStructFieldByName(struct_matvar, fieldnames[0], 0, matvar);
dims[0] = 1; dims[1] = 1;
matvar = Mat_VarCreate(fieldnames[1], MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, (void *)age, 0);
Mat_VarSetStructFieldByName(struct_matvar, fieldnames[1], 0, matvar);
Mat_VarWrite(mat, struct_matvar, MAT_COMPRESSION_ZLIB);
Mat_VarFree(struct_matvar);
Mat_Close(mat);
} |
Thanks for having a look. |
Here is a code, based on yours, that reproduces what we are doing in Scilab.
|
Thanks for the test. 6321cda (on mat5.c) seems to be the suspicious commit. Need to investigate in more detail. |
@tbeu The fix is working well, thanks! |
Saving a structure in v7 format with compression creates a corrupted file.
After some investigation, the problem seems to be present since matio 1.5.12.
File generated with matio 1.5.9 (not corrupted):
structS-matio-1.5.9.zip
File generated with matio 1.5.27 (corrupted):
structS-matio-1.5.27.zip
The structure saved contains two fields
type
andage
with values "logiciel" and 30.The text was updated successfully, but these errors were encountered: