wei-spring / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

EXC_BAD_ACCESS in new VM inside java_lang_Comparable_compareTo #1305

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Build the ChartsDemo app with the new VM
2. Open on device (or in iOS simulator)
3. Click on the first chart in the menu.

What is the expected output? What do you see instead?

Should just show the chart.  Instead, app crashes with EXC_BAD_ACCESS.  Works 
fine on Simulator, Android, and Old VM (iOS).

Please use labels and text to provide additional information.

Crashed thread:

#0  0x010243e1 in 
virtual_java_lang_Comparable_compareTo___java_lang_Object_R_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_lang_Comparable.m:58
#1  0x0128a4ec in 
java_util_TreeMap_cmp___java_lang_Comparable_java_lang_Object_java_lang_Object_R
_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_util_TreeMap.m:2850
#2  0x012a2e02 in java_util_TreeMap_get___java_lang_Object_R_java_lang_Object at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_util_TreeMap.m:2522
#3  0x001579a7 in 
virtual_com_codename1_charts_models_XYSeries_IndexXYMap_get___java_lang_Object_R
_java_lang_Object at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_charts_models_XYSeries_IndexXYMap.m:805
#4  0x0014cdd8 in com_codename1_charts_models_XYSeries_add___double_double at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_charts_models_XYSeries.m:383
#5  0x00153e63 in 
virtual_com_codename1_charts_models_XYSeries_add___double_double at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_charts_models_XYSeries.m:1135
#6  0x002d6c01 in 
com_codename1_demos_charts_AbstractDemoChart_addXYSeries___com_codename1_charts_
models_XYMultipleSeriesDataset_java_lang_String_1ARRAY_java_util_List_java_util_
List_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AbstractDemoChart.m:194
#7  0x002d582f in 
virtual_com_codename1_demos_charts_AbstractDemoChart_addXYSeries___com_codename1
_charts_models_XYMultipleSeriesDataset_java_lang_String_1ARRAY_java_util_List_ja
va_util_List_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AbstractDemoChart.m:1245
#8  0x002d55c2 in 
com_codename1_demos_charts_AbstractDemoChart_buildDataset___java_lang_String_1AR
RAY_java_util_List_java_util_List_R_com_codename1_charts_models_XYMultipleSeries
Dataset at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AbstractDemoChart.m:60
#9  0x002f1033 in 
virtual_com_codename1_demos_charts_AverageCubicTemperatureChart_buildDataset___j
ava_lang_String_1ARRAY_java_util_List_java_util_List_R_com_codename1_charts_mode
ls_XYMultipleSeriesDataset at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AverageCubicTemperatureChart.m:847
#10 0x002f0571 in 
com_codename1_demos_charts_AverageCubicTemperatureChart_execute___R_com_codename
1_ui_Form at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AverageCubicTemperatureChart.m:721
#11 0x002e2269 in 
virtual_com_codename1_demos_charts_AbstractDemoChart_execute___R_com_codename1_u
i_Form at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_AbstractDemoChart.m:1237
#12 0x0031f04d in 
com_codename1_demos_charts_ChartDemosForm_1_actionPerformed___com_codename1_ui_e
vents_ActionEvent at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_demos_charts_ChartDemosForm_1.m:150
#13 0x0093b154 in 
virtual_com_codename1_ui_events_ActionListener_actionPerformed___com_codename1_u
i_events_ActionEvent at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_events_ActionListener.m:68
#14 0x00ec049b in 
com_codename1_ui_util_EventDispatcher_fireActionEvent___com_codename1_ui_events_
ActionEvent at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_util_EventDispatcher.m:1265
#15 0x00b30a51 in 
com_codename1_ui_List_fireActionEvent___com_codename1_ui_events_ActionEvent at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_List.m:6712
#16 0x00b3aa60 in 
com_codename1_ui_List_pointerReleasedImpl___int_int_boolean_boolean at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_List.m:8902
#17 0x00b4061e in com_codename1_ui_List_pointerReleased___int_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_List.m:8930
#18 0x007afe18 in virtual_com_codename1_ui_Component_pointerReleased___int_int 
at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Component.m:15101
#19 0x0099aeb1 in com_codename1_ui_Form_pointerReleased___int_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Form.m:8487
#20 0x007afe18 in virtual_com_codename1_ui_Component_pointerReleased___int_int 
at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Component.m:15101
#21 0x007afd0b in 
com_codename1_ui_Component_pointerReleased___int_1ARRAY_int_1ARRAY at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Component.m:8579
#22 0x009b3288 in 
virtual_com_codename1_ui_Form_pointerReleased___int_1ARRAY_int_1ARRAY at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Form.m:12382
#23 0x008e47ba in com_codename1_ui_Display_handleEvent___int_R_int at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Display.m:6622
#24 0x008ce9ff in com_codename1_ui_Display_edtLoopImpl__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Display.m:2832
#25 0x008dad39 in com_codename1_ui_Display_mainEDTLoop__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_Display.m:2513
#26 0x00d5f09f in com_codename1_ui_RunnableWrapper_run__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_ui_RunnableWrapper.m:515
#27 0x010493d6 in virtual_java_lang_Runnable_run__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_lang_Runnable.m:68
#28 0x0044e5fc in com_codename1_impl_CodenameOneThread_run__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/com_codename1_impl_CodenameOneThread.m:576
#29 0x010493d6 in virtual_java_lang_Runnable_run__ at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_lang_Runnable.m:68
#30 0x010881da in java_lang_Thread_runImpl___long at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/java_lang_Thread.m:271
#31 0x0139334b in threadRunner at 
/var/folders/k7/b5qdhxt88v58wp008k8yxy180000gn/T/build4212967506019656537xxx/dis
t/ChartsDemo-src/nativeMethods.m:782

