文档章节

ASM Type top (current frame, locals[3]) is not assignable 问题排查

哈库纳
 哈库纳
发布于 2017/02/15 14:06
字数 1452
阅读 302
收藏 1

    先说遇到的问题,Hasor 在1.6 和早期 1.7 jdk 下运行 asm 动态生成的字节码无任何异常。接着有反馈在 java8下出现类似如下异常,一开始并没有里会这个异常信息。找到一个解决办法是增加一个  -noverify 参数来压制这个校验异常。

    最近比较好奇想寻找一下究竟为什么会出现 VerifyError 错误,下面是这个错误的全貌。


2017-02-15 11:03:47.423 [RSF-Nio-4] INFO  - connected form 127.0.0.1:60618
2017-02-15 11:03:47.440 [RSF-Biz-1] ERROR - do request(12345) failed -> service [RSF]net.hasor.website.client.ProjectService-1.0.0, error :(net.hasor.core.utils.UnhandledException)java.lang.VerifyError - Inconsistent stackmap frames at branch target 101
Exception Details:
  Location:
    net/hasor/website/manager/UserManager$A_19.loginUpdate(Lnet/hasor/website/domain/UserDO;Ljava/lang/String;)V @101: new
  Reason:
    Type top (current frame, locals[3]) is not assignable to 'java/lang/Throwable' (stack map, locals[3])
  Current Frame:
    bci: @92
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', top, top, 'java/lang/Throwable' }
    stack: { integer }
  Stackmap Frame:
    bci: @101
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', 'java/lang/Throwable' }
    stack: { }
  Bytecode:
    0x0000000: 1002 bd00 0659 1000 1208 5359 1001 120a
    0x0000010: 533a 0410 02bd 000c 5910 002b 5359 1001
    0x0000020: 2c53 3a05 2ab6 0012 1213 1904 b600 173a
    0x0000030: 06bb 0019 5919 062a 1905 b700 1d3a 07bb
    0x0000040: 001f 5912 2119 0619 07b7 0024 b600 283a
    0x0000050: 0819 0857 b13a 0519 05c1 002a 9900 0919
    0x0000060: 05c0 002a bfbb 002a 5919 05b7 002d bf  
  Exception Handler Table:
    bci [0, 83] => handler: 85
  Stackmap Table:
    same_locals_1_stack_item_extended(@85,Object[#4])
    append_frame(@101,Object[#4])

net.hasor.core.utils.UnhandledException: java.lang.VerifyError - Inconsistent stackmap frames at branch target 101
Exception Details:
  Location:
    net/hasor/website/manager/UserManager$A_19.loginUpdate(Lnet/hasor/website/domain/UserDO;Ljava/lang/String;)V @101: new
  Reason:
    Type top (current frame, locals[3]) is not assignable to 'java/lang/Throwable' (stack map, locals[3])
  Current Frame:
    bci: @92
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', top, top, 'java/lang/Throwable' }
    stack: { integer }
  Stackmap Frame:
    bci: @101
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', 'java/lang/Throwable' }
    stack: { }
  Bytecode:
    0x0000000: 1002 bd00 0659 1000 1208 5359 1001 120a
    0x0000010: 533a 0410 02bd 000c 5910 002b 5359 1001
    0x0000020: 2c53 3a05 2ab6 0012 1213 1904 b600 173a
    0x0000030: 06bb 0019 5919 062a 1905 b700 1d3a 07bb
    0x0000040: 001f 5912 2119 0619 07b7 0024 b600 283a
    0x0000050: 0819 0857 b13a 0519 05c1 002a 9900 0919
    0x0000060: 05c0 002a bfbb 002a 5919 05b7 002d bf  
  Exception Handler Table:
    bci [0, 83] => handler: 85
  Stackmap Table:
    same_locals_1_stack_item_extended(@85,Object[#4])
    append_frame(@101,Object[#4])

	at net.hasor.core.utils.ExceptionUtils.toRuntimeException(ExceptionUtils.java:28) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.createObject(TemplateBeanBuilder.java:159) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.callSuperCreateObject(BeanContainer.java:156) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.access$000(BeanContainer.java:42) ~[classes/:na]
	at net.hasor.core.container.BeanContainer$1.get(BeanContainer.java:144) ~[classes/:na]
	at net.hasor.core.provider.SingleProvider.get(SingleProvider.java:35) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.createObject(BeanContainer.java:142) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.getDefaultInstance(TemplateBeanBuilder.java:88) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext$1.get(TemplateAppContext.java:149) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext.getInstance(TemplateAppContext.java:98) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.injInject(TemplateBeanBuilder.java:249) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.injectObject(TemplateBeanBuilder.java:232) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.doInject(TemplateBeanBuilder.java:176) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.createObject(TemplateBeanBuilder.java:149) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.callSuperCreateObject(BeanContainer.java:156) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.access$000(BeanContainer.java:42) ~[classes/:na]
	at net.hasor.core.container.BeanContainer$1.get(BeanContainer.java:144) ~[classes/:na]
	at net.hasor.core.provider.SingleProvider.get(SingleProvider.java:35) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.createObject(BeanContainer.java:142) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.getDefaultInstance(TemplateBeanBuilder.java:88) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext$1.get(TemplateAppContext.java:149) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext.getInstance(TemplateAppContext.java:98) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.injInject(TemplateBeanBuilder.java:249) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.injectObject(TemplateBeanBuilder.java:232) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.doInject(TemplateBeanBuilder.java:176) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.createObject(TemplateBeanBuilder.java:149) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.callSuperCreateObject(BeanContainer.java:156) ~[classes/:na]
	at net.hasor.core.container.BeanContainer.createObject(BeanContainer.java:148) ~[classes/:na]
	at net.hasor.core.container.TemplateBeanBuilder.getDefaultInstance(TemplateBeanBuilder.java:88) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext$1.get(TemplateAppContext.java:149) ~[classes/:na]
	at net.hasor.core.context.TemplateAppContext.getInstance(TemplateAppContext.java:98) ~[classes/:na]
	at net.hasor.core.provider.ClassAwareProvider.get(ClassAwareProvider.java:40) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.remote.RsfInvokeFilterChain.doFilter(RsfInvokeFilterChain.java:40) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.RsfFilterHandler.doFilter(RsfFilterHandler.java:43) ~[classes/:na]
	at net.hasor.rsf.filters.online.OnlineRsfFilter.doFilter(OnlineRsfFilter.java:37) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.RsfFilterHandler.doFilter(RsfFilterHandler.java:41) ~[classes/:na]
	at net.hasor.rsf.filters.thread.LocalWarpFilter.doFilter(LocalWarpFilter.java:32) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.RsfFilterHandler.doFilter(RsfFilterHandler.java:41) ~[classes/:na]
	at net.hasor.rsf.filters.local.LocalPref.doFilter(LocalPref.java:49) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.RsfFilterHandler.doFilter(RsfFilterHandler.java:41) ~[classes/:na]
	at net.hasor.rsf.filters.trace.TraceFilter.doFilter(TraceFilter.java:40) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.RsfFilterHandler.doFilter(RsfFilterHandler.java:41) ~[classes/:na]
	at net.hasor.rsf.rpc.caller.remote.InvokerProcessing.run(InvokerProcessing.java:152) ~[classes/:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_74]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_74]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74]
Caused by: java.lang.VerifyError: Inconsistent stackmap frames at branch target 101
Exception Details:
  Location:
    net/hasor/website/manager/UserManager$A_19.loginUpdate(Lnet/hasor/website/domain/UserDO;Ljava/lang/String;)V @101: new
  Reason:
    Type top (current frame, locals[3]) is not assignable to 'java/lang/Throwable' (stack map, locals[3])
  Current Frame:
    bci: @92
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', top, top, 'java/lang/Throwable' }
    stack: { integer }
  Stackmap Frame:
    bci: @101
    flags: { }
    locals: { 'net/hasor/website/manager/UserManager$A_19', 'net/hasor/website/domain/UserDO', 'java/lang/String', 'java/lang/Throwable' }
    stack: { }
  Bytecode:
    0x0000000: 1002 bd00 0659 1000 1208 5359 1001 120a
    0x0000010: 533a 0410 02bd 000c 5910 002b 5359 1001
    0x0000020: 2c53 3a05 2ab6 0012 1213 1904 b600 173a
    0x0000030: 06bb 0019 5919 062a 1905 b700 1d3a 07bb
    0x0000040: 001f 5912 2119 0619 07b7 0024 b600 283a
    0x0000050: 0819 0857 b13a 0519 05c1 002a 9900 0919
    0x0000060: 05c0 002a bfbb 002a 5919 05b7 002d bf  
  Exception Handler Table:
    bci [0, 83] => handler: 85
  Stackmap Table:
    same_locals_1_stack_item_extended(@85,Object[#4])
    append_frame(@101,Object[#4])

	at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_74]
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[na:1.8.0_74]
	at java.lang.Class.getConstructor0(Class.java:3075) ~[na:1.8.0_74]
	at java.lang.Class.getConstructor(Class.java:1825) ~[na:1.8.0_74]
	at net.hasor.core.container.TemplateBeanBuilder.createObject(TemplateBeanBuilder.java:142) ~[classes/:na]
	... 44 common frames omitted

Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

----------

    Hasor 的 Aop 功能是通过 asm 进行动态代理,每个被代理的方法会用如下方式生成。一般情况下这个生成的类是在内存中的,本地磁盘是看不到它的。为了排查框架问题,在 Hasor 3.1.0 版本之后添加了 “WORK_MODE” 环境变量参数,将其设置为 debug。

    之后所有被 Hasor 动态代理的类都会 把生成的 class 保存到 work 目录下的 temp 目录中了。 

    现在看一下 Hasor aop 动态代理方法的全貌把。这个asm 生成动态类的 java 反编译,目测生成的代码没有什么异常。

----------

    既然代码反编译成 java 源文件看不出端倪,那我们就直接 “javap -p -c ”看一下字节码指令上不同的地方。javap 反编译,生成的代码(右侧)和java8下编译的代码(左侧)。经过字节码反编译似乎看出了端倪,难道是因为 return 指令强制后置的问题?

----------

    既然出现问题的代码在 catch 块中,那就把 异常抛出的生成代码简化一下。把上面的代码封装到一个工具类里然后去生成一个更为简单的 throw 语句,如下:

    问题解决。

----------

总结一下:虽然最后引发原因的异常指令暂时没找到,但是问题搞定了。最后原因定位在生成的 if 代码问题上。以后有时间在 深入一下 jvm 源码看看 jdk8 加了什么新东西。

© 著作权归作者所有

共有 人打赏支持
哈库纳

哈库纳

粉丝 964
博文 84
码字总数 151810
作品 4
杭州
后端工程师
私信 提问
加载中

评论(2)

哈库纳
哈库纳

引用来自“hejun_d”的评论

用的是jdk7吗?
jdk8 ,jdk7 u80 上似乎也这样。
hejun_d
hejun_d
用的是jdk7吗?
Hadoop3.1.0分布式计算报的错误 YARN模式

Hadoop3.1.0分布式计算报的错误,Hadoop 3.0.0也报同样的错: Showing 4096 bytes. Click here for full log not assignable to 'org/apache/hadoop/shaded/com/google/protobuf/GeneratedM......

竹子20180630
07/13
0
0
Hadoop3.1.0分布式计算报的错误 YARN模式

Hadoop3.1.0分布式计算报的错误,Hadoop 3.0.0也报同样的错: Showing 4096 bytes. Click here for full log not assignable to 'org/apache/hadoop/shaded/com/google/protobuf/GeneratedM......

竹子20180630
07/13
0
0
需要使用jfinal中的JedisPlugin的一些问题

@Jfinal 现在项目用的jfinal版本是1.9的,需要用到redis缓存。请问需要哪些引入哪些pom依赖。另外现在引入了jedis和common-pool现在报下面这个错误严重: Exception starting filter jfinal ...

raysunnnn
2016/12/13
183
0
jfinal 加载beetl 出错

------------------------------------------beetl加载类------------------------------------------------ package common; import org.beetl.ext.jfinal.BeetlRender; import org.beetl.......

ly71669
2016/02/24
400
2
python--inspect模块

inspect模块主要提供了四种用处:   1.对是否是模块、框架、函数进行类型检查   2.获取源码   3.获取类或者函数的参数信息   4.解析堆栈 一、type and members 1. inspect.getmember...

yaohong
04/18
0
0

没有更多内容

加载失败,请刷新页面

加载更多

设计模式之单例模式

单例模式核心:保证一个类只有一个对象 单例模式分为五种:懒汉式、饿汉式、双重检测锁式、静态内部类式、枚举式 五种模式的特点:懒汉式---线程安全,调用效率高,不能延时加载 饿汉式---线...

森林之下
11分钟前
0
0
markdown语法

这篇博客是本人在使用markdown语法过程中,用于记录一些自己总是会忘记的语法,并且会持续更新; 如何增加批注/备注:>; 这是一条备注/引言 如何手动换行,行末两次空格;

BlackCanary
12分钟前
1
0
redis 设置外网可访问

前提是你已经把redis的端口放到了防火墙计划中,  /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT /etc/rc.d/init.d/iptables save 更改redis.conf 文件 bind 127.0.0.1prot...

时刻在奔跑
14分钟前
0
0
css3隐藏滚动条

chrome 和Safari .element::-webkit-scrollbar { width: 0 } IE 10+ .element { -ms-overflow-style: none; } Firefox .element { overflow: -moz-scrollbars-none; } firefox这个没试过~啦啦......

呵呵闯
30分钟前
0
0
Poco官方PPT_020-ErrorHandlingAndDebugging双语对照翻译

因工作需要用到这一块的功能,所以直接翻译了一下 此PPT来源于官方文件,地址https://pocoproject.org/documentation.html

CHONGCHEN
34分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部