0

In this problem, (filter), I'm receiving all green from check50. But when I ran valgrind for blurring I got the following error:

==4412== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==4412== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==4412== Command: ./filter -b images/stadium.bmp out.bmp
==4412== 
==4412== Invalid read of size 1
==4412==    at 0x425342: blur (helpers.c:59)
==4412==    by 0x423341: main (filter.c:105)
==4412==  Address 0x5ebf240 is 0 bytes after a block of size 720,000 alloc'd
==4412==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4412==    by 0x423096: main (filter.c:78)
==4412== 
==4412== Invalid read of size 1
==4412==    at 0x4255B7: blur (helpers.c:60)
==4412==    by 0x423341: main (filter.c:105)
==4412==  Address 0x5ebf241 is 1 bytes after a block of size 720,000 alloc'd
==4412==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4412==    by 0x423096: main (filter.c:78)
==4412== 
==4412== Invalid read of size 1
==4412==    at 0x42582C: blur (helpers.c:61)
==4412==    by 0x423341: main (filter.c:105)
==4412==  Address 0x5ebf242 is 2 bytes after a block of size 720,000 alloc'd
==4412==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4412==    by 0x423096: main (filter.c:78)
==4412== 
==4412== 
==4412== HEAP SUMMARY:
==4412==     in use at exit: 32 bytes in 1 blocks
==4412==   total heap usage: 6 allocs, 5 frees, 729,328 bytes allocated
==4412== 
==4412== 32 bytes in 1 blocks are still reachable in loss record 1 of 1
==4412==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4412==    by 0x56027E4: _dlerror_run (dlerror.c:140)
==4412==    by 0x5602165: dlsym (dlsym.c:70)
==4412==    by 0x4229E2: __interception::GetRealFunctionAddress(char const*, unsigned long*, unsigned long, unsigned long) (llvm/projects/compiler-rt/lib/interception/interception_linux.cc:33)
==4412==    by 0x422913: InitializeSignalInterceptors (llvm/projects/compiler-rt/lib/ubsan/../sanitizer_common/sanitizer_signal_interceptors.inc:85)
==4412==    by 0x422913: __ubsan::InitializeDeadlySignals() (llvm/projects/compiler-rt/lib/ubsan/ubsan_signals_standalone.cc:60)
==4412==    by 0x4010805: _dl_init (dl-init.c:104)
==4412==    by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so)
==4412==    by 0x3: ???
==4412==    by 0x1FFF000926: ???
==4412==    by 0x1FFF00092F: ???
==4412==    by 0x1FFF000932: ???
==4412==    by 0x1FFF000945: ???
==4412== 
==4412== LEAK SUMMARY:
==4412==    definitely lost: 0 bytes in 0 blocks
==4412==    indirectly lost: 0 bytes in 0 blocks
==4412==      possibly lost: 0 bytes in 0 blocks
==4412==    still reachable: 32 bytes in 1 blocks
==4412==         suppressed: 0 bytes in 0 blocks
==4412== 
==4412== For counts of detected and suppressed errors, rerun with: -v
==4412== ERROR SUMMARY: 5394 errors from 3 contexts (suppressed: 0 from 0)

Same thing happens for edging. Now, after spending some time, I understood that something is wrong in helpers.c file's line 59, 60 and 61. Now, I'm guessing that I've done something wrong with getting RGBTRIPLE's value. Whenever I'm addressing to images[i][j].rgbtRed (or rgbtGreen or rgbtBlue) inside the void blur or void edges function, valgrind is giving me error.

I also addressed RGBTRIPLE's value in the void grayscale function. But when I run valgrind ./filter -g in.bmp out.bmp, there's no error. I'm confused here

1

It looks like your blur function is trying to access a non-existent pixel at image[height-1][width]. If so, that's probably not the only reference outside the boundary of image.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .