realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Realm doesn't like accented characters in class names

Open Harmonium opened this issue 8 years ago • 4 comments

Goals

To use accented characters in classes

Expected Results

Do not crash

Actual Results

It crashes

Steps to Reproduce

Use accented characters in classes

Code Sample

class Électeur: Object { dynamic var cléÉlecteur: Int = 0 dynamic var section: Int = 0 dynamic var noLigne: Int = 0 dynamic var numeroElecteur: String = "" dynamic var nom: String = "" dynamic var prénom: String = "" dynamic var dateNaissance: Date = Date() dynamic var sexe: String = "" }

Version of Realm and Tooling

ProductName: Mac OS X ProductVersion: 10.12.3 BuildVersion: 16D32

/Applications/Xcode.app/Contents/Developer Xcode 8.2.1 Build version 8C1002

/usr/local/bin/pod 1.2.0 Realm (2.4.4) RealmSwift (2.4.4)

/bin/bash GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)

(not in use here)

/usr/bin/git git version 2.10.1 (Apple Git-78)

Harmonium avatar Mar 25 '17 16:03 Harmonium

Actual Results

It crashes

Can you please share a crash log or backtrace and exception message from the crash?

bdash avatar Mar 25 '17 16:03 bdash

It crashes here only when my class contains an accented characters like Électeur

inline size_t Table::add_empty_row(size_t num_rows) { size_t row_ndx = m_size; insert_empty_row(row_ndx, num_rows); // Throws return row_ndx; // Return index of first new row }

I have that also:

file:///Users/FoG/Library/Developer/CoreSimulator/Devices/F3FA9DD5-1C67-4564-A839-7F85D996CDA2/data/Containers/Data/Application/94B2F816-7B68-4D8E-8FE0-B0B249D6C966/Documents/default.realm table.cpp:2922: [realm-core-2.3.3] Assertion failed: col_ndx < get_column_count() [4541941835, 8] 0 Realm 0x000000010debcaf8 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 40 1 Realm 0x000000010debcdf5 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 517 2 Realm 0x000000010db2caa1 ZN5realm4util9terminateIJmmEEEvPKcS3_lDpT + 145 3 Realm 0x000000010e056606 _ZN5realm5Table7set_intEmmxb + 662 4 Realm 0x000000010dbeb709 _ZL11RLMSetValueP13RLMObjectBasemPU16objcproto6RLMInt8NSNumberb + 169 5 Realm 0x000000010dbf19c4 _ZZ13RLMDynamicSetP13RLMObjectBaseP11RLMPropertyP11objc_objectmENK3$_0clEv + 164 6 Realm 0x000000010dbe7f97 _ZL13RLMWrapSetterIZ13RLMDynamicSetP13RLMObjectBaseP11RLMPropertyP11objc_objectmE3$0EvS1_P8NSStringOT + 183 7 Realm 0x000000010dbe7d87 _Z13RLMDynamicSetP13RLMObjectBaseP11RLMPropertyP11objc_objectm + 183 8 Realm 0x000000010dc27682 RLMAddObjectToRealm + 2882 9 RealmSwift 0x000000010e51dfa0 TFC10RealmSwift5Realm3addfTCS_6Object6updateSb_T + 688 10 RealmDemo 0x000000010da3e130 TFFC9RealmDemo14ViewController11viewDidLoadFT_T_U_FT_T + 80 11 RealmSwift 0x000000010e51da07 TFC10RealmSwift5Realm5writefzFzT_T_T + 71 12 RealmDemo 0x000000010da3dfdb TFC9RealmDemo14ViewController11viewDidLoadfT_T + 2235 13 RealmDemo 0x000000010da3e242 TToFC9RealmDemo14ViewController11viewDidLoadfT_T + 34 14 UIKit 0x000000010f1e4a3d -[UIViewController loadViewIfRequired] + 1258 15 UIKit 0x000000010f1e4e70 -[UIViewController view] + 27 16 UIKit 0x000000010f0ae4b5 -[UIWindow addRootViewControllerViewIfPossible] + 71 17 UIKit 0x000000010f0aec06 -[UIWindow _setHidden:forced:] + 293 18 UIKit 0x000000010f0c2519 -[UIWindow makeKeyAndVisible] + 42 19 UIKit 0x000000010f03af8d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818 20 UIKit 0x000000010f0410ed -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731 21 UIKit 0x000000010f03e26d -[UIApplication workspaceDidEndTransaction:] + 188 22 FrontBoardServices 0x00000001177e86cb FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24 23 FrontBoardServices 0x00000001177e8544 -[FBSSerialQueue _performNext] + 189 24 FrontBoardServices 0x00000001177e88cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45 25 CoreFoundation 0x0000000111283761 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 26 CoreFoundation 0x000000011126898c __CFRunLoopDoSources0 + 556 27 CoreFoundation 0x0000000111267e76 __CFRunLoopRun + 918 28 CoreFoundation 0x0000000111267884 CFRunLoopRunSpecific + 420 29 UIKit 0x000000010f03caea -[UIApplication _run] + 434 30 UIKit 0x000000010f042c68 UIApplicationMain + 159 31 RealmDemo 0x000000010da4201f main + 111 32 libdyld.dylib 0x000000011195e68d start + 1 33 ??? 0x0000000000000001 0x0 + 1 IMPORTANT: if you see this error, please send this log to [email protected].(lldb)

Harmonium avatar Mar 25 '17 16:03 Harmonium

If you want I can send you a little project I made.

Harmonium avatar Mar 25 '17 16:03 Harmonium

Thanks, I was able to reproduce it by renaming one of the classes in Realm Swift's unit tests to include an umlaut.

I think the underlying issue here is that Schema::find uses StringData::operator< as the comparator for std::lower_bound, while Schema::Schema uses std::string::operator< when sorting, and StringData and std::string disagree on the ordering. This prevents Schema from being able to look up some classes.

bdash avatar Mar 25 '17 16:03 bdash