NSObject(NSObject) doesNotRecognizeSelector crashing app, report missing some symbolication - exception

I have an application that has been release in the App Store. About maybe 1% - 2% of my users are reporting that the App is crashing. This isn't exactly unexpected behavior, so I have asked for the crash logs. Here is the last exception backtrace (the part that actually shows the issue):
Last Exception Backtrace:
0 CoreFoundation 0x2ecc5e7e __exceptionPreprocess + 126
1 libobjc.A.dylib 0x390226c2 objc_exception_throw + 34
2 CoreFoundation 0x2ecc97b2 -[NSObject(NSObject) doesNotRecognizeSelector:] + 198
3 CoreFoundation 0x2ecc80aa ___forwarding___ + 702
4 CoreFoundation 0x2ec16dc4 __forwarding_prep_0___ + 20
5 MyAppName 0x000874d0 0x6c000 + 111824
6 UIKit 0x3157c310 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 404
7 UIKit 0x315246c8 -[UITableView _updateVisibleCellsNow:] + 1796
8 UIKit 0x31523eec -[UITableView layoutSubviews] + 180
As you can see the issue is on line 2, NSObject(NSObject) doesNotRecognizeSelector.
This tells me what is happening, but obviously not where or what. So go to line 5, and here is my App calling an unknown method. For some reason this is not symbolicated. It seems like this method is probably what is causing the issue.
Every single report (I have about 10 of them right now) is identical to this here. Any idea how I can see the proper symbolication? Thanks!

I have experienced these kinds of crash before.
It was due to data type issue in all my cases.
For example trying to call a method specific for one data type on another data type.
i.e
trying to call integerValue method on a dictionary or trying to call length method on a string but in essence it is a dictionary so it crashes with [NSObject doesNotRecognizeSelector:]:
It's better check data type and call the method on the object to avoid crashes like this.
When we're calling APIs , it can easily happen as sometimes APIs can return wrong datatypes or unexpected response.

Related

Need help understanding this decimal code

I am trying to understand what this decimal code would be as a binary:
I understand how to normally get the answer, because I would take 425 and then figure out that 256 + 128 + 32 + 8 + 1 = 425, which would be 110101001 in binary.
However, I am completely thrown off by the d in the decimal. How can I understand what it is and how to solve this (if the answer is different than 110101001)?

MySQL segfault with mismatched charsets

I recently rsync a bunch of MYI, MYD, and FRM files from one MySQL 5.0.95 server to another, both using MyISAM. Due to a forgotten hot-fix, it turns out that the original database was configured to default tables to utf8, and the new database was set to latin1. When we turned on the new database, it worked, but shortly thereafter, several queries caused it to segfault multiple times in a row. I suspect it has to do with the charset difference, but I don't understand the stack trace well enough to get to the bottom of the issue. Below is the decoded stack trace, and then the mysql.log.
Stack trace:
0x819b416 handle_segfault + 806
0xb76246a1 _end + -1358137335
0x8193936 Protocol::store_string_aux(char const*, unsigned int, charset_info_st*, charset_info_st*) + 166
0x8193a2b Protocol_simple::store(Field*) + 139
0x818f671 select_send::send_data(List<Item>&) + 161
0x81e5735 init_read_record_seq(st_join_table*) + 373
0x81e8629 join_read_always_key_or_null(st_join_table*) + 2153
0x81ecbc7 sub_select(JOIN*, st_join_table*, bool) + 135
0x81ef127 JOIN::rollup_write_data(unsigned int, st_table*) + 2487
0x81ff6ed JOIN::exec() + 1341
0x81fc72b _Z12mysql_selectP3THDPPP4ItemP10TABLE_LISTjR4ListIS1_ES2_jP8st_orderSB_S2_SB_yP13select_resultP18st_select_lex_unitP13st_select + 219
0x82015a6 handle_select(THD*, st_lex*, select_result*, unsigned long) + 326
0x81b1240 mysql_execute_command(THD*) + 7728
0x81b6140 mysql_parse(THD*, char const*, unsigned int, char const**) + 640
0x81b88d0 dispatch_command(enum_server_command, THD*, char*, unsigned int) + 3408
0x81b9f30 handle_one_connection + 2624
0xb785f10f _end + -1355799945
0xb767c74e _end + -1357776714
mysql.log:
160623 17:39:52 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.
key_buffer_size=209715200
read_buffer_size=262144
max_used_connections=4
max_connections=1500
threads_connected=4
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 3660800 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
thd=0x86799f8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0xa648d168, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x819b416
0xb75d56a1
0x8193936
0x8193a2b
0x818f671
0x81e5735
0x81e8629
0x81ecbc7
0x81ef127
0x81ff6ed
0x81fc72b
0x82015a6
0x81b1240
0x81b6140
0x81b88d0
0x81b9f30
0xb781010f
0xb762d74e
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x875aaf0 = SELECT * FROM Data_197_21268_1 ORDER BY ID LIMIT 1
thd->thread_id=8
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
Thank you in advance for any help you can offer. Also, I know I have to upgrade MySQL, this is in the works.

