Skip to content
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

overflow when opening 4 GiB raw file #8

Open
ferdymercury opened this issue Mar 24, 2022 · 1 comment
Open

overflow when opening 4 GiB raw file #8

ferdymercury opened this issue Mar 24, 2022 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ferdymercury
Copy link
Owner

ferdymercury commented Mar 24, 2022

Opening Raw Data File fails if data are bigger or equal to 4 GiB leads to a buggy number of bytes to be read.

image

This diff fixes this number:


---------------------- amide-current/src/amitk_raw_data.h ----------------------
index 3b1c397..7a3a306 100644
@@ -191,3 +191,3 @@ AmitkRawFormat amitk_format_to_raw_format(AmitkFormat data_format);
 #define amitk_raw_format_calc_num_bytes_per_slice(dim, raw_format) ((dim).x*(dim).y*amitk_raw_format_sizes[raw_format])
-#define amitk_raw_format_calc_num_bytes(dim, raw_format) ((dim).z*(dim).g*(dim).t*amitk_raw_format_calc_num_bytes_per_slice(dim,raw_format))
+#define amitk_raw_format_calc_num_bytes(dim, raw_format) (1ULL*(dim).z*(dim).g*(dim).t*amitk_raw_format_calc_num_bytes_per_slice(dim,raw_format))

However one then get's a SEGV at:

		AMITK_RAW_DATA_USHORT_SET_CONTENT(raw_data,i) =
		  GUINT16_FROM_LE(DATA_CONTENT(data, dim, i));

In contrast, latest ImageJ has no problem in opening this dataset.

@ferdymercury ferdymercury added bug Something isn't working help wanted Extra attention is needed labels Mar 24, 2022
@ferdymercury ferdymercury changed the title overflow 4 GiB maximum file overflow when opening 4 GiB raw file Mar 24, 2022
@ferdymercury
Copy link
Owner Author

Tried with

--------------- amide-current/src/amitk_raw_data_variable_type.h ---------------
index 0075f2c..e0eba9a 100644
@@ -45,3 +45,3 @@
   (((amitk_format_`'m4_Variable_Type`'_t *) (amitk_raw_data)->data)+ \
-   ((((((((((i).t) * ((amitk_raw_data)->dim.g)) + \
+   ((((((((1ULL*((i).t) * ((amitk_raw_data)->dim.g)) + \
       (i).g) * ((amitk_raw_data)->dim.z)) + \

but still crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant