Bug 36785 - Segmentation fault in Gnat.Regexp
Summary: Segmentation fault in Gnat.Regexp
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-10 11:28 UTC by Duncan Sands
Modified: 2015-12-05 16:49 UTC (History)
3 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-08-03 12:07:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Sands 2008-07-10 11:28:45 UTC
$ gnatmake rtest.adb
gcc -c rtest.adb
gnatbind -x rtest.ali
gnatlink rtest.ali
$ ./rtest

raised STORAGE_ERROR : stack overflow (or erroneous memory access)

Also occurs with GNAT GPL 2008.

-- chop here --
with Gnat.Regexp;
procedure RTest is
   R : constant Gnat.Regexp.Regexp := Gnat.Regexp.Compile
     (Pattern => ".*AB.*|.*XYZ.*|.*0123456.*");
   B : Boolean;
begin
   B := Gnat.Regexp.Match("A", R);
end;
Comment 1 Samuel Tardieu 2008-08-03 12:07:22 UTC
Confirmed on 4.4.0 20080803 (i686-pc-linux-gnu).
Comment 2 Duncan Sands 2009-02-17 13:36:14 UTC
If I unsupress checks in System.Regexp.Compile.Create_Secondary_Table,
then I get
  "raised CONSTRAINT_ERROR : s-regexp.adb:1161 index check failed"
here:

1160                for Column in 0 .. Alphabet_Size loop
1161                   Meta_States (Nb_State + 1) := (others => False); -- Here
1162                   Temp_State_Not_Null := False;

The reason is that Nb_State + 1 is beyond Meta_States'Last.
Comment 3 Eric Botcazou 2015-12-05 16:49:42 UTC
2014-01-29  Emmanuel Briot  <briot@adacore.com>

	* s-regexp.adb (Create_Secondary_Table): Automatically grow the state
	machine as needed.
	(Dump): New subprogram.