You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Function Java运行时启动失败,JVM崩溃求助

问题:Azure Java函数部署后JVM崩溃,本地运行正常

我有一个使用Java编写的Azure Function,此前部署到函数应用及本地运行均正常。突然Azure函数日志中出现错误,该函数在本地仍可正常运行,但部署到Azure函数应用后无法工作。

日志信息

2024-02-09T02:41:37Z   [Verbose]   Handling WorkerErrorEvent for runtime:java, workerId:java. Failed with: Microsoft.Azure.WebJobs.Script.Workers.WorkerProcessExitException: /usr/lib/jvm/msft-11-x64/bin/java exited with code 134 (0x86)
 ---> System.Exception
   --- End of inner exception stack trace ---
2024-02-09T02:41:37Z   [Verbose]   Attempting to dispose webhost or jobhost channel for workerId: 'x', runtime: 'java'
2024-02-09T02:41:37Z   [Verbose]   Disposing language worker channel with id:x
2024-02-09T02:41:37Z   [Verbose]   Disposed language worker channel with id:x
2024-02-09T02:41:37Z   [Verbose]   No initialized worker channels for runtime 'java'. Delaying future invocations
2024-02-09T02:41:37Z   [Verbose]   Restarting worker channel for runtime: 'java'
2024-02-09T02:41:37Z   [Error]   Exceeded language worker restart retry count for runtime:java. Shutting down and proactively recycling the Functions Host to recover
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   # A fatal error has been detected by the Java Runtime Environment:
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   #  SIGSEGV (0xb) at pc=0x00007c9f44fc1d17 (sent by kill), pid=72, tid=104
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   # JRE version: OpenJDK Runtime Environment Microsoft-8519785 (11.0.21+9) (build 11.0.21+9-LTS)
2024-02-09T02:44:03Z   [Information]   # Java VM: OpenJDK 64-Bit Server VM Microsoft-8519785 (11.0.21+9-LTS, mixed mode, tiered, compressed oops, serial gc, linux-amd64)
2024-02-09T02:44:03Z   [Information]   # Problematic frame:
2024-02-09T02:44:03Z   [Information]   # J 1366 c1 java.lang.invoke.VarForm.getMemberName(I)Ljava/lang/invoke/MemberName; java.base@11.0.21 (21 bytes) @ 0x00007c9f44fc1d17 [0x00007c9f44fc1cc0+0x0000000000000057]
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   # Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/site/wwwroot/core.72)
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   # An error report file with more information is saved as:
2024-02-09T02:44:03Z   [Information]   # /tmp/hs_err_pid72.log
2024-02-09T02:44:03Z   [Information]   Compiled method (c1)    9133 1366       1       java.lang.invoke.VarForm::getMemberName (21 bytes)
2024-02-09T02:44:03Z   [Information]    total in heap  [0x00007c9f44fc1b10,0x00007c9f44fc1ef0] = 992
2024-02-09T02:44:03Z   [Information]    relocation     [0x00007c9f44fc1c88,0x00007c9f44fc1cc0] = 56
2024-02-09T02:44:03Z   [Information]    main code      [0x00007c9f44fc1cc0,0x00007c9f44fc1e00] = 320
2024-02-09T02:44:03Z   [Information]    stub code      [0x00007c9f44fc1e00,0x00007c9f44fc1e40] = 64
2024-02-09T02:44:03Z   [Information]    metadata       [0x00007c9f44fc1e40,0x00007c9f44fc1e48] = 8
2024-02-09T02:44:03Z   [Information]    scopes data    [0x00007c9f44fc1e48,0x00007c9f44fc1e68] = 32
2024-02-09T02:44:03Z   [Information]    scopes pcs     [0x00007c9f44fc1e68,0x00007c9f44fc1ed8] = 112
2024-02-09T02:44:03Z   [Information]    dependencies   [0x00007c9f44fc1ed8,0x00007c9f44fc1ee0] = 8
2024-02-09T02:44:03Z   [Information]    nul chk table  [0x00007c9f44fc1ee0,0x00007c9f44fc1ef0] = 16
2024-02-09T02:44:03Z   [Information]   Could not load hsdis-amd64.so; library not loadable; PrintAssembly is disabled
2024-02-09T02:44:03Z   [Information]   #
2024-02-09T02:44:03Z   [Information]   # If you would like to submit a bug report, please visit:
2024-02-09T02:44:03Z   [Information]   #   https://github.com/microsoft/openjdk/issues
2024-02-09T02:44:03Z   [Information]   #

应用配置检查

已确认以下配置正常且未变更:

"FUNCTIONS_WORKER_RUNTIME": "java",
"FUNCTIONS_EXTENSION_VERSION": "~4",

恢复方案建议

  • 切换JDK版本:当前使用的Microsoft OpenJDK 11.0.21存在触发SIGSEGV崩溃的已知问题,可升级到同系列更高版本(如11.0.22及以上),或切换至OpenJDK 17。在函数应用配置中添加JAVA_VERSION参数,指定目标版本,例如JAVA_VERSION: 11.0.22或JAVA_VERSION: 17。
  • 禁用相关编译器优化:崩溃发生在C1编译的java.lang.invoke.VarForm.getMemberName方法,可通过JVM参数规避。在函数应用配置中添加JAVA_OPTS,设置为-XX:-TieredCompilation关闭分层编译;或使用-XX:CompileCommand=exclude,java/lang/invoke/VarForm.getMemberName排除该方法的编译优化。
  • 手动重启函数应用:自动回收可能未彻底清除异常状态,手动重启整个函数应用实例,尝试恢复正常运行。
  • 排查资源限制:若运行在消耗/基础计划,资源不足可能引发JVM异常,临时升级至标准计划验证是否解决问题,排除资源瓶颈。
  • 重新部署函数包:虽之前部署正常,但可能存在包损坏情况,重新构建并部署最新代码包,确保部署过程完整。

内容的提问来源于stack exchange,提问作者ncgamer99

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 10:24:52