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 at libjniavformat #1711

Closed
zouxiaodong opened this issue Oct 20, 2021 · 2 comments
Closed

jvm crash at libjniavformat #1711

zouxiaodong opened this issue Oct 20, 2021 · 2 comments

Comments

@zouxiaodong
Copy link

zouxiaodong commented Oct 20, 2021

javacv version: 1.5.6

java snippet code as follow:

  FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("udp://239.0.1.3:3300");
  grabber.setOption("analyzeduration", "5000000");
  grabber.setOption("probesize", "20000000");
  grabber.setOption("fifo_size", "50000000");
  grabber.setOption("timeout", "1000000");
  try{
    grabber.startUnsafe();
    AVFormatContext fc = grabber.getFormatContext();
    AVRational AV_TIME_BASE_Q = new AVRational().num(1).den(avutil.AV_TIME_BASE);
    log.debug("ts_id:{}", fc.ts_id());
    videoFeature.setTsId(fc.ts_id());
    //only parse first program
    AVProgram program = fc.programs(0);
    VideoFeature.Program videoProgram = new VideoFeature.Program();
    videoFeature.setProgram(videoProgram);
    videoProgram.setProgramId(program.id());
    videoProgram.setProgramNum(program.program_num());
    videoProgram.setStreams(program.nb_stream_indexes());
    videoProgram.setPmtPid(program.pmt_pid());
    videoProgram.setPcrPid(program.pcr_pid());
    videoProgram.setStartPts(program.start_time());
    videoProgram.setStartTime(printTime(program.start_time(), AV_TIME_BASE_Q, 0));
    .....
    some code get streams info
    ....
  }catch (Exception e)
  {
  }finally{
    grabber.releaseUnsafe();
  }
--------------
A fatal error has been detected by the Java Runtime Environment:

 SIGSEGV (0xb) at pc=0x00007efe8d797ef0, pid=17572, tid=0x00007efef55d0700

JRE version: Java(TM) SE Runtime Environment (8.0_281-b09) (build 1.8.0_281-b09)
Java VM: Java HotSpot(TM) 64-Bit Server VM (25.281-b09 mixed mode linux-amd64 compressed oops)
Problematic frame:
C  [libjniavformat.so+0x44ef0]  Java_org_bytedeco_ffmpeg_avformat_AVFormatContext_programs__I+0x50

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

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.

java.lang.Integer
 - klass: 'java/lang/Integer'
R9 =0x00000000eb2cb120 is an oop
org.bytedeco.ffmpeg.avformat.AVFormatContext
 - klass: 'org/bytedeco/ffmpeg/avformat/AVFormatContext'
R10=0x00000000000056ee is an unknown value
R11=0x00007eff5b5cd31c: <offset 0xfda31c> in /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so at 0x00007eff5a5f3000
R12=0x00007efe90730d00 is an unknown value
R13=0x00007efef55cf7f0 is pointing into the stack for thread: 0x00007efeac004800
R14=0x00007efef55cf490 is pointing into the stack for thread: 0x00007efeac004800
R15=0x00007efeac004800 is a thread


Stack: [0x00007efef54d0000,0x00007efef55d1000],  sp=0x00007efef55cf7c0,  free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libjniavformat.so+0x44ef0]  Java_org_bytedeco_ffmpeg_avformat_AVFormatContext_programs__I+0x50

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 6262  org.bytedeco.ffmpeg.avformat.AVFormatContext.programs(I)Lorg/bytedeco/ffmpeg/avformat/AVProgram; (0 bytes) @ 0x00007eff463b1238 [0x00007eff463b1200+0x38]
J 6253 C2 com.xx.TsExtractService.extraceFeature(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)V (2349 bytes) @ 0x00007eff463b6fd8 [0x00007eff463b4480+0x2b58]
@zouxiaodong
Copy link
Author

zouxiaodong commented Oct 21, 2021

i reproduced the issue, jvm will crashed at AVProgram program = fc.programs(0) if ffmpeg Could not find codec parameters for stream .
so how to check that situation in javacv ? ts_id ==0 or fc.programs() == null || fc.programs().isNull()?

-----gdb coredump
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007fae6491a859 in __GI_abort () at abort.c:79
#2 0x00007fae64212e99 in os::abort(bool) () from /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so
#3 0x00007fae643db4c3 in VMError::report_and_die() () from /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so
#4 0x00007fae6421d165 in JVM_handle_linux_signal () from /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so
#5 0x00007fae6420ffe8 in signalHandler(int, siginfo*, void*) () from /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so
#6
#7 0x00007fad959b3ef0 in Java_org_bytedeco_ffmpeg_avformat_AVFormatContext_programs__I ()
from /home/xzitv/.javacpp/cache/ffmpeg-4.4-1.5.6-linux-x86_64.jar/org/bytedeco/ffmpeg/linux-x86_64/libjniavformat.so
#8 0x00007fae4db86970 in ?? ()
#9 0x00000000eb8c47d0 in ?? ()
#10 0x00000000eb93f848 in ?? ()
#11 0x00000000eb8c4330 in ?? ()
#12 0x0000002d0000000b in ?? ()
#13 0x00000000c074f370 in ?? ()
#14 0x00000000eb8c4e78 in ?? ()
#15 0x0000000000000001 in ?? ()
#16 0x00007fae64006d8d in JVM_Sleep () from /usr/local/jdk1.8.0_281/jre/lib/amd64/server/libjvm.so
#17 0x00007fae4e6c1cfc in ?? ()
#18 0x00000000eb8c44b8 in ?? ()
#19 0x00000000eb8c4720 in ?? ()
#20 0x00000000eb8c47d0 in ?? ()
#21 0x00000000c0711a98 in ?? ()

---java log
[mpegts @ 0x7fadbc0c3640] Could not find codec parameters for stream 1 (Unknown: none): unknown codec
Consider increasing the value for the 'analyzeduration' (5000000) and 'probesize' (20000000) options
Input #0, mpegts, from 'udp://239.93.0.184:5140':
Duration: N/A, start: 28087.985978, bitrate: 192 kb/s
Stream #0:0[0x1100]: Audio: mp2, 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:1[0x1011]: Unknown: none
2021-10-20 21:51:03 DEBUG feature-cctv1hd c.z.i.p.a.c.s.FeatureExtractService ts_id:0
A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x00007fad959b3ef0, pid=2838329, tid=0x00007fae00f3f700

JRE version: Java(TM) SE Runtime Environment (8.0_281-b09) (build 1.8.0_281-b09)

@zouxiaodong
Copy link
Author

fc.programs() is null if some exception occured,

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

No branches or pull requests

2 participants