Getting an exception in gendarme while analyzing a c# application using sonar

730 views
Skip to first unread message

vishnu

unread,
Jan 1, 2012, 10:50:51 PM1/1/12
to Gendarme
Today when I analyzed a C# application (source code size above 20
mb).I am getting an exception as shown below

[INFO] [11:05:44.212] Sensor
com.hello2morrow.sonarplugin.SonargraphSensor@11ae15a done: 370 ms
[INFO] [11:05:44.212] Sensor CpdSensor...
[INFO] [11:05:44.212] PmdEngine is used
[INFO] [11:05:45.952] Sensor CpdSensor done: 1740 ms
[INFO] [11:05:45.952] Sensor
org.sonar.plugins.csharp.gendarme.GendarmeSensor@10e0623...
[INFO] [11:05:45.962] Gendarme executable not found: 'C:\Program Files
\gendarme-2.10-bin\gendarme.exe'. The embedded version (2.10) will be
used instead.
[INFO] [11:05:47.246]
[INFO] [11:05:47.246] An uncaught exception occured. Please fill a bug
report at https://bugzilla.novell.com/
[INFO] [11:05:47.246] Stack trace: System.ArgumentOutOfRangeException:
Specified argument was out of the range of valid values.
[INFO] [11:05:47.246] at
Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
[INFO] [11:05:47.246] at
Gendarme.Framework.Symbols.ExtractFirst(MethodDefinition method)
[INFO] [11:05:47.246] at
Gendarme.Framework.Symbols.ExtractFirst(TypeDefinition type)
[INFO] [11:05:47.246] at
Gendarme.Framework.Symbols.GetSource(Defect defect)
[INFO] [11:05:47.246] at Gendarme.Framework.Defect.get_Source()
[INFO] [11:05:47.246] at
Gendarme.XmlResultWriter.CreateElement(Defect defect)
[INFO] [11:05:47.246] at Gendarme.XmlResultWriter.CreateDefects()
[INFO] [11:05:47.246] at Gendarme.XmlResultWriter.Write()
[INFO] [11:05:47.246] at Gendarme.ResultWriter.Report()
[INFO] [11:05:47.246] at Gendarme.ConsoleRunner.Report()
[INFO] [11:05:47.246] at Gendarme.ConsoleRunner.Execute(String[]
args)
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Can not execute Sonar

Embedded error: Gendarme execution failed.
Gendarme analysis failed: execution was interrupted by a non-handled
exception. This is likely a bug inside Gendarme and should be reported
on Novell's bugzilla (http://bugzilla.novell.com) or on the mailing-
list.
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 59 seconds
[INFO] Finished at: Fri Dec 30 11:05:47 IST 2011
[INFO] Final Memory: 21M/62M
[INFO]
------------------------------------------------------------------------

I am using sonar 2.12

I tried with maven and as well as with simple java runner

When I searched for similar exception in web I could n’t able find
valid reason for this issue.

Please help me out in resolving this issue

Alik Kurdyukov

unread,
Feb 13, 2012, 7:27:01 AM2/13/12
to Gendarme
Hi,

I have exactly the same exception. And the problem has something to
relation with COM library connection. I just turned off Gendarme from
sonar build. I'll try to investigate the problem if I build Gandarme.

On Jan 2, 7:50 am, vishnu <vishnu.vis2...@gmail.com> wrote:
> Today when I analyzed a C# application (source code size above 20
> mb).I am getting an exception  as shown below
>
> [INFO] [11:05:44.212] Sensor
> com.hello2morrow.sonarplugin.SonargraphSensor@11ae15a done: 370 ms
> [INFO] [11:05:44.212] Sensor CpdSensor...
> [INFO] [11:05:44.212] PmdEngine is used
> [INFO] [11:05:45.952] Sensor CpdSensor done: 1740 ms
> [INFO] [11:05:45.952] Sensor
> org.sonar.plugins.csharp.gendarme.GendarmeSensor@10e0623...
> [INFO] [11:05:45.962] Gendarme executable not found: 'C:\Program Files
> \gendarme-2.10-bin\gendarme.exe'. The embedded version (2.10) will be
> used instead.
> [INFO] [11:05:47.246]
> [INFO] [11:05:47.246] An uncaught exception occured. Please fill a bug
> report athttps://bugzilla.novell.com/

Jb Evain

unread,
Feb 13, 2012, 8:09:26 AM2/13/12
to gend...@googlegroups.com
Hey,

On Mon, Jan 2, 2012 at 4:50 AM, vishnu <vishnu....@gmail.com> wrote:
> [INFO] [11:05:47.246] An uncaught exception occured. Please fill a bug
> report at https://bugzilla.novell.com/
> [INFO] [11:05:47.246] Stack trace: System.ArgumentOutOfRangeException:
> Specified argument was out of the range of valid values.
> [INFO] [11:05:47.246]    at
> Mono.Collections.Generic.Collection`1.get_Item(Int32 index)
> [INFO] [11:05:47.246]    at
> Gendarme.Framework.Symbols.ExtractFirst(MethodDefinition method)
> [INFO] [11:05:47.246]    at
> Gendarme.Framework.Symbols.ExtractFirst(TypeDefinition type)
> [INFO] [11:05:47.246]    at
> Gendarme.Framework.Symbols.GetSource(Defect defect)
> [INFO] [11:05:47.246]    at Gendarme.Framework.Defect.get_Source()
> [INFO] [11:05:47.246]    at

This stack trace seems to indicate that you have a method with the
HasBody flag, but which doesn't have any Instruction.

Could you verify that this assumption is true?

I'll fix gendarme to not crash on this anyway.

Jb

Alik Kurdyukov

unread,
Feb 13, 2012, 8:35:24 AM2/13/12
to gend...@googlegroups.com
Hey,

I'm not sure I understand what's HasBody flag for methods. How can I check the assumption?
 
The assembly that crashed Gendarme includes 'native' code with ".custom" marks on methods. ILDASM show no disassemblies for them. For ex:

.class interface public abstract auto ansi import P2ClientGateMTA.IP2BLMessage

{

  .custom instance void [mscorlib]System.Runtime.InteropServices.TypeIdentifierAttribute::.ctor() = ( 01 00 00 00 ) 

  .custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 41 38 35 42 43 37 41 33 2D 39 43 45 34   // ..$A85BC7A3-9CE4

                                                                                                  2D 34 32 39 45 2D 41 33 37 30 2D 35 38 37 35 44   // -429E-A370-5875D

                                                                                                  45 46 45 42 33 45 39 00 00 )                      // EFEB3E9..

  .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 

} // end of class P2ClientGateMTA.IP2BLMessage



--
Best regards, 
Alik Kurdyukov

--
You received this message because you are subscribed to the Google Groups "Gendarme" group.
To post to this group, send email to gend...@googlegroups.com.
To unsubscribe from this group, send email to gendarme+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gendarme?hl=en.

Jb Evain

unread,
Feb 13, 2012, 9:31:59 AM2/13/12
to gend...@googlegroups.com
On Mon, Feb 13, 2012 at 2:35 PM, Alik Kurdyukov <akurd...@gmail.com> wrote:
> I'm not sure I understand what's HasBody flag for methods. How can I check
> the assumption?

You can run on your assembly a piece of code using Cecil like:

var module = ModuleDefinition.ReadModule("MyAssembly.dll");
foreach (var method in module.GetTypes().SelectMany(t =>
t.Methods).Where(m => m.HasBody && m.Body.Instructions.Count == 0)) {
Console.WriteLine ("Method with empty body: {0}", method);
}

And you'll have the names of actual methods with empty bodies.

Jb

Alik Kurdyukov

unread,
Feb 13, 2012, 10:01:25 AM2/13/12
to gend...@googlegroups.com
Thank you for code sample. For my assembly it gives:

Method with empty body: System.Void P2ClientGateMTA.IP2Connection::_VtblGap1_1()
Method with empty body: System.Void P2ClientGateMTA.IP2Connection::_VtblGap2_5()
Method with empty body: System.Void P2ClientGateMTA.IP2Connection::_VtblGap3_2()
Method with empty body: System.Void P2ClientGateMTA.IP2Connection::_VtblGap4_2()
Method with empty body: System.Void P2ClientGateMTA.IP2TableSet::_VtblGap1_4()
Method with empty body: System.Void P2ClientGateMTA.IP2TableSet::_VtblGap2_5()
Method with empty body: System.Void P2ClientGateMTA.IP2DataStreamEvents_Event::_VtblGap1_2()
Method with empty body: System.Void P2ClientGateMTA.IP2DataStreamEvents_Event::_VtblGap2_4()
Method with empty body: System.Void P2ClientGateMTA.IP2BLMessage::_VtblGap1_3()
Method with empty body: System.Void P2ClientGateMTA.IP2BLMessage::_VtblGap2_3()
Method with empty body: System.Void P2ClientGateMTA.IP2DataStreamEvents::_VtblGap1_1()
Method with empty body: System.Void P2ClientGateMTA.IP2DataStreamEvents::_VtblGap2_2()

BTW, I can give you binaries for P2ClientGateMTA assembly. Can it be of any help?

--
Best regards, 
Alik Kurdyukov

Jb Evain

unread,
Feb 13, 2012, 11:23:45 AM2/13/12
to gend...@googlegroups.com
I see,

This is a Microsoft C# compiler bug:

https://connect.microsoft.com/VisualStudio/feedback/details/595412/bug-in-nopia-emission-of-vtblgap-methods

They emit managed methods which claim to be managed but are actually
implemented by the runtime. Not that they care a lot.

I committed a fix to gendarme
(1fbb7ea90bbb96d2d28f9567ec7dee8dc735cfc7), you can either build
gendarme yourself or have the sonar guys cherry-pick this fix.

Jb

Alik Kurdyukov

unread,
Feb 14, 2012, 7:29:35 AM2/14/12
to gend...@googlegroups.com
Jb,

Thank you for hotfixing the problem. Do you have any dates for next Gendarme release?

--
Best regards, 
Alik Kurdyukov

Sebastien Pouliot

unread,
Feb 14, 2012, 7:59:38 AM2/14/12
to gend...@googlegroups.com
Hello Alik,

Gendarme official releases occurs at the same time as Mono releases.
The beta cycle for 2.11 should start soon - but we're a few months
away from a stable 2.12.

Sebastien

Ty

unread,
May 23, 2012, 12:14:52 PM5/23/12
to gend...@googlegroups.com
Jb,
 
I am running into similar problems like Alik posted earlier. I downloaded the new 2.11  version of gendarme (gendarme-2.11-snapshot-20110305-win32-setup), but the problem is still there. Wondering if your hot fix has been included into new 2.11 version release.
 
BTW, I am totally new to using sonar .NET plugin, can you point me to where to get your a fix to gendarme
(1fbb7ea90bbb96d2d28f9567ec7dee8dc735cfc7)?
 
Thanks a lot for your help.
 
Ty
I see,

https://connect.microsoft.com/VisualStudio/feedback/details/595412/bug-in-nopia-emission-of-vtblgap-methods

Jb

> gendarme+unsubscribe@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/gendarme?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Gendarme" group.
> To post to this group, send email to gend...@googlegroups.com.
> To unsubscribe from this group, send email to

> gendarme+unsubscribe@googlegroups.com.

Kulvinder Singh

unread,
May 31, 2012, 6:22:40 AM5/31/12
to gend...@googlegroups.com
I'm running in to this too, here is a link to the commit Jb made:  https://www.ohloh.net/p/gendarme/commits/163580935 (couldn't get Google to find it from the UID).

I'll keep an eye out for news too.
Reply all
Reply to author
Forward
0 new messages