Hello.
Please review the fix forjdk9.

I found this issue during code review of another task, related to performance.

The sample code below will call the IsomorphicCopy method which call memcpy on the overlapping memory(this is the simplest example)

BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB_PRE);
     Graphics2D g = img.createGraphics();
     g.setComposite(AlphaComposite.Src);
     g.drawImage(img, 0, 0, null);
     g.dispose();

http://linux.die.net/man/3/memcpy
"The memcpy() function copies n bytes from memory area src to memory area dest. The memory areas must not overlap. Use memmove(3) if the memory areas do overlap"


I can confirm this bug using valgrind and a program above:
command:
valgrind --smc-check=all --tool=memcheck --leak-check=full -v ./9/client/build/linux-x86_64-normal-server-fastdebug/images/jdk/bin/java -Xint Main

output:
==60975== Source and destination overlap in memcpy(0xe1b8b4d8, 0xe1b8b4d8, 400) ==60975== at 0x4C2F71C: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==60975== by 0x1E0F504D: AnyIntIsomorphicCopy (in /moe/workspaces/jdk/9/client-work/build/linux-x86_64-normal-server-fastdebug/images/jdk/lib/amd64/libawt.so) ==60975== by 0x1E0F5DE8: Java_sun_java2d_loops_Blit_Blit (in /moe/workspaces/jdk/9/client-work/build/linux-x86_64-normal-server-fastdebug/images/jdk/lib/amd64/libawt.so)


Bug: https://bugs.openjdk.java.net/browse/JDK-8080847
Webrev can be found at: http://cr.openjdk.java.net/~serb/8080847/webrev.00

--
Best regards, Sergey.

Reply via email to