当前位置: 首页 > 工具软件 > vlcj > 使用案例 >

ubuntu环境下vlcj报错:A fatal error has been detected #C [libc.so.6+0x121024] _IO_file_underflow+0x64

阎彬炳
2023-12-01

最近采用vlcj进行播放软件的开发过程中遇到了一些问题,记录下来以做参考。
开发环境:windows10+eclipse Mars.2 Release (4.5.2)+jdk1.7.0_79
贴上官方示例代码

package tutorial;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;

public class Tutorial {

    private final JFrame frame;

    private final EmbeddedMediaPlayerComponent mediaPlayerComponent;

    public static void main(final String[] args) {
        //new NativeDiscovery().discover();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new Tutorial();
            }
        });
    }


    public Tutorial() {
        frame = new JFrame("My First Media Player");
        frame.setBounds(100, 100, 600, 400);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
        frame.setContentPane(mediaPlayerComponent);
        frame.setVisible(true);
        mediaPlayerComponent.getMediaPlayer().playMedia("test.mp4");
    }
}

在Window平台下编译、运行正常。

运行平台:
ubuntu12.04(32bit)+vlc2.0.8+jre7
ubuntu14.04(32bit)+2.1.6+jre7
ubuntu16.04(32bit)+vlc2.2.2+jre7
以上三个平台环境下,当执行到playMedia()方法时,程序报错退出。也就是说,之前的界面渲染和构造对象都是没有影响的。
报错如下:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xb76f3ec8, pid=15121, tid=0xa0817b40
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) Client VM (25.144-b01 mixed mode linux-x86 )
# Problematic frame:
# C  [libc.so.6+0x127ec8]  _IO_file_underflow+0x68
#
# Core dump written. Default location: /home/linaro/Desktop/exe-test/core or core.15121
#
# An error report file with more information is saved as:
# /home/linaro/Desktop/exe-test/hs_err_pid15121.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp

参考网上一些资料后,比较有代表性的摘写如下
一哥们查看了gdb信息:

#0 0x0028f688 in _IO_file_underflow () from /lib/i386-linux-gnu/libc.so.6
#1 0x001d83a9 in _IO_default_uflow () from /lib/i386-linux-gnu/libc.so.6
#2 0x001d81c0 in __uflow () from /lib/i386-linux-gnu/libc.so.6
#3 0x001ce6d2 in getc () from /lib/i386-linux-gnu/libc.so.6
#4 0x02c8abc4 in luaL_loadfile () from /usr/lib/i386-linux-gnu/liblua5.1.so.0

他分析是在lauxlib.c文件的luaL_loadfile方法执行时出现的错误。

The piece of code that triggers this bug is in lauxlib.c in the luaL_loadfile method:

while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; <— Crash failure triggered here after freopen

This bug is only triggered when the LUA script being opened has been compiled by luac - if I run the same test with a source script rather than a compiled script the fatal crash is not triggered. I think the lua code essentially opens the script file, sniffs for a magic number to check if it is a binary script, and if so reopens the file. I think it is this act of reopening the file that ultimately triggers the bug.

大概意思就是,这是个在特殊系统环境下才会产生的bug。当正在被打开的Lua脚本已经被luac编译过的时候,该bug才会被触发。
他认为这是Ubuntu自身的bug而不是JVM或是lua的问题,因为当他删掉Ubuntu提供的Lua包,换上自己的lua环境后,在32位的Ubuntu下就可以运行了。

I am reporting this as an Ubuntu bug rather than a JVM or lua bug because if I remove the lua package provided by Ubuntu and instead build lua myself using the vanilla untouched 5.1 source code from lua.org, my test case does in fact work on 32-bit Ubuntu.

同时他指出,仅32位操作系统受此影响,64位的Ubuntu是可以正常运行的。

参考了几处解决方案后,方法有3种:(1)换用64位的操作系统,(2)换用jre6;(3)将32位系统vlc下的lua文件夹移除。建议使用mv将其移除目录即可。

sudo mv /usr/lib/vlc/lua /usr/lib/lua-vlc-backup

大概是ubuntu的一个bug,精力有限,没有去细扣其中原委。以后有时间将加以补充。

参考出处:
https://github.com/caprica/vlcj/issues/62
https://bugs.launchpad.net/ubuntu/+source/lua5.1/+bug/1136432

 类似资料: