文档章节

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 加了什么新东西。

© 著作权归作者所有

共有 人打赏支持
哈库纳

哈库纳

粉丝 961
博文 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

没有更多内容

加载失败,请刷新页面

加载更多

Sqoop 操作实例补充

导入指定字段和指定条件的行记录 # 指定导入的字段--columns <col,col,col…># 指定过滤条件--where <where clause># 设置切分的工作单元--split-by <column-name># 目标目录存在...

PeakFang-BOK
25分钟前
2
0
App store 侵权投诉

App Store Content Dispute 侵权投诉 https://www.apple.com/legal/internet-services/itunes/appstorenotices/#?lang=zh...

壹峰
28分钟前
1
0
教程:如何在window上安装Apache HTTP Server

Apache官网只提供 Apache HTTP Server 的源代码,不提供编译好的二进制文件。 不过我们还是可以从网络上找到其他人编译好的Apache HTTP Server。 首先,从 https://www.apachehaus.com/cgi-b...

Doxde
45分钟前
1
0
中国移动蔡谦:5G传输准备就绪

目前5G已成业界热议话题,在即将到来的万物互联时代,5G是非常关键的技术。且5G相比4G,业务场景多种多样,对5G承载网带来巨大挑战。5G传输,承载先行并不仅仅是一个口号。当前5G承载网的部署...

linux-tao
53分钟前
4
0
维护“修理权”,苹果使用专有软件工具来修复MacBook Pro和iMac Pro

根据上月发给苹果授权服务提供商的一份文件,苹果公司正在使用新的专有软件诊断工具来修复MacBook Pros和iMac Pros,如果不用专有软件工具来修复关键部件,将会导致“系统失效和修复不完整”...

linuxCool
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部