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

JVM crash on grabber.stop() method #1568

Closed
4714407 opened this issue Jan 17, 2021 · 8 comments
Closed

JVM crash on grabber.stop() method #1568

4714407 opened this issue Jan 17, 2021 · 8 comments
Labels

Comments

@4714407
Copy link

4714407 commented Jan 17, 2021

When I set grabber's ImageMode to FrameGrabber.ImageMode.RAW, the JVM crashes when I call the stop method.
The code looks like this

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(url);
grabber.setImageMode(FrameGrabber.ImageMode.RAW);
grabber.start();
 while((frame = grabber.grabImage()) != null){
                count++;
            }
 grabber.stop();

Drop this line "Comment it out grabber.setImageMode ( FrameGrabber.ImageMode.RAW ); "
Everything is OK

@4714407
Copy link
Author

4714407 commented Jan 17, 2021

Tracking code found that the exception is caused by avcodec_free_context(video_c);

@saudet
Copy link
Member

saudet commented Jan 17, 2021

Please send a pull request to fix this! Thanks

@4714407
Copy link
Author

4714407 commented Jan 17, 2021

I don't know how to fix this problem. That's why I put this bug to you

@4714407 4714407 changed the title JVM carsh on grabber.stop() method JVM crash on grabber.stop() method Jan 17, 2021
@4714407
Copy link
Author

4714407 commented Jan 17, 2021

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007fff43bc935d, pid=2208, tid=0x0000000000000d68

JRE version: Java(TM) SE Runtime Environment (8.0_231-b11) (build 1.8.0_231-b11)

Java VM: Java HotSpot(TM) 64-Bit Server VM (25.231-b11 mixed mode windows-amd64 compressed oops)

Problematic frame:

C [msvcrt.dll+0x1935d]

Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

If you would like to submit a bug report, please visit:

http://bugreport.java.com/bugreport/crash.jsp

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

--------------- T H R E A D ---------------