Line from java_lang_Comparable.m:
return 
(*(functionPtr_java_lang_Comparable_compareTo___java_lang_Object_R_int)__cn1This
Object->__codenameOneParentClsReference->vtable[classToInterfaceMap_java_lang_Co
mparable[__cn1ThisObject->__codenameOneParentClsReference->classId][0]])(threadS
tateData, __cn1ThisObject, __cn1Arg1);

Error:

Thread 3: EXC_BAD_ACCESS (code=1 address=0x0)

Also attached screenshot in Xcode with error happening.

Original issue reported on code.google.com by st...@weblite.ca on 24 Jan 2015 at 6:04

Attachments:

GoogleCodeExporter commented 9 years ago
I have identified the problem.  TreeMap includes a no-arg constructor that 
leaves the comparator null.  This allows you to use keys that implement 
Comparable already.  In most of Java, this includes things like Number types 
and Strings.  The full list for JDK 6 is:

All Known Implementing Classes:
Authenticator.RequestorType, BigDecimal, BigInteger, Boolean, Byte, ByteBuffer, 
Calendar, Character, CharBuffer, Charset, ClientInfoStatus, CollationKey, 
Component.BaselineResizeBehavior, CompositeName, CompoundName, Date, Date, 
Desktop.Action, Diagnostic.Kind, Dialog.ModalExclusionType, 
Dialog.ModalityType, Double, DoubleBuffer, DropMode, ElementKind, ElementType, 
Enum, File, Float, FloatBuffer, Formatter.BigDecimalLayoutForm, 
FormSubmitEvent.MethodType, GregorianCalendar, GroupLayout.Alignment, 
IntBuffer, Integer, JavaFileObject.Kind, JTable.PrintMode, KeyRep.Type, 
LayoutStyle.ComponentPlacement, LdapName, Long, LongBuffer, MappedByteBuffer, 
MemoryType, MessageContext.Scope, Modifier, 
MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod, 
NestingKind, Normalizer.Form, ObjectName, ObjectStreamField, Proxy.Type, Rdn, 
Resource.AuthenticationType, RetentionPolicy, RoundingMode, 
RowFilter.ComparisonType, RowIdLifetime, RowSorterEvent.Type, Service.Mode, 
Short, ShortBuffer, SOAPBinding.ParameterStyle, SOAPBinding.Style, 
SOAPBinding.Use, SortOrder, SourceVersion, SSLEngineResult.HandshakeStatus, 
SSLEngineResult.Status, StandardLocation, String, SwingWorker.StateValue, 
Thread.State, Time, Timestamp, TimeUnit, TrayIcon.MessageType, TypeKind, URI, 
UUID, WebParam.Mode, XmlAccessOrder, XmlAccessType, XmlNsForm

Unfortunately in our API the only classes that implement Comparable are:

All Known Implementing Classes:
ElementType, Enum, RetentionPolicy

There are 3 possible solutions:

1. Throw an exception when a no-arg constructor is called for TreeMap (and 
likely any form of sorted set, map, or list because they all work the same way.
2. Change the number classes to implement Comparable.   This may be difficult 
to maintain consistency on J2ME.
3. Add special handling to the no-arg constructors to create appropriate 
comparables for Number types.

My preferred option is #3.  My proposed approach is to implement package 
private Comparable implementations for all of the boxed number types, then add 
special handling to the no-arg constructors of 
TreeSet and TreeMap to instantiate the appropriate comparable when the key type 
is a boxed numeric type.

Do you have any objections to this approach?  
If I went this route, I assume I would need to make the change in both the 
CLDC11 project and the JavaAPI project.  Is that correct?

Original comment by steve.ha...@codenameone.com on 27 Jan 2015 at 5:37

GoogleCodeExporter commented 9 years ago
I went ahead and fixed this with option 3.  
https://code.google.com/p/codenameone/source/detail?r=2043

I also patched the CLDC11 project with the same changes to make compatible with 
J2ME/BB.

Original comment by st...@weblite.ca on 27 Jan 2015 at 6:07

GoogleCodeExporter commented 9 years ago
Changing the CLDC11 project isn't the right thing to do here. Since there is no 
API change your changes are meaningless as the CLDC11 project is mostly just 
stubs.

Original comment by shai.almog on 27 Jan 2015 at 6:08

GoogleCodeExporter commented 9 years ago
How does J2ME make use of the java collections classes?  Do they have their own 
copy or do they get them from the CLDC11 jar?

Original comment by st...@weblite.ca on 27 Jan 2015 at 6:16

GoogleCodeExporter commented 9 years ago
There is code that is executed from the builder. Its in the JavaCompatibility 
project. It has a rather different structure since it can't occupy java.*.

Original comment by shai.almog on 27 Jan 2015 at 7:46

GoogleCodeExporter commented 9 years ago
OK  I have reversed the change to CLDC11.  Will look into the JavaCompatibility 
project.

Original comment by st...@weblite.ca on 27 Jan 2015 at 7:57