Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336977

Summary: Oprofile initialization fails on IBM Power architecture
Product: z_Archived Reporter: Severin Gehwolf <sgehwolf>
Component: LinuxToolsAssignee: OProfile Inbox <linux.oprofile-inbox>
Status: CLOSED NOT_ECLIPSE QA Contact:
Severity: normal    
Priority: P3 CC: danielhb, kksebasti, sgehwolf
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Linux Tools Oprofile PSF
none
output of "cd /dev/oprofile && find"
none
output of " su -c 'ophelp -X' "
none
Example project illustrating XML parsing problem. none

Description Severin Gehwolf CLA 2011-02-11 12:15:16 EST
Using upstream Eclipse with Linux Tools 0.7.

Here is the original bug report:

Just made the test using the factorial project. Got the following error
on a popup window called "Problem occurred":

"Launching factorial" has encountered a problem.

An internal error occurred during: "Launching factorial".


When hitting the "Details" button:

An internal error occurred during: "Launching factorial".
java.lang.ExceptionInInitializerError

Test was done using Eclipse SDK 3.6.2 with CDT 7.0.2. Java version
1.5.0. OS used was RHEL 6.0. processor was a Power6 3,5Ghz on a LPar
with 2GB of RAM.
Comment 1 Severin Gehwolf CLA 2011-02-11 12:16:45 EST
Here is the conversation which followed:

I assume you did: Right click on binary in CDT view => Profile as =>
Profile with Oprofile, right?

Can you run the binary without errors? Right click => Run as => Local
C/C++ Application

Just making sure this isn't a CDT problem :)
Comment 2 Severin Gehwolf CLA 2011-02-11 12:17:35 EST
> I assume you did: Right click on binary in CDT view => Profile as =>
> Profile with Oprofile, right?

Precisely.

> 
> Can you run the binary without errors? Right click => Run as => Local
> C/C++ Application
> 
> Just making sure this isn't a CDT problem :)

Hehehe sorry, forgot to mention that. Project runs fine as local
application, but fails to profile with Oprofile.
Comment 3 Severin Gehwolf CLA 2011-02-11 12:18:09 EST
I forgot to send the stack trace from workspace/.metadata/.log . I think
it might be helpful


java.lang.ExceptionInInitializerError
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:218)
        at
org.eclipse.linuxtools.oprofile.core.linux.LinuxOpcontrolProvider.setupDaemon(LinuxOpcontrolProvider.java:179)
        at
org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.oprofileSetupDaemon(AbstractOprofileLaunchConfigurationDelegate.java:130)
        at
org.eclipse.linuxtools.oprofile.launch.launching.OprofileLaunchConfigurationDelegate.preExec(OprofileLaunchConfigurationDelegate.java:42)
        at
org.eclipse.linuxtools.oprofile.launch.launching.AbstractOprofileLaunchConfigurationDelegate.launch(AbstractOprofileLaunchConfigurationDelegate.java:66)
        at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
        at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
        at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:924)
        at org.eclipse.debug.internal.ui.DebugUIPlugin
$8.run(DebugUIPlugin.java:1128)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
        at
org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.createHeaders(InfoAdapter.java:131)
        at
org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter.process(InfoAdapter.java:124)
        at
org.eclipse.linuxtools.oprofile.core.linux.OpxmlRunner.run(OpxmlRunner.java:106)
        at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider
$OpInfoRunner.run(LinuxOpxmlProvider.java:55)
        at org.eclipse.linuxtools.oprofile.core.linux.LinuxOpxmlProvider
$OpInfoRunner.run0(LinuxOpxmlProvider.java:46)
        at
org.eclipse.linuxtools.oprofile.core.daemon.OpInfo.getInfo(OpInfo.java:85)
        at
org.eclipse.linuxtools.oprofile.core.Oprofile._initializeOprofileCore(Oprofile.java:94)
        at
org.eclipse.linuxtools.oprofile.core.Oprofile.initializeOprofileModule(Oprofile.java:64)
        at
org.eclipse.linuxtools.oprofile.core.Oprofile.<clinit>(Oprofile.java:43)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
        ... 9 more
Comment 4 Severin Gehwolf CLA 2011-02-11 12:18:57 EST
Ok
Comment 5 Severin Gehwolf CLA 2011-02-11 12:34:17 EST
Daniel, I've created this bug to debug this further. I hope that's ok. Unfortunately I have no access to a PPC machine, so I am dependent on your help to debug this.

