This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 239181 - StackOverflowError at java.util.regex.Pattern$BmpCharProperty.match
Summary: StackOverflowError at java.util.regex.Pattern$BmpCharProperty.match
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: DB schema (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal (vote)
Assignee: Libor Fischmeistr
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2013-12-06 08:09 UTC by Exceptions Reporter
Modified: 2014-01-16 21:11 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 172857


Attachments
stacktrace (110.84 KB, text/plain)
2013-12-06 08:09 UTC, Exceptions Reporter
Details
proposed patch v1 (3.20 KB, patch)
2013-12-09 19:01 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Exceptions Reporter 2013-12-06 08:09:53 UTC
This issue was reported manually by gidravlic.
It already has 3 duplicates 


Build: NetBeans IDE 7.4 (Build 201310111528)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.45-b08, Java(TM) SE Runtime Environment, 1.7.0_45-b18
OS: Windows 7

User Comments:
GUEST: While create entity classes from DataBase ...

GUEST: I'm trying to make a new Database Entity Class.

In my database (MS SQL 2005) we have a couple of views that contain no keys and additionally contain a union.  This error occurs whenever NB (7.0 beta) attempts to enumerate tables / keys.




Stacktrace: 
java.lang.StackOverflowError
   at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
   at java.util.regex.Pattern$Curly.match0(Pattern.java:4148)
   at java.util.regex.Pattern$Curly.match(Pattern.java:4132)
   at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
   at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
   at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715)
Comment 1 Exceptions Reporter 2013-12-06 08:09:55 UTC
Created attachment 142892 [details]
stacktrace
Comment 2 matthias42 2013-12-06 20:16:34 UTC
Could you please provide your db schema? I suspect, that the handling of the call to sp_depends is the cause of this problem, but with a trivial test database (AdventureWorks) this is not reproducible.

If you can't provide the schema, could you check for unnatural names (tables/view with non-ascii names)?
Comment 3 gidravlic 2013-12-09 10:11:23 UTC
Hi!

Sorry, but i can't provide db schema. I noticed that if the number of tables and views is a small count, it does not fall wizard. Tables and views names contain only latin character.
Comment 4 gidravlic 2013-12-09 10:44:46 UTC
To test my hypothesis, I tried create entity classes from my big database with 1394 tables. And wow!!! All work fine. How i can found invalid object in my db? Any guesses?

Thanks!
Comment 5 gidravlic 2013-12-09 11:42:08 UTC
I did some research and found that if you call sp_depends for one my view(View1) Procedure return:
dbo.Table1	user table	no	yes	ID
dbo.Table2	user table	no	yes	Table1ID
dbo.Table2	user table	no	yes	Date
dbo.Table2	user table	no	yes	String1
dbo.View2	view		no	yes	String1
dbo.View2	view		no	yes	String2

After this sp_depends procedure is invoked for view(View2):

dbo.View1	view
dbo.Proc1	stored procedure

After again sp_depends for View1 and so until the error java.lang.StackOverflowError has occurred.

FYI
From MS SQL Help about db_depends:
Important:  
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use sys.dm_sql_referencing_entities and sys.dm_sql_referenced_entities instead.
Comment 6 matthias42 2013-12-09 19:01:39 UTC
Created attachment 142979 [details]
proposed patch v1
Comment 7 matthias42 2013-12-09 19:10:18 UTC
Thank you gidravlic for investigating! The simplest reproducer:

create table t (id int);
create view a as select * from t;
create view b as select * from a;
alter view a as select * from b;

This way you create a recursive view definition.

I see two possible solutions:

1. Track the dependency chain and skip dependencies if they are already analysed
2. Record the recursion level and break the chain at a certain depth.

I decided to take the second route, as this also prevents excessivly deep chains. A patch implementing that is attached.

With regard to the deprecation and replacement of the function, I would not consider it right now. The mentioned alternative "dm_sql_referenced_entities" is only presend in 2008 and newer. This is not that old (at work we have several 2005 instances running).


As the problem can't be worked around (apart from cleaning the database), I'm raising the priority to P2.
Comment 8 gidravlic 2013-12-10 08:10:17 UTC
matthias42 thanks for the quick response.
Comment 9 Libor Fischmeistr 2014-01-08 12:23:00 UTC
Finally patch applied: http://hg.netbeans.org/core-main/rev/244254c3c7f1

Matthias, thank you very much for it.

Please verify if possible.

Thanks
Comment 10 matthias42 2014-01-16 21:11:07 UTC
(In reply to Libor Fischmeistr from comment #9)
> Finally patch applied: http://hg.netbeans.org/core-main/rev/244254c3c7f1
> 
> Matthias, thank you very much for it.
> 
> Please verify if possible.

I verified with the core-main build I did today and the db I created to reproduce the problem. While my 7.4 installation is broken (as in the original report), core-main works.