Forums

COBRA INTERNAL ERROR / ArgumentException / An item with the

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby gauthier » Fri Dec 26, 2008 9:17 am

I get internal error when compiling dll with many dependencies (nhibernate, activerecord, windsor...)

Code: Select all
error: COBRA INTERNAL ERROR / ArgumentException / An item with the same key has already been added.


the compiler arguments look like that:
Code: Select all
-t:lib
-color
-d
-out:%PROJECT%\build\net-3.5\debug\bdabd.BusinessLogic.Billing.Implementation.dll
-ref:%PROJECT%\build\net-3.5\debug\castleproject\bin\Castle.Core.dll
-ref:%PROJECT%\build\net-3.5\debug\nhibernate\bin\Iesi.Collections.dll
-ref:%PROJECT%\build\net-3.5\debug\nhibernate\bin\NHibernate.dll
-ref:%PROJECT%\build\net-3.5\debug\smoothdev\bin\smoothdev.Data.Entities.dll
-ref:%PROJECT%\build\net-3.5\debug\smoothdev\bin\smoothdev.FluentSignature.dll
-ref:%PROJECT%\build\net-3.5\debug\projectlib1.dll
-ref:%PROJECT%\build\net-3.5\debug\projectlib2.dll
-ref:%PROJECT%\build\net-3.5\debug\projectlib3.dll
-ref:%PROJECT%\build\net-3.5\debug\projectlib4.dll
-ref:%PROJECT%\build\net-3.5\debug\projectlib5.dll
%PROJECT%\...\source.cobra


some projectlibs are cobra assemblies

This is after having progressively added needed dependencies to the build script, I also got FileNotFoundException when dependency order doesn't suit cobra well (when same order is working with csc).

Anyone encounter theses issues with large solution?

anyway to diagnostic how cobra parse references?
gauthier
 
Posts: 116

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby Charles » Fri Dec 26, 2008 10:14 am

Try adding:

cobra -v:3 -reveal-internal-exceptions ...
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby gauthier » Tue Dec 30, 2008 5:32 am

Sadly, for my particular case, the additional arguments doesn't show any detail for the exception.

What I see is that the order of dependencies is tweaked from the order given in the command line.

The argument exception does'nt say more.