SYS(3050) is throwing Function argument value,type or count is invalid error

Earlier i had an issue of not enough memory for file mapping.
Then as advised by few experts I used following code in my main program and that solves the issue and worked fine.
SYS(3050,1,MIN(536870912,VAL(SYS(3050,1,0))))
SYS(3050,2,MIN(536870912,VAL(SYS(3050,1,0))))
But recently one of client's machine is upgraded to Windows 7 64 bit from XP 32 bit. After that when the system is starting
it is throwing an error of Function argument value, type or count is invalid at SYS(3050) line.
If I omit this and continues then not enough memory for file mapping is occurs.
Can anybody advise what i should do to overcome this issue? Is it because of 64 bit OS of Windows 7 (because other two machines with Windows 7 and 32 bit are working properly)
As Alan B said, the problems with 'not enough memory for file mapping' tend to go away when switching to VFP9 SP2 (it's the one fly in the ointment when using VFP8 SP1 which is otherwise the most solid of the lot).
If switching to VFP9 is not an option then I would suggest factoring out the nested SYS(3050,1,0) calls and sanitising the result before feeding it into VAL(). At the very least it would pinpoint more accurately the place where the problem occurs, to guide further investigation with the aid of a debugger or a tool like IDA.
The original code already caps the parameter at 536870912, which is well below the threshold of 2^31 at which SYS(3050) throws a range error. However, the parameter must be strictly positive, which requires adding a MAX() term:
local nLimit
nLimit = max(1, min(536870912, val(sys(3050, 1))))
sys(3050, 1, m.nLimit)
sys(3050, 2, m.nLimit)
Background: calling the function with a limit parameter of 0 is the same as calling it without a limit (i.e. it gets the limit instead of setting it). Calling the function with a negative parameter causes it to blow with a range error.

Big unicode problems - AS3

I made a program where people can type in 4 letters and it will give you the corresponding unicode character that it inserts in a textflow element. Now i had a lot of problems with this, but in the end i succeeded with some help. Now the problem came when i typed "dddd" or "ddd1" as a test.
I got the error
- "An unpaired Unicode surrogate was encountered in the input."
Now i spend like 2 days testing for that, and there was absolutly no event triggering that made it possible for me to test for the error before it occurred.
The code:
str = "dddd"
num = parseInt(str,16)
res = String.fromCharCode(num)
Acutally when the error occurres res is equal to "?" in the console ... but if you test for it with if(res == "?") it returns false.
MY QUESTION:
Now i searched and searched and found abolutly no description on this error in adobes as3 reference, but after 2 days i found this page for javascript: http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter04a
It says that
- The code units in the range 0xD800–0xDFFF, serve a special purpose, however. These code units, known as surrogate code units
So now i test with:
if( num > 0 && num < uint(0xD800)) || ( num > uint(0xDFFF) && num < uint(0xFFFF) ){
get unicode character.
}
my question is simply if i understood this correctly, that this will actually prevent the error from occurring? - I'm no unicode specialist and don't know really how to test for it, since there are ten's of thousands characters so i might have missed one and that would mean that the users by accident could get the error and risk crashing the application.
You are correct. A code point ("high surrogate") between 0xD800-0xDBFF must be paired with a code point ("low surrogate") between 0xDC00-0xDFFF. Those are reserved for use in UTF-16[1] - when needing to address the higher planes that don't fit in 16 bits - and hence those code points can't appear on their own. For example:
0xD802 DC01 corresponds to (I'll leave out the 0x hex markers):
10000 + (high - D800) * 0400 + (low - DC00)
10000 + (D802 - D800) * 0400 + (DC01 - DC00)
= 10000 + 0002 * 0400 + 0001
= 10801 expressed as UTF-16
... just adding that bit of into in case you later need to support it.
I haven't tested the AS3 functionality for the following, but you may want to also test the input below - you won't get the surrogate error for these, but might get another error message:
0xFFFE and 0xFFFF (when using higher planes, also any code point "ending" with those bits, e.g. 0x1FFFE and 0x1FFFF; 0x2FFFE and 0x2FFFF etc.) Those are "non-characters".
The same goes for 0xFDD0-0xFEDF - also "non-characters".
AS3 actually uses UTF-16 to store its strings, but even if it didn't, the surrogate code points would still have no meaning outside pairs - the code points are reserved and can't be used in other Unicode encodings either (e.g. UTF-8 or UTF-32)

Why is there a limit of max 20 parameters to a clojure function

there seems to be a limit to the number of parameters a clojure function can take.
When defining a function with more than 20 parameters I receive the following:
#<CompilerException java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Can't specify more than 20 params (NO_SOURCE_FILE:0) (NO_SOURCE_FILE:0)>
Obviously this can be avoided, but I was hitting this limit porting the execution model of an existing DSL to clojure, and I have constructs in my DSL like the following, which by macro expansion can be mapped to functions quite easily except for this limit:
(defAlias nn1 ((element ?e1) (element ?e2)) number
"#doc features of the elements are calculated for entry into
the first neural network, the result is the score computed by the latter"
(nn1-recall (nn1-feature00 ?e1 ?e2) (nn1-feature01 ?e1 ?e2) ... (nn1-feature89 ?e1 ?e2)))
which is a DSL statement to call a neural network with 90 input nodes.
Can work around it of course, but was wondering where the limit comes from.
Thanks.
First of all, the limit only applies to required positional arguments; you can always use the variable arity case (& more-args in the function's signature) to handle as many arguments as you want to:
(defn foo [& args]
(count args))
(foo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)
;; returns 25
In fact, at first glance, & args is likely to be exactly the right solution to your problem. (E.g. you'll be able to map a function over your input nodes collected into a sequence, loop / recur over said sequence etc. -- tends to make more sense with a large number of similar items than assigning separate names to each one of them.
(Note that I don't pretend to know the nature of the specific DSL you're transcribing into Clojure or the kind of problems you're dealing with, just suggesting points which might be of interest to you. If you've got a really funky situation where this doesn't seem to apply, maybe you can provide more details and we'll see if someone here can offer some useful hints for dealing with it in Clojure.)
For the sake of completeness, you can add the & args bit to a function which takes its first 19 arguments as required positional args:
(defn bar [a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 & as]
(+ 19 (count as)))
(bar 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)
;; returns 25
Note that if you specify 20 positional args and the & arg on top of that, apparently weirdness will ensue.
As for the rationale, I believe this has to do with the fact that the JVM can dispatch to a method by arity very efficiently, so the clojure.lang.Fn class has the invoke method overloaded for arities up to 20. I'm not entirely sure if it could go higher than that, but I suppose this isn't something people require that often... I mean, I certainly find any API specifying over 20 positional arguments to a function a bit suspect.
The answer of Michal Marczyk tells you very well how to get around the limit. If you're interrested in the reason of this limitation, you might want to take a glance at this bit of clojure source : IFn
invoke being a java overloaded method implemented by the Ifn interface, Rich overloaded it to support up to 20 arguments. When you call a function in clojure, the underlying implementation calls invoke on the function object, a method that only supports up to 20 args.
You could overload it to support more, but i doubt of the utility of such a thing. If you have a bunch of input sources, they can probably be treated as an array anyway.