Here's my suggestion:
1.) Import oprofile sources (using the attached PSF file; File => Import => Team => PSF; note, you need subclipse or something equivalent)
2.) cd to org.eclipse.linuxtools.oprofile.core/natives/linux/scripts (in the file system)
3.) su -c './install.sh' (this installs the oprofile wrapper)
4.) Place a breakpoint on line 131 of org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter in createHeaders()
5.) Right-click on org.eclipse.linuxtools.oprofile.core => Debug as => Eclipse Application (this fires up a second Eclipse instance)
6.) Import factorial project again.
7.) Right-click on binary => Profile As => Profile with Oprofile

This should stop in the host Eclipse instance where you are getting a NullPointerException. I'd like to know what the variables in this passage are for you:

// number of counters (snippet from InfoAdapter).
String numCounters = String.valueOf(getNrCounters());
Element numCountersTag = newDoc.createElement(NUM_COUNTERS);

Also, could you past output of the following commands:

$ cd /dev/oprofile && find
$ su -c 'ophelp -X'

Thanks!
Comment 6 Severin Gehwolf CLA 2011-02-11 12:38:42 EST
Created attachment 188798 [details]
Linux Tools Oprofile PSF
Comment 7 Daniel Henrique Barboza CLA 2011-02-14 13:33:21 EST
Hello,

I've done a debug session, just like Severin described.

What I've got so far:

- the variables you asked:

numCounters = "6"
numCountersTag = none, Null Pointer exception occurs on this line.

The outputs of the commands you asked are attached, since I think they are too big to post here.

- I did a quick investigation of my own on this debug. On the breakpoint of line 131, the InfoAdapter object has the following attributes:

newDoc = null
newRoot = null
oldRoot = null

On line 132:

Element numCountersTag = newDoc.createElement(NUM_COUNTERS);

gives a null pointer because newDoc is null itself.

Going a bit deeper, what I think might be the start of the problem is at line 101, same class, createDom(InputStream is) method:

Document oldDoc = builder.parse(is); 

This line gives an exception on the terminal:

[Fatal Error] :138:127: Invalid byte 1 of 1-byte UTF-8 sequence.

And this exception skips all the remaining lines of createDOM() where newDoc, newRoot and oldRoot are initialized.
Comment 8 Daniel Henrique Barboza CLA 2011-02-14 13:38:20 EST
Created attachment 188929 [details]
output of "cd /dev/oprofile && find"
Comment 9 Daniel Henrique Barboza CLA 2011-02-14 13:39:20 EST
Created attachment 188930 [details]
output of  " su -c 'ophelp -X' "
Comment 10 Severin Gehwolf CLA 2011-02-14 15:09:11 EST
(In reply to comment #7)
> Going a bit deeper, what I think might be the start of the problem is at line
> 101, same class, createDom(InputStream is) method:
> 
> Document oldDoc = builder.parse(is); 
> 
> This line gives an exception on the terminal:
> 
> [Fatal Error] :138:127: Invalid byte 1 of 1-byte UTF-8 sequence.
> 
> And this exception skips all the remaining lines of createDOM() where newDoc,
> newRoot and oldRoot are initialized.

Thanks! It looks like XML parsing is broken on your system. We are using javax.xml.parsers.DocumentBuilder which is part of your JVM. I'll attach a small reproducer (a simple Java project). I expect this to cause the same exception, however, you should see the entire trace.

Could you post output of this reproducer?

1.) su -c 'opcontrol --init'
2.) Run TestDocumentParse in Eclipse

Which Eclipse and Java version are you using?

Anyhow, it doesn't seem to be a problem of the Linux Tools OProfile plug-in.
Comment 11 Severin Gehwolf CLA 2011-02-14 15:10:11 EST
Created attachment 188947 [details]
Example project illustrating XML parsing problem.
Comment 12 Daniel Henrique Barboza CLA 2011-02-15 11:28:56 EST
su -c 'opcontrol --init' returned no output.

And you were right Severin, the example project you sent gave the same exception. I tried to run it with another JVM and it worked ... so I guess we're talking about a JVM issue. I couldn't run the plugins with gcj (and later on I've learned that Eclipse is incompatible with gcj) but I'll assume that the JVM is indeed the problem.

I'll open a bug against this JVM (FYI it's an IBM J5 JVM) and hope they can fix it fast.

Thanks for the help!
Comment 13 Severin Gehwolf CLA 2011-02-15 11:47:08 EST
(In reply to comment #12)
> And you were right Severin, the example project you sent gave the same
> exception. I tried to run it with another JVM and it worked ... so I guess
> we're talking about a JVM issue. I couldn't run the plugins with gcj (and later
> on I've learned that Eclipse is incompatible with gcj) but I'll assume that the
> JVM is indeed the problem.
> 
> I'll open a bug against this JVM (FYI it's an IBM J5 JVM) and hope they can fix
> it fast.

OK, I'll close this bug for now. Feel free to get back to us, once the JVM issue has been sorted out and you still have problems with OProfile.

Thanks!