Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273011

JVM crashed when String.valueOf(a / b) should throw ArithmeticException: / by zero

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      # JRE version: OpenJDK Runtime Environment (Zulu 8.54.0.21-CA-macosx) (8.0_292-b10) (build 1.8.0_292-b10)
      # Java VM: OpenJDK 64-Bit Server VM (25.292-b10 mixed mode bsd-amd64 compressed oops)

      A DESCRIPTION OF THE PROBLEM :
      # Problematic frame:
      # j com.alibaba.cloud.examples.ProviderApplication$EchoController.divide(Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/String;+5
      #
      # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
      #


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      start provider,
      start consumer,
      request url http://127.0.0.1:18083/divide-feign2?a=2

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      report error by divide zero
      ACTUAL -
      #
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # SIGFPE (0x8) at pc=0x0000000112e9a5e8, pid=40515, tid=0x000000000000b503
      #
      # JRE version: OpenJDK Runtime Environment (Zulu 8.54.0.21-CA-macosx) (8.0_292-b10) (build 1.8.0_292-b10)
      # Java VM: OpenJDK 64-Bit Server VM (25.292-b10 mixed mode bsd-amd64 compressed oops)
      # Problematic frame:
      # j com.alibaba.cloud.examples.ProviderApplication$EchoController.divide(Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/String;+5
      #
      # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
      #
      # An error report file with more information is saved as:
      # /Users/luosong/Desktop/sources/spring-cloud-alibaba-master/hs_err_pid40515.log
      Compiled method (c1) 65474 745 1 java.lang.Integer::intValue (5 bytes)
       total in heap [0x00000001130ba010,0x00000001130ba2a8] = 664
       relocation [0x00000001130ba138,0x00000001130ba160] = 40
       main code [0x00000001130ba160,0x00000001130ba1e0] = 128
       stub code [0x00000001130ba1e0,0x00000001130ba270] = 144
       metadata [0x00000001130ba270,0x00000001130ba278] = 8
       scopes data [0x00000001130ba278,0x00000001130ba280] = 8
       scopes pcs [0x00000001130ba280,0x00000001130ba2a0] = 32
       dependencies [0x00000001130ba2a0,0x00000001130ba2a8] = 8
      #
      # If you would like to submit a bug report, please visit:
      # http://www.azulsystems.com/support/
      #
      Disconnected from the target VM, address: '127.0.0.1:52211', transport: 'socket'

      Process finished with exit code 134 (interrupted by signal 6: SIGABRT)


      ---------- BEGIN SOURCE ----------
      provider:

      package com.alibaba.cloud.examples;

      import org.springframework.boot.SpringApplication;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
      import org.springframework.http.HttpStatus;
      import org.springframework.http.ResponseEntity;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.bind.annotation.RestController;


      @EnableDiscoveryClient
      @SpringBootApplication
      public class ProviderApplication {

      public static void main(String[] args) {
      SpringApplication.run(ProviderApplication.class, args);
      }

      @RestController
      class EchoController {

      @GetMapping("/divide")
      public String divide(@RequestParam Integer a, @RequestParam Integer b) {
      return String.valueOf(a / b);
      }

      }

      }

      consumer:


      package com.alibaba.cloud.examples;

      import com.alibaba.cloud.examples.ConsumerApplication.EchoService;
      import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;

      import org.springframework.boot.SpringApplication;
      import org.springframework.boot.autoconfigure.SpringBootApplication;
      import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
      import org.springframework.cloud.client.loadbalancer.LoadBalanced;
      import org.springframework.cloud.openfeign.EnableFeignClients;
      import org.springframework.cloud.openfeign.FeignClient;
      import org.springframework.context.annotation.Bean;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.client.RestTemplate;


      @SpringBootApplication
      @EnableDiscoveryClient(autoRegister = true)
      @EnableFeignClients
      public class ConsumerApplication {

      @LoadBalanced
      @Bean
      @SentinelRestTemplate(urlCleanerClass = UrlCleaner.class, urlCleaner = "clean")
      public RestTemplate restTemplate() {
      return new RestTemplate();
      }

      @LoadBalanced
      @Bean
      @SentinelRestTemplate
      public RestTemplate restTemplate1() {
      return new RestTemplate();
      }

      public static void main(String[] args) {
      SpringApplication.run(ConsumerApplication.class, args);
      }

      @FeignClient(name = "service-provider", fallback = EchoServiceFallback.class,
      configuration = FeignConfiguration.class)
      public interface EchoService {

      @GetMapping("/echo/{str}")
      String echo(@PathVariable("str") String str);

      @GetMapping("/divide")
      String divide(@RequestParam("a") Integer a, @RequestParam("b") Integer b);

      default String divide(Integer a) {
      return divide(a, 0);
      }

      @GetMapping("/notFound")
      String notFound();

      }

      }

      class FeignConfiguration {

      @Bean
      public EchoServiceFallback echoServiceFallback() {
      return new EchoServiceFallback();
      }

      }

      class EchoServiceFallback implements EchoService {

      @Override
      public String echo(@PathVariable("str") String str) {
      return "echo fallback";
      }

      @Override
      public String divide(@RequestParam Integer a, @RequestParam Integer b) {
      return "divide fallback";
      }

      @Override
      public String notFound() {
      return "notFound fallback";
      }

      }

      TestController:

      package com.alibaba.cloud.examples;

      import com.alibaba.cloud.examples.ConsumerApplication.EchoService;

      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.cloud.client.discovery.DiscoveryClient;
      import org.springframework.web.bind.annotation.GetMapping;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.bind.annotation.RestController;
      import org.springframework.web.client.RestTemplate;

      @RestController
      public class TestController {


      @Autowired
      private EchoService echoService;

      @Autowired
      private DiscoveryClient discoveryClient;



      @GetMapping("/divide-feign2")
      public String divide(@RequestParam Integer a) {
      return echoService.divide(a);
      }


      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vkempik Vladimir Kempik
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: