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

Invalid read of size 4 #16

Closed
pmudry opened this issue Aug 21, 2019 · 9 comments
Closed

Invalid read of size 4 #16

pmudry opened this issue Aug 21, 2019 · 9 comments

Comments

@pmudry
Copy link

pmudry commented Aug 21, 2019

Memory checking a program with valgrind returns an invalid read of size 4 in at line 10533 of sod.c.

Minimal example code :

#include <stdlib.h>
#include <math.h>
#include "sod.h"

int main(int argc, char *argv[]) {
	const char *zInput = argv[1];
	sod_img imgIn = sod_img_load_grayscale(zInput);
	sod_img cannyImg = sod_canny_edge_image(imgIn, 0);
	sod_free_image(cannyImg);
	return 0;
}

Valgrind output after compilation in Ubuntu 18.04 amd 64 :

==17492== Invalid read of size 4
==17492==    at 0x1286F8: canny_non_max_suppression (sod.c:10533)
==17492==    by 0x129D0E: sod_canny_edge_image (sod.c:10832)
==17492==    by 0x10B534: main (minimal.c:8)
==17492==  Address 0x4d57f00 is 0 bytes after a block of size 473,600 alloc'd
==17492==    at 0x483AB35: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==17492==    by 0x1234A3: sod_make_image (sod.c:9190)
==17492==    by 0x129C67: sod_canny_edge_image (sod.c:10827)
==17492==    by 0x10B534: main (minimal.c:8)
==17492== 
@symisc
Copy link
Owner

symisc commented Aug 22, 2019

Yes, this is an issue with memory allocation of an array that may run out of bound in some cases. A fix is to be pushed in the coming weeks with the next release of the library.

@pmudry
Copy link
Author

pmudry commented Aug 22, 2019

Ok, good to know you are aware of that 👍.

I also faced a memory leak in canny detector which sometimes leaks 128 bytes and sometimes not ? I am still trying to discover how exactly but it is happening around line 966 in SysSetPut

@symisc
Copy link
Owner

symisc commented Aug 22, 2019 via email

@pmudry
Copy link
Author

pmudry commented Aug 22, 2019

For the memory leak, I am sorry the problem was on my side. I was not always releasing the lines while doing hough lines detection.

Everything fine there. Nice work by the way !

@pmudry
Copy link
Author

pmudry commented Sep 3, 2019

Any idea when the next library release will be coming out ?

@symisc
Copy link
Owner

symisc commented Sep 3, 2019 via email

@pmudry
Copy link
Author

pmudry commented Nov 28, 2019

Any news on the new library release ?

Cheers

@symisc
Copy link
Owner

symisc commented Dec 2, 2019

The release is scheduled for January 2020 due time constraint and developers focusing on a global scale product powered by SOD. We have managed to fix the canny edge issue and adding new image processing interfaces. Stay tune!

@symisc
Copy link
Owner

symisc commented Mar 3, 2020

Make sure to update to the latest version of SOD which fix the canny edge detection memory leak issue https://sod.pixlab.io/changelog.html

@symisc symisc closed this as completed Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants