8 Replies Latest reply on Aug 21, 2017 6:34 PM by Gary Graham-Oracle

    Find DB object spins until out of memory in specific conditions

    Alastair M

      I think I have found a bug with the Find DB object feature in Sql Developer 4.2 (and also in 17.2).

       

      To reproduce, create a test view as follows:

       

      create or replace view test_view as
      select dummy
      from dual
      order by dummy;
      

       

      Then, go to View > Find DB Object. Make sure All Views is selected under Code and enter 'dummy' as the search string. Hit Go and it will spin for 5 or 6 minutes before eventually crashing. In the logs is the message:

       

        ORA-04030: out of process memory when trying to allocate 16328 bytes (koh-kghu call ,pl/sql vc2)

       

      Looking into the statement that SQL Developer issues it seems there is a logic bug. If there is a match on more than one line of a view including the last line then it fails. At least in my case, the last line of the view text does not end with a chr(10) and so the line_end variable is not set correctly.

       

      A suggested fix would be to add the following ELSE logic to the first IF statement:

       

                  IF instr(
                      text,
                      chr(10),
                      match_pos
                  ) > 0 THEN
                      line_end := instr(
                          text,
                          chr(10),
                          match_pos
                      ) - 1;
                      l_char := substr(
                          text,
                          1,
                          line_end
                      );
                  ELSE -- bug fix: added this line
                    line_end := rec.text_length; -- bug fix: added this line
                  END IF;
      

       

      This was happening when searching through a schema with a large number of views so it took a while to track down which one was causing the problem.

       

      Also, this was on an 11.2 database but I just tried it on 12.1 as well with same results.