Bug 240720

Summary: gcj generates bad native code for scala
Product: [Fedora] Fedora Reporter: Geoff Reedy <geoff+fedora>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: rawhideCC: aph, tromey
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-05-30 15:57:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Stack trace and other gdb post-mortem
none
a small test case that triggers this bug none

Description Geoff Reedy 2007-05-21 05:44:06 UTC
Description of problem:

Using aot-compile to build native code versions of scala's compiler and standard
library results in code that sends a class name instead of a class structure to
_Jv_CheckCast which results in a segmentation fault (reported as a
NullPointerException)

Version-Release number of selected component (if applicable):

libgcj-4.1.2-12

How reproducible:

Always

Steps to Reproduce:
1. Download the scala runtime from
http://www.scala-lang.org/downloads/distrib/files/scala-2.5.0-RC2.tar.bz2

2. Extract runtime to a new directory

3. Run the following from that directory:

mkdir share/scala/lib-native
aot-compile -c -g share/scala/lib share/scala/lib-native
gcj-dbtool -m scala.gcjdb `gcj-dbtool -p` share/scala/lib-native/*.db
GCJ_PROPERTIES="gnu.gcj.precompiled.db.path=$PWD/scala.gcjdb" bin/scala 
  
Actual results:

Segmentation fault

Expected results:

The scala interpreter banner and prompt

Additional info:

In particular the issue seems to be with scala's anonymous functions since the
scala compiler fails in the same way within another anonymous function.

I have attached a stack trace and some additional post-mortem from gdb

Comment 1 Geoff Reedy 2007-05-21 05:44:06 UTC
Created attachment 155072 [details]
Stack trace and other gdb post-mortem

Comment 2 Geoff Reedy 2007-05-21 05:48:03 UTC
Also, I have been unable to generate a smaller test case or one that involves
vanilla java code.  I'll keep trying and add it here if I am successful.

Comment 3 Geoff Reedy 2007-05-25 04:10:19 UTC
I've managed to get together a more minimal test case that doesn't involve scala
at all.  It wasn't generated from java source but through jasmin and some binary
edits to the class files to mimic the files generated by the scala compiler
(setting the access flags of test$$anonfun$0 to public synthetic final). I'll be
attaching a zip file with these classes momentarily.

Comment 4 Geoff Reedy 2007-05-25 04:25:57 UTC
Created attachment 155426 [details]
a small test case that triggers this bug

Comment 5 Andrew Haley 2007-05-30 15:56:13 UTC
Patch at http://gcc.gnu.org/ml/java-patches/2007-q2/msg00252.html

Comment 6 Geoff Reedy 2007-05-31 02:53:02 UTC
Thanks for the quick resolution of this issue!  Seeing as fc7 is scheduled for release tomorrow I 
understand the fix won't make it in.  Will the patch be in an update for fc7 shortly?

Comment 7 Jakub Jelinek 2007-05-31 07:26:39 UTC
It will make it into Fedora 8 development soon (and the packages will be usable
even in F7).  It will make it into F7 updates after some time, depends what
shortly means for you.  It certainly won't be shorter than a month or two,
releasing a huge gcc update just to fix one or two bugs, unless they are show
stoppers for many people, is just way too bandwidth unfriendly for all people
that would need to download it.