Current thread (0x0000000003726000): JavaThread "main" [_thread_in_native, id=3432, stack(0x0000000003120000,0x0000000003220000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x000000001ec0d2f8

Registers:
RAX=0x000000001d6c96c0, RBX=0x000000000321edc8, RCX=0x000000001ec0d300, RDX=0x000000001ec0d300
RSP=0x000000000321ed70, RBP=0x000000000321ef90, RSI=0x000000000321eef8, RDI=0x0000000000000000
R8 =0x000000001eaeb600, R9 =0x0000000000000001, R10=0x000000000000001b, R11=0x000000000321ed40
R12=0x0000000000000000, R13=0x0000000017f190b0, R14=0x000000000321efb0, R15=0x0000000003726000
RIP=0x00007fff43bc935d, EFLAGS=0x0000000000010206

Top of Stack: (sp=0x000000000321ed70)
0x000000000321ed70: 0000000100000023 0000000001970000
0x000000000321ed80: 000000000321ef90 0000000000000000
0x000000000321ed90: 0000000000000000 00007fff27669d7b
0x000000000321eda0: 0000000000000000 00007fff43bc9c9c
0x000000000321edb0: 000000001d45d5c0 000000000321eef8
0x000000000321edc0: 000000001d6c96c0 000000001eaeb600
0x000000000321edd0: 000000001c0e3b40 00007ffee419f3a5
0x000000000321ede0: 0000000000000000 00007fff43bc9c9c
0x000000000321edf0: 000000001d45d5c0 000000000321eef8
0x000000000321ee00: 000000001d45d5c0 00007fff27669829
0x000000000321ee10: 000000001d45d5c0 000000001c0e3b40
0x000000000321ee20: 000000000321ef90 000000001d45d5c0
0x000000000321ee30: 000000000321eef8 000000001c17c980
0x000000000321ee40: 000000000321ef90 00007ffee644617b
0x000000000321ee50: 0000000003726000 000000000321eec0
0x000000000321ee60: 0000000017f190b0 0000000003726000

Instructions: (pc=0x00007fff43bc935d)
0x00007fff43bc933d: 48 83 c4 28 c3 cc cc cc cc cc cc cc cc cc cc cc
0x00007fff43bc934d: cc cc cc 48 83 ec 28 48 85 c9 74 0d 48 83 e1 f8
0x00007fff43bc935d: 48 8b 49 f8 e8 1a 09 00 00 48 83 c4 28 c3 cc cc
0x00007fff43bc936d: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc

Register to memory mapping:

RAX=0x000000001d6c96c0 is an unknown value
RBX=0x000000000321edc8 is pointing into the stack for thread: 0x0000000003726000
RCX=0x000000001ec0d300 is an unknown value
RDX=0x000000001ec0d300 is an unknown value
RSP=0x000000000321ed70 is pointing into the stack for thread: 0x0000000003726000
RBP=0x000000000321ef90 is pointing into the stack for thread: 0x0000000003726000
RSI=0x000000000321eef8 is pointing into the stack for thread: 0x0000000003726000
RDI=0x0000000000000000 is an unknown value
R8 =0x000000001eaeb600 is an unknown value
R9 =0x0000000000000001 is an unknown value
R10=0x000000000000001b is an unknown value
R11=0x000000000321ed40 is pointing into the stack for thread: 0x0000000003726000
R12=0x0000000000000000 is an unknown value
R13=0x0000000017f190b0 is pointing into metadata
R14=0x000000000321efb0 is pointing into the stack for thread: 0x0000000003726000
R15=0x0000000003726000 is a thread

Stack: [0x0000000003120000,0x0000000003220000], sp=0x000000000321ed70, free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [msvcrt.dll+0x1935d]
C [avutil-56.dll+0x9d7b]
C [avcodec-58.dll+0x17f3a5]
C [avutil-56.dll+0x9829]
C [avcodec-58.dll+0x242617b]
C [avcodec-58.dll+0x51a509]
C [jniavcodec.dll+0x44bc6]
C 0x0000000003838c67

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.bytedeco.ffmpeg.global.avcodec.avcodec_free_context(Lorg/bytedeco/ffmpeg/avcodec/AVCodecContext;)V+0
j org.bytedeco.javacv.FFmpegFrameGrabber.releaseUnsafe()V+189
j org.bytedeco.javacv.FFmpegFrameGrabber.release()V+6
j org.bytedeco.javacv.FFmpegFrameGrabber.stop()V+1
j net.weborld.Grabber.saveImage(Ljava/lang/String;J)V+257
j net.weborld.Grabber.main([Ljava/lang/String;)V+9
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x000000001ac52800 JavaThread "JavaCPP Deallocator" daemon [_thread_blocked, id=7260, stack(0x000000001bcd0000,0x000000001bdd0000)]
0x0000000019a8e800 JavaThread "Service Thread" daemon [_thread_blocked, id=14672, stack(0x000000001a890000,0x000000001a990000)]
0x0000000019a81000 JavaThread "C1 CompilerThread2" daemon [_thread_blocked, id=1284, stack(0x000000001a790000,0x000000001a890000)]
0x0000000019a32800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=15144, stack(0x0000000019e90000,0x0000000019f90000)]
0x0000000019a2f800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=12992, stack(0x0000000019d90000,0x0000000019e90000)]
0x0000000019a64000 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=14772, stack(0x0000000019c90000,0x0000000019d90000)]
0x00000000196d2800 JavaThread "Attach Listener" daemon [_thread_blocked, id=7844, stack(0x0000000019b90000,0x0000000019c90000)]
0x0000000018354800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=12216, stack(0x0000000019a90000,0x0000000019b90000)]
0x000000000381a800 JavaThread "Finalizer" daemon [_thread_blocked, id=4256, stack(0x0000000019590000,0x0000000019690000)]
0x000000001832a000 JavaThread "Reference Handler" daemon [_thread_blocked, id=9192, stack(0x0000000019490000,0x0000000019590000)]
=>0x0000000003726000 JavaThread "main" [_thread_in_native, id=3432, stack(0x0000000003120000,0x0000000003220000)]