It worth mentioning that some assemblies (c# or cobra) contains the same namespaces.
gauthier
 
Posts: 116

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby Charles » Tue Dec 30, 2008 10:52 am

-- Are you using the latest source or the last release (0.8)?

-- It would be highly unusual for -v:3 not to show additional output. Also, it would be unusual for -reveal-internal-exceptions to leave the message as "COBRA INTERNAL ERROR / Argument Exception / ..." instead of dumping the exception stack to the console. Consider this program:
class X

def main is shared
pass
%% throw

When run from the command line as:

cobra -v:3 -reveal-internal-exceptions internal-error.cobra > r 2>&1

The output captured in r is:

Cobra Command Line 0.8.0 post-release
Copyright (C) 2003-2008 by Cobra Language LLC.

OS Version: Microsoft Windows NT 5.1.2600 Service Pack 2
CLR Platform: .NET
CLR Version: 2.0.50727.3053
Current Directory: C:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source
Current Exe: C:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\cobra.exe
Option Dictionary:
reveal-internal-exceptions: true
verbosity: 3
contracts: 'inline'
correct-source: Set<of String>['none']
debugging-tips: true
embed-run-time: false
include-asserts: true
include-nil-checks: true
include-tests: true
include-traces: true
number: 'decimal'
Paths:
internal-error.cobra
Adding reference to Cobra.Lang.dll
Reading assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
Reading assembly: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 at C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
Final assembly reference list:
0. Cobra.Lang.dll
Loading reference: Cobra.Lang.dll
Reading assembly: Cobra.Lang, Version=0.8.0.1, Culture=neutral, PublicKeyToken=null at C:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\Cobra.Lang.dll
Noting C:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraInfo.cs
Parsing internal-error.cobra

Unhandled Exception: Cobra.Lang_ert_bdc3941bd5a2d15da53a1dea2c6c8319.AssertException:
sourceSite = C:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraParser.cobra:577 in Parser.compilerDirective for object Parser
info = IdentifierExpr-de(5365, didBindInh=false, didBindInt=false, didBindImp=false, token=Token(THROW, 'throw', 'throw', ln 5, col 4, internal-error.cobra), name=throw, type=nil, 5365)
this = Parser

at Parser.CompilerDirective() in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraParser.cobra:line 577
at Parser._parseTokens() in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraParser.cobra:line 528
at Parser.ParseSource(String fileName, String source) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraParser.cobra:line 196
at Parser.ParseFileNamed(String fileName) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CobraParser.cobra:line 179
at Compiler.ParseFilesNamed(IList`1 filenames) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\Compiler.cobra:line 432
at Compiler._compileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\Compiler.cobra:line 297
at Compiler.CompileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\Compiler.cobra:line 264
at CommandLine.DoCompile(List`1 paths, Boolean willPrintSuccessMsg, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CommandLine.cobra:line 570
at CommandLine.DoRun(List`1 paths) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CommandLine.cobra:line 646
at CommandLine.Run(List`1 args) in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CommandLine.cobra:line 543
at CommandLine.Run() in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\CommandLine.cobra:line 485
at CobraMain.Main() in c:\Documents and Settings\Chuck\My Documents\Projects\Cobra\Workspace-New\Source\cobra.cobra:line 13


I would like to know your output for:

cobra -v:3 -reveal-internal-exceptions internal-error.cobra (YOUR-ARGS) > r 2>&1

Also, please attach r instead of pasting here as I did for illustrative purposes.

Thanks,
Chuck
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby gauthier » Tue Dec 30, 2008 11:38 am

Sorry, I meant "same with uptodate cobra and default parameters"

here is the complete output

Code: Select all
NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///%ROOT%/src/model/tests/unit/lib12.TestFixtures/lib12.TestFixtures.build
Target framework: Microsoft .NET Framework 3.5
Target(s) specified: build

     [echo] Detected NAnt 0.86 Beta 1, consider upgrading to a newer version when building for .NET 3.5

common.check-nant-version:


common.find-tools:


set-framework-configuration:


set-net-3.5-framework-configuration:


set-project-configuration:


set-debug-project-configuration:


base.init:


common.cobra.init:


init:


common.compile-cobra-tests:


common.compile-cobra-dll:

    [cobra] Compiling 1 files to '%ROOT%\build\net-3.5\debug\lib12.dll'.
    [cobra] Cobra Command Line 0.8.0 post-release
    [cobra] Copyright (C) 2003-2008 by Cobra Language LLC.
    [cobra]
    [cobra] OS Version:   Microsoft Windows NT 5.1.2600 Service Pack 2
    [cobra] CLR Platform: .NET
    [cobra] CLR Version:  2.0.50727.1433
    [cobra] Current Directory: %ROOT%\src\model\tests\unit\lib12
    [cobra] Current Exe: C:\Cobra\Cobra-0.8.0-post\bin\cobra.exe
    [cobra] Option Dictionary:
    [cobra]     target: 'lib'
    [cobra]     color: true
    [cobra]     debug: '+'
    [cobra]     embed-run-time: true
    [cobra]     out: '%ROOT%\build\net-3.5\debug\lib12.TestFixtures.dll'
    [cobra]     reference: List<of String>['%ROOT%\build\net-3.5\debug\nunit\bin\nunit.framework.dll', '%ROOT%\build\net-3.5\debug\log4net\bin\log4net.dll', '%ROOT%\build\net-3.5\debug\nhibernate\bin\Iesi.Collections.dll', '%ROOT%\build\net-3.5\debug\nhibernate\bin\NHibernate.dll', '%ROOT%\build\net-3.5\debug\castleproject\bin\Castle.ActiveRecord.dll', '%ROOT%\build\net-3.5\debug\castleproject\bin\Castle.Core.dll', '%ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.Data.Entities.dll', '%ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.FluentSignature.dll', '%ROOT%\build\net-3.5\debug\lib11.dll', '%ROOT%\build\net-3.5\debug\lib10.dll', '%ROOT%\build\net-3.5\debug\lib9.dll', '%ROOT%\build\net-3.5\debug\lib8.dll']
    [cobra]     library-directory: List<of String>['%ROOT%\build\net-3.5\debug/castleproject/bin']
    [cobra]     verbosity: 3
    [cobra]     reveal-internal-exceptions: true
    [cobra]     exception-report: true
    [cobra]     detailed-stack-trace: true
    [cobra]     contracts: 'inline'
    [cobra]     correct-source: Set<of String>['none']
    [cobra]     debugging-tips: false
    [cobra]     include-asserts: true
    [cobra]     include-nil-checks: true
    [cobra]     include-tests: true
    [cobra]     include-traces: true
    [cobra]     number: 'decimal'
    [cobra]     compile: true
    [cobra] Paths:
    [cobra]     %ROOT%\src\model\tests\unit\lib12\TestFixture.cobra
    [cobra] Reading assembly:  mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
    [cobra] Reading assembly:  System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 at C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
    [cobra] Final assembly reference list:
    [cobra] 0. %ROOT%\build\net-3.5\debug\nunit\bin\nunit.framework.dll
    [cobra] 1. %ROOT%\build\net-3.5\debug\log4net\bin\log4net.dll
    [cobra] 2. %ROOT%\build\net-3.5\debug\nhibernate\bin\Iesi.Collections.dll
    [cobra] 3. %ROOT%\build\net-3.5\debug\nhibernate\bin\NHibernate.dll
    [cobra] 4. %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.ActiveRecord.dll
    [cobra] 5. %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.Core.dll
    [cobra] 6. %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.Data.Entities.dll
    [cobra] 7. %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.FluentSignature.dll
    [cobra] 8. %ROOT%\build\net-3.5\debug\lib12.dll
    [cobra] 9. %ROOT%\build\net-3.5\debug\lib11.dll
    [cobra] 10. %ROOT%\build\net-3.5\debug\lib10.dll
    [cobra] 11. %ROOT%\build\net-3.5\debug\lib9.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\nunit\bin\nunit.framework.dll
    [cobra] Reading assembly:  nunit.framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77 at C:\WINDOWS\assembly\GAC_MSIL\nunit.framework\2.2.8.0__96d09a1eb7f44a77\nunit.framework.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\log4net\bin\log4net.dll
    [cobra] Reading assembly:  log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 at %ROOT%\build\net-3.5\debug\log4net\bin\log4net.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\nhibernate\bin\Iesi.Collections.dll
    [cobra] Reading assembly:  Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4 at %ROOT%\build\net-3.5\debug\nhibernate\bin\Iesi.Collections.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\nhibernate\bin\NHibernate.dll
    [cobra] Reading assembly:  NHibernate, Version=2.1.0.1001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4 at %ROOT%\build\net-3.5\debug\nhibernate\bin\NHibernate.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.ActiveRecord.dll
    [cobra] Reading assembly:  Castle.ActiveRecord, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc at %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.ActiveRecord.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.Core.dll
    [cobra] Reading assembly:  Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc at %ROOT%\build\net-3.5\debug\castleproject\bin\Castle.Core.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.Data.Entities.dll
    [cobra] Reading assembly:  smoothdev.Data.Entities, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null at %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.Data.Entities.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.FluentSignature.dll
    [cobra] Reading assembly:  smoothdev.FluentSignature, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null at %ROOT%\build\net-3.5\debug\smoothdev\bin\smoothdev.FluentSignature.dll
    [cobra] Loading reference: %ROOT%\build\net-3.5\debug\lib11.dll
    [cobra] Reading assembly:  lib11, Version=0.0.1.0, Culture=neutral, PublicKeyToken=null at %ROOT%\build\net-3.5\debug\lib11.dll
    [cobra] An unhandled exception has occurred.
    [cobra]
    [cobra] Cobra debugging tips:
    [cobra]     To get file name and line number information for the stack frames, use:
    [cobra]         cobra -debug foo.cobra
    [cobra]     To get a post-mortem, HTML-formatted report with more details about your objects:
    [cobra]         cobra -debug -exception-report foo.cobra
    [cobra]     For even more information, try:
    [cobra]         cobra -debug -exception-report -detailed-stack-trace foo.cobra
    [cobra]     Or use the abbreviations:
    [cobra]         cobra -d -er -dst foo.cobra
    [cobra]
    [cobra]
    [cobra] Unhandled Exception: System.ArgumentException: An item with the same key has already been added.
    [cobra]    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
    [cobra]    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    [cobra]    at Container`1.AddDecl(TMember decl)
    [cobra]    at NameSpace.AddDecl(INameSpaceMember decl)
    [cobra]    at NameSpace.GetOrMakeNameSpaceNamed(IToken token, String name)
    [cobra]    at NameSpace.GetOrMakeNameSpaceNamed(IToken token, String name)
    [cobra]    at Compiler.ReadAssembly(Assembly ass, Boolean skipCobra)
    [cobra]    at Compiler.LoadReference(String reference)
    [cobra]    at Compiler.ReadAssemblyTypes(OptionValues options)
    [cobra]    at Compiler.ParseFilesNamed(IList`1 filenames)
    [cobra]    at Compiler._compileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt)
    [cobra]    at Compiler.CompileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt)
    [cobra]    at CommandLine.DoCompile(List`1 paths, Boolean willPrintSuccessMsg, Boolean writeTestInvocation, Boolean stopAfterBindInt)
    [cobra]    at CommandLine.DoCompile(List`1 paths)
    [cobra]    at CommandLine.Run(List`1 args)
    [cobra]    at CommandLine.Run()
    [cobra]    at CobraMain.Main()

BUILD FAILED - 0 non-fatal error(s), 19 warning(s)

%ROOT%\common.project.nant.xml(162,4):
External Program Failed: cobra (return code was -532459699)

Total time: 8.3 seconds.


hopefully, it seems the stack trace reveal the location of the error: NameSpace.AddDecl
gauthier
 
Posts: 116

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby Charles » Wed Dec 31, 2008 2:49 am

Well we're closer to understanding. Cobra thinks there is a duplicate member declaration in a type in lib11.dll. But there are a few dictionaries being updated in that method.

When Cobra is installed, it's compiled with -turbo which turns off contracts and other checks. I've just checked in an enhancement so you can say:

install-from-workspace -debug

And the "-debug" will replace the -turbo. Be sure to do an svn up first, the install and then try again.

(http://cobra-language.com/trac/cobra/changeset/1860)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby gauthier » Thu Jan 01, 2009 8:08 am

The problem is reproducible by referencing 2 assemblies containing a same namespace part without the same case:

lib1.cs
Code: Select all
namespace Name1 {public class Foo {}}


csc /target:library lib1.cs

lib2.cs
Code: Select all
namespace name1 {public class Bar {}}


csc /target:library lib2.cs

class Program
def main is shared
pass


cobra -ref:lib1.dll -ref:lib2.dll main.cobra
gauthier
 
Posts: 116

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby Charles » Thu Jan 01, 2009 8:18 pm

Thanks for distilling this down. I'll fix.

Btw is this something that you corrected after you found it, or do you really want two namespaces that differ by case only? I'm curious how/why this comes up.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby Charles » Fri Jan 02, 2009 2:40 am

I checked in some improvements. Update and try again.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: COBRA INTERNAL ERROR / ArgumentException / An item with the

Postby gauthier » Tue Jan 06, 2009 12:32 pm

Chuck wrote:Btw is this something that you corrected after you found it, or do you really want two namespaces that differ by case only? I'm curious how/why this comes up.


I took ownership of horrendous codebase and decided the new architecture (working with existing app runtime) took place in the same namespace with first part as lowercased, this is edge but realworld case (you can't avoid someone being to create "system" or anything).
gauthier
 
Posts: 116


Return to Discussion

Who is online

Users browsing this forum: No registered users and 27 guests