Other Threads:
0x0000000018307800 VMThread [stack: 0x0000000019390000,0x0000000019490000] [id=14800]
0x000000001a070000 WatcherThread [stack: 0x000000001a990000,0x000000001aa90000] [id=9320]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

heap address: 0x0000000081e00000, size: 2018 MB, Compressed Oops mode: 32-bit
Narrow klass base: 0x0000000000000000, Narrow klass shift: 3
Compressed class space size: 1073741824 Address: 0x0000000100000000

Heap:
PSYoungGen total 34304K, used 19172K [0x00000000d5f80000, 0x00000000d8500000, 0x0000000100000000)
eden space 32256K, 53% used [0x00000000d5f80000,0x00000000d7063160,0x00000000d7f00000)
from space 2048K, 91% used [0x00000000d8300000,0x00000000d84d6010,0x00000000d8500000)
to space 2560K, 0% used [0x00000000d8000000,0x00000000d8000000,0x00000000d8280000)
ParOldGen total 87552K, used 48K [0x0000000081e00000, 0x0000000087380000, 0x00000000d5f80000)
object space 87552K, 0% used [0x0000000081e00000,0x0000000081e0c000,0x0000000087380000)
Metaspace used 7490K, capacity 7618K, committed 7808K, reserved 1056768K
class space used 823K, capacity 851K, committed 896K, reserved 1048576K

Card table byte_map: [0x0000000012be0000,0x0000000012fe0000] byte_map_base: 0x00000000127d1000

Marking Bits: (ParMarkBitMap*) 0x0000000057246d90
Begin Bits: [0x0000000013690000, 0x0000000015618000)
End Bits: [0x0000000015618000, 0x00000000175a0000)

Polling page: 0x0000000001880000

CodeCache: size=245760Kb used=5075Kb max_used=5075Kb free=240684Kb
bounds [0x0000000003820000, 0x0000000003d20000, 0x0000000012820000]
total_blobs=1305 nmethods=967 adapters=251
compilation: enabled

Compilation events (10 events):
Event: 26.779 Thread 0x0000000019a2f800 963 4 java.nio.ByteBuffer:: (45 bytes)
Event: 26.783 Thread 0x0000000019a2f800 nmethod 963 0x0000000003d084d0 code [0x0000000003d08620, 0x0000000003d08838]
Event: 27.702 Thread 0x0000000019a32800 964 4 java.nio.DirectByteBuffer:: (24 bytes)
Event: 27.703 Thread 0x0000000019a32800 nmethod 964 0x0000000003d08150 code [0x0000000003d08280, 0x0000000003d08358]
Event: 27.950 Thread 0x0000000019a2f800 965 4 org.bytedeco.javacv.FFmpegFrameGrabber::processImage (508 bytes)
Event: 27.972 Thread 0x0000000019a2f800 nmethod 965 0x0000000003d12bd0 code [0x0000000003d12e80, 0x0000000003d13b88]
Event: 28.053 Thread 0x0000000019a32800 966 4 org.bytedeco.javacv.FFmpegFrameGrabber::grabImage (10 bytes)
Event: 28.054 Thread 0x0000000019a32800 nmethod 966 0x0000000003d07e50 code [0x0000000003d07fa0, 0x0000000003d08028]
Event: 172.368 Thread 0x0000000019a81000 967 % ! 3 net.weborld.Grabber::saveImage @ 187 (278 bytes)
Event: 172.375 Thread 0x0000000019a81000 nmethod 967% 0x0000000003d14b50 code [0x0000000003d15200, 0x0000000003d19428]

@saudet
Copy link
Member

saudet commented Jan 18, 2021

Ok, I've fixed that in commit d6afac0. Thanks for reporting!

@4714407
Copy link
Author

4714407 commented Jan 18, 2021

Everything is OK. What resources do I need to release manually in RAM mode?

@saudet
Copy link
Member

saudet commented Jan 18, 2021

As long as you call close()/stop() everything should get released.

@4714407 4714407 closed this as completed Jan 18, 2021
@saudet
Copy link
Member

saudet commented Mar 10, 2021

The fix has been released with JavaCV 1.5.5! Enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants