Objective-c decode UInt8 array of unsigned chars - objective-c

I'm trying to decode the following object, the variable is called data and is of type UInt8.
(UInt8 [520]) data = {
[0] = '\xff'
[1] = '\0'
[2] = '2'
[3] = '\0'
[4] = 'H'
[5] = '\0'
[6] = 'o'
[7] = '\0'
[8] = 's'
[9] = '\0'
[10] = 't'
[11] = '\0'
[12] = 'e'
[13] = '\0'
[14] = 'd'
[15] = '\0'
[16] = ' '
[17] = '\0'
[18] = 'o'
[19] = '\0'
[20] = 'n'
[21] = '\0'
[22] = ' '
[23] = '\0'
[24] = 'D'
[25] = '\0'
[26] = 'i'
[27] = '\0'
[28] = 'g'
[29] = '\0'
[30] = 'i'
[31] = '\0'
[32] = 't'
[33] = '\0'
[34] = 'a'
[35] = '\0'
[36] = 'l'
[37] = '\0'
[38] = ' '
[39] = '\0'
[40] = 'O'
[41] = '\0'
[42] = 'c'
[43] = '\0'
[44] = 'e'
[45] = '\0'
[46] = 'a'
[47] = '\0'
[48] = 'n'
[49] = '\0'
[50] = '.'
[51] = '\0'
[52] = ' '
[53] = '\0'
[54] = 'M'
[55] = '\0'
[56] = 'a'
[57] = '\0'
[58] = 'n'
[59] = '\0'
[60] = 'a'
[61] = '\0'
[62] = 'g'
[63] = '\0'
[64] = 'e'
[65] = '\0'
[66] = 'd'
[67] = '\0'
[68] = ' '
[69] = '\0'
[70] = 'w'
[71] = '\0'
[72] = 'i'
[73] = '\0'
[74] = 't'
[75] = '\0'
[76] = 'h'
[77] = '\0'
[78] = ' '
[79] = '\0'
[80] = 'P'
[81] = '\0'
[82] = 'u'
[83] = '\0'
[84] = 'p'
[85] = '\0'
[86] = 'p'
[87] = '\0'
[88] = 'e'
[89] = '\0'
[90] = 't'
[91] = '\0'
[92] = '!'
[93] = '\0'
[94] = '\xa7'
[95] = '\0'
[96] = '0'
[97] = '\0'
[98] = '\xa7'
[99] = '\0'
[100] = '2'
[101] = '\0'
[102] = '0'
[103] = '\0'
[104] = '\xa9'
[105] = '\x14'
[106] = '\x0e'
[107] = '\x02'
[108] = '\x01'
[109] = '\0'
[110] = '\0'
[111] = '\0'
[112] = '\xe3'
[113] = ' '
[114] = '\x0e'
[115] = '\x02'
[116] = '\x01'
[117] = '\0'
[118] = '\0'
[119] = '\0'
[120] = '\xe8'
[121] = '\xc3'
[122] = '\x85'
[123] = '\x01'
[124] = '\x01'
[125] = '\0'
[126] = '\0'
[127] = '\0'
[128] = '\0'
[129] = '\xc3'
[130] = '\x85'
[131] = '\x01'
[132] = '\x01'
[133] = '\0'
[134] = '\0'
[135] = '\0'
[136] = '\xc8'
[137] = 'P'
[138] = '\0'
[139] = '\0'
[140] = '\x01'
[141] = '\0'
[142] = '\0'
[143] = '\0'
[144] = '`'
[145] = '\xc3'
[146] = '\xbf'
[147] = '_'
[148] = '\xff'
[149] = '\x7f'
[150] = '\0'
[151] = '\0'
[152] = 'a'
[153] = '"'
[154] = '\x0e'
[155] = '\x02'
[156] = '\x01'
[157] = '\0'
[158] = '\0'
[159] = '\0'
[160] = '\xf8'
[161] = '\xc3'
[162] = '\x85'
[163] = '\x01'
[164] = '\x01'
[165] = '\0'
[166] = '\0'
[167] = '\0'
[168] = '\xfc'
[169] = '\xc3'
[170] = '\x85'
[171] = '\x01'
[172] = '\x01'
[173] = '\0'
[174] = '\0'
[175] = '\0'
[176] = '\xa0'
[177] = '>'
[178] = '\x85'
[179] = '\x01'
[180] = '\0'
[181] = '\0'
[182] = '\0'
[183] = '\0'
[184] = '\xe8'
[185] = '\xc3'
[186] = '\x85'
[187] = '\x01'
[188] = '\x01'
[189] = '\0'
[190] = '\0'
[191] = '\0'
[192] = '\xe8'
[193] = '\xc3'
[194] = '\x85'
[195] = '\x01'
[196] = '\x01'
[197] = '\0'
[198] = '\0'
[199] = '\0'
[200] = '\0'
[201] = '\xc4'
[202] = '\x85'
[203] = '\x01'
[204] = '\x01'
[205] = '\0'
[206] = '\0'
[207] = '\0'
[208] = '\0'
[209] = '\0'
[210] = '\0'
[211] = '\0'
[212] = '\0'
[213] = '\0'
[214] = '\0'
[215] = '\0'
[216] = '\x80'
[217] = '6'
[218] = 'O'
[219] = '\0'
[220] = '\0'
[221] = '\0'
[222] = '\0'
[223] = '\0'
[224] = '#'
[225] = '\0'
[226] = '\0'
[227] = '\0'
[228] = '\0'
[229] = '6'
[230] = 'O'
[231] = '\0'
[232] = '\0'
[233] = '\xc3'
[234] = '\xbf'
[235] = '_'
[236] = '\xff'
[237] = '\x7f'
[238] = '\0'
[239] = '\0'
[240] = '\xfc'
[241] = '\xc3'
[242] = '\x85'
[243] = '\x01'
[244] = '\x01'
[245] = '\0'
[246] = '\0'
[247] = '\0'
[248] = '\0'
[249] = '\xc4'
[250] = '\x85'
[251] = '\x01'
[252] = '\x01'
[253] = '\0'
[254] = '\0'
[255] = '\0'
...
}
I'm using this code to convert to an NSString.
NSString *info =[[NSString alloc] initWithBytes:data length:sizeof(data) encoding:NSUnicodeStringEncoding];
But I'm just getting foreign characters and wing-dings in the output.
What am I doing wrong?
I'm only interested in the first 3 sections separated by '\xa7'.

Looks like I should've used
NSString *info =[[NSString alloc] initWithBytes:data length:sizeof(data) encoding:NSUTF16LittleEndianStringEncoding];

Related

Not able to populate Athena script in AWS Lambda

import awswrangler as wr
def main():
database = 'temp'
output_table = 'Output Table'
output_s3_location = "'s3:Location'"
output_s3_storage_format = "'Parquet'" # "'TEXTFILE'" # "'Parquet'"
create_query = "CREATE TABLE " + database + "." + output_table + " \
WITH ( \
format = "+output_s3_storage_format+", \
external_location = "+ output_s3_location +", \
partitioned_by = ARRAY['run_date']) AS "
insert_query = "INSERT INTO "+database+"."+output_table+" "
select_query = """with temp AS
(SELECT CONCAT(period,' ',date1) AS new_Date,text,text1
FROM
(SELECT Substr(CAST(year AS varchar),3,4) AS date1,
test,
text1,
CASE
WHEN period='JAN' THEN 'Jan'
WHEN period='FEB' THEN 'Feb'
WHEN period='MAR' THEN 'Mar'
WHEN period='APR' THEN 'Apr'
WHEN period='MAY' THEN 'May'
WHEN period='JUN' THEN 'Jun'
WHEN period='JUL' THEN 'Jul'
WHEN period='AUG' THEN 'Aug'
WHEN period='SEP' THEN 'Sep'
WHEN period='OCT' THEN 'Oct'
WHEN period='NOV' THEN 'Nov'
WHEN period='DEC' THEN 'Dec'
END AS period
FROM Table_Name
WHERE text1='Car' ) ) ,
temp1 AS
(SELECT temp.* from A left join temp
ON A.value=temp.value)
Select * from temp2";"""
if create:
wr.athena.read_sql_query(sql="DROP TABLE " + database +"." + output_table + ";", database=database, ctas_approach=False)
wr.athena.read_sql_query(sql=create_query+select_query, database=database, ctas_approach=False)
else:
wr.athena.read_sql_query(sql=insert_query+select_query, database=database, ctas_approach=False)
def lambda_handler(event, context):
main()
return "True"
I am getting the below error while writing this script in Lambda function and testing it:
Response:
{
"errorMessage": "An error occurred (InvalidRequestException) when calling the StartQueryExecution operation: line 24:23: mismatched input '.' expecting {',', ')', 'FROM', 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'UNION', 'EXCEPT', 'INTERSECT'}",
"errorType": "InvalidRequestException",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 134, in lambda_handler\n main()\n",
" File \"/var/task/lambda_function.py\", line 128, in main\n wr.athena.read_sql_query(sql=create_query+select_query, database=database, ctas_approach=False)\n",
" File \"/opt/python/awswrangler/_config.py\", line 263, in wrapper\n return function(**args)\n",

Transform the output of an SqlQuery to numeric

I have got a Sql table and connected to it using R with odbcConnect(). The data I used is to find here: http://robjhyndman.com/tsdldata/data/nybirths.dat
I loaded a Query with
bstring <- sqlQuery(dbcon, "SELECT maptostring(__raw__) FROM births")
where dbcon is the connection to my database. The returned data is the following String:
bstring
$maptostring
[1] {\n "26.663;23.598;26.931;24.74;25.806" : "24.364;24.477;23.901;23.175;23.227"\n}\n
[2] {\n "26.663;23.598;26.931;24.74;25.806" : "21.672;21.87;21.439;21.089;23.709"\n}\n
[3] {\n "26.663;23.598;26.931;24.74;25.806" : "21.669;21.752;20.761;23.479;23.824"\n}\n
[4] {\n "26.663;23.598;26.931;24.74;25.806" : "23.105;23.11;21.759;22.073;21.937"\n}\n
[5] {\n "26.663;23.598;26.931;24.74;25.806" : "20.035;23.59;21.672;22.222;22.123"\n}\n
[6] {\n "26.663;23.598;26.931;24.74;25.806" : "23.95;23.504;22.238;23.142;21.059"\n}\n
[7] {\n "26.663;23.598;26.931;24.74;25.806" : "21.573;21.548;20;22.424;20.615"\n}\n
[8] {\n "26.663;23.598;26.931;24.74;25.806" : "21.761;22.874;24.104;23.748;23.262"\n}\n
[9] {\n "26.663;23.598;26.931;24.74;25.806" : "22.907;21.519;22.025;22.604;20.894"\n}\n
[10] {\n "26.663;23.598;26.931;24.74;25.806" : "24.677;23.673;25.32;23.583;24.671"\n}\n
[11] {\n "26.663;23.598;26.931;24.74;25.806" : "24.454;24.122;24.252;22.084;22.991"\n}\n
[12] {\n "26.663;23.598;26.931;24.74;25.806" : "23.287;23.049;25.076;24.037;24.43"\n}\n
[13] {\n "26.663;23.598;26.931;24.74;25.806" : "24.667;26.451;25.618;25.014;25.11"\n}\n
[14] {\n "26.663;23.598;26.931;24.74;25.806" : "22.964;23.981;23.798;22.27;24.775"\n}\n
[15] {\n "26.663;23.598;26.931;24.74;25.806" : "22.646;23.988;24.737;26.276;25.816"\n}\n
[16] {\n "26.663;23.598;26.931;24.74;25.806" : "25.21;25.199;23.162;24.707;24.364"\n}\n
[17]{\n "26.663;23.598;26.931;24.74;25.806" : "22.644;25.565;24.062;25.431;24.635"\n}\n
[18] {\n "26.663;23.598;26.931;24.74;25.806" : "27.009;26.606;26.268;26.462;25.246"\n}\n
[19] {\n "26.663;23.598;26.931;24.74;25.806" : "25.18;24.657;23.304;26.982;26.199"\n}\n
[20] {\n "26.663;23.598;26.931;24.74;25.806" : "27.21;26.122;26.706;26.878;26.152"\n}\n
[21] {\n "26.663;23.598;26.931;24.74;25.806" : "26.379;24.712;25.688;24.99;24.239"\n}\n
[22] {\n "26.663;23.598;26.931;24.74;25.806" : "26.721;23.475;24.767;26.219;28.361"\n}\n
[23] {\n "26.663;23.598;26.931;24.74;25.806" : "28.599;27.914;27.784;25.693;26.881"\n}\n
[24] {\n "26.663;23.598;26.931;24.74;25.806" : "26.217;24.218;27.914;26.975;28.527"\n}\n
[25] {\n "26.663;23.598;26.931;24.74;25.806" : "27.139;28.982;28.169;28.056;29.136"\n}\n
[26] {\n "26.663;23.598;26.931;24.74;25.806" : "26.291;26.987;26.589;24.848;27.543"\n}\n
[27] {\n "26.663;23.598;26.931;24.74;25.806" : "26.896;28.878;27.39;28.065;28.141"\n}\n
[28] {\n "26.663;23.598;26.931;24.74;25.806" : "29.048;28.484;26.634;27.735;27.132"\n}\n
[29] {\n "26.663;23.598;26.931;24.74;25.806" : "24.924;28.963;26.589;27.931;28.009"\n}\n
[30] {\n "26.663;23.598;26.931;24.74;25.806" : "29.229;28.759;28.405;27.945;25.912"\n}\n
[31] {\n "26.663;23.598;26.931;24.74;25.806" : "26.619;26.076;25.286;27.66;25.951"\n}\n
[32] {\n "26.663;23.598;26.931;24.74;25.806" : "26.398;25.565;28.865;30;29.261"\n}\n
[33] {\n "26.663;23.598;26.931;24.74;25.806" : "29.012;26.992;27.897"\n}\n
[34] {\n "26.663;23.598;26.931;24.74;25.806" : "24.364;24.477;23.901;23.175;23.227"\n}\n
[35] {\n "26.663;23.598;26.931;24.74;25.806" : "21.672;21.87;21.439;21.089;23.709"\n}\n
[36] {\n "26.663;23.598;26.931;24.74;25.806" : "21.669;21.752;20.761;23.479;23.824"\n}\n
[37] {\n "26.663;23.598;26.931;24.74;25.806" : "23.105;23.11;21.759;22.073;21.937"\n}\n
[38] {\n "26.663;23.598;26.931;24.74;25.806" : "20.035;23.59;21.672;22.222;22.123"\n}\n
[39] {\n "26.663;23.598;26.931;24.74;25.806" : "23.95;23.504;22.238;23.142;21.059"\n}\n
[40] {\n "26.663;23.598;26.931;24.74;25.806" : "21.573;21.548;20;22.424;20.615"\n}\n
[41] {\n "26.663;23.598;26.931;24.74;25.806" : "21.761;22.874;24.104;23.748;23.262"\n}\n
[42] {\n "26.663;23.598;26.931;24.74;25.806" : "22.907;21.519;22.025;22.604;20.894"\n}\n
[43] {\n "26.663;23.598;26.931;24.74;25.806" : "24.677;23.673;25.32;23.583;24.671"\n}\n
[44] {\n "26.663;23.598;26.931;24.74;25.806" : "24.454;24.122;24.252;22.084;22.991"\n}\n
[45] {\n "26.663;23.598;26.931;24.74;25.806" : "23.287;23.049;25.076;24.037;24.43"\n}\n
[46] {\n "26.663;23.598;26.931;24.74;25.806" : "24.667;26.451;25.618;25.014;25.11"\n}\n
[47] {\n "26.663;23.598;26.931;24.74;25.806" : "22.964;23.981;23.798;22.27;24.775"\n}\n
[48] {\n "26.663;23.598;26.931;24.74;25.806" : "22.646;23.988;24.737;26.276;25.816"\n}\n
[49] {\n "26.663;23.598;26.931;24.74;25.806" : "25.21;25.199;23.162;24.707;24.364"\n}\n
[50] {\n "26.663;23.598;26.931;24.74;25.806" : "22.644;25.565;24.062;25.431;24.635"\n}\n
[51] {\n "26.663;23.598;26.931;24.74;25.806" : "27.009;26.606;26.268;26.462;25.246"\n}\n
[52] {\n "26.663;23.598;26.931;24.74;25.806" : "25.18;24.657;23.304;26.982;26.199"\n}\n
[53] {\n "26.663;23.598;26.931;24.74;25.806" : "27.21;26.122;26.706;26.878;26.152"\n}\n
[54] {\n "26.663;23.598;26.931;24.74;25.806" : "26.379;24.712;25.688;24.99;24.239"\n}\n
[55] {\n "26.663;23.598;26.931;24.74;25.806" : "26.721;23.475;24.767;26.219;28.361"\n}\n
[56] {\n "26.663;23.598;26.931;24.74;25.806" : "28.599;27.914;27.784;25.693;26.881"\n}\n
[57] {\n "26.663;23.598;26.931;24.74;25.806" : "26.217;24.218;27.914;26.975;28.527"\n}\n
[58] {\n "26.663;23.598;26.931;24.74;25.806" : "27.139;28.982;28.169;28.056;29.136"\n}\n
[59] {\n "26.663;23.598;26.931;24.74;25.806" : "26.291;26.987;26.589;24.848;27.543"\n}\n
[60] {\n "26.663;23.598;26.931;24.74;25.806" : "26.896;28.878;27.39;28.065;28.141"\n}\n
[61] {\n "26.663;23.598;26.931;24.74;25.806" : "29.048;28.484;26.634;27.735;27.132"\n}\n
[62] {\n "26.663;23.598;26.931;24.74;25.806" : "24.924;28.963;26.589;27.931;28.009"\n}\n
[63] {\n "26.663;23.598;26.931;24.74;25.806" : "29.229;28.759;28.405;27.945;25.912"\n}\n
[64] {\n "26.663;23.598;26.931;24.74;25.806" : "26.619;26.076;25.286;27.66;25.951"\n}\n
[65] {\n "26.663;23.598;26.931;24.74;25.806" : "26.398;25.565;28.865;30;29.261"\n}\n
[66] {\n "26.663;23.598;26.931;24.74;25.806" : "29.012;26.992;27.897"\n}\n
33 Levels: {\n "26.663;23.598;26.931;24.74;25.806" : "20.035;23.59;21.672;22.222;22.123"\n}\n ...
I want to use ARIMA to create a forecast using this data. To do so I tried to parse this data into numeric using
bnumeric <- as.numeric(unlist(bstring))
This did not work well, I got a pretty useless vector of numbers. How can I extract the numbers from this data to create a forecast?

looking for a code list for cil , as in what does 16, 17, 18 , 19 , 02 do

I was wondering if there is a cil code list, I think 16 = false and 17 = true, but not 100% sure, also think -1 = 0 , but if anyone has a website to help with this that would be great.
16 = false
17 = true ?
You can find a complete listing of all opcodes in Partition III of ECMA-335, but as for the specific instructions you listed:
02 (0x02) = ldarg.0
16 (0x10) = starg.s
17 (0x11) = ldloc.s
18 (0x12) = ldloca.s
19 (0x13) = stloc.s
0x16 = ldc.i4.0 // could be a 0 or false or '\0' ... the exact type depends on how it's used.
0x17 = ldc.i4.1 // could be a 1 or true or '\u0001' ... again, the exact type depends on how it's used.
0x18 = ldc.i4.2
0x19 = ldc.i4.3

SQL Server Pivot Sum By Day Grand Total

The query work except the total sum of local amount. I can used sum IIF or case when to calculate the sum of the local amount as usual but I would like to know how it works using a SQL Server pivot.
The first query are pivot and with roll up and I want this below query union to it and given the output of grant total.
DECLARE #financialYear INT;
DECLARE #financialPeriod INT;
SET #financialYear = 2013;
SET #financialPeriod = 7;
SELECT chartOfAccountCategoryDescription,
chartOfAccountDescription,
coalesce([1], 0) AS [1],
coalesce([2], 0) AS [2],
coalesce([3], 0) AS [3],
coalesce([4], 0) AS [4],
coalesce([5], 0) AS [5]
,coalesce([6], 0) AS [6]
,coalesce([7], 0) AS [7]
,coalesce([8], 0) AS [8]
,coalesce([9], 0) AS [9]
,coalesce([10], 0) AS [10]
,coalesce([11], 0) AS [11]
,coalesce([12], 0) AS [12]
,coalesce([13], 0) AS [13]
,coalesce([14], 0) AS [14]
,coalesce([15], 0) AS [15]
,coalesce([16], 0) AS [16]
,coalesce([17], 0) AS [17]
,coalesce([18], 0) AS [18]
,coalesce([19], 0) AS [19]
,coalesce([20], 0) AS [20]
,coalesce([21], 0) AS [21]
,coalesce([22], 0) AS [22]
,coalesce([23], 0) AS [23]
,coalesce([24], 0) AS [24]
,coalesce([25], 0) AS [25]
,coalesce([26], 0) AS [26]
,coalesce([27], 0) AS [27]
,coalesce([28], 0) AS [28]
,coalesce([29], 0) AS [29]
,coalesce([30], 0) AS [30]
,coalesce([31], 0) AS [31]
,coalesce([Total], 0) AS [Total] FROM (
SELECT 'Total' AS chartOfAccountCategoryDescription
,' ' AS chartOfAccountDescription
,ISNULL(DATENAME(DAY, generalLedgerDate), 'Total') AS theMonth
,ABS(localAmount) AS items
FROM generalLedger
WHERE DATEPART(YEAR, generalLedgerDate) = #financialYear
) AS s
PIVOT(SUM(items) FOR theMonth IN (
[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]
,[26]
,[27]
,[28]
,[29]
,[30]
,[31]
,[Total]
)) AS p

"Illegal instruction: 4" shows up in OS X Lion

Some C++ application compiled and run seamlessly in OS X Snow Leopard, but I changed recently to OS X Lion, and here, although there is no compilation error, when I try to run it I get the error "Illegal instruction: 4", I have no clue, what could be the reason?
PS:
These are the linking flags I use
-Wl,-stack_size,0x10000000,-stack_addr,0xc0000000
This is the output I get when I do sudo truss executable
setrlimit returned result = -1
SYSCALL(args) = return
getpid(0x0, 0x0, 0x0) = 32993 0
__sysctl(0xBFFFF5EC, 0x3, 0xBFFFF5E8) = 0 0
issetugid(0xBFFFF5EC, 0x3, 0xBFFFF5E8) = 0 0
csops(0x0, 0x0, 0xBFFFF65C) = 0 0
shared_region_check_np(0xBFFFD5E0, 0x0, 0xBFFFF65C) = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0xBFFFE830, 0xBFFFF65C) = 0 0
open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0) = 3 0
pread(0x3, "\312\376\272\276\0", 0x1000, 0x0) = 4096 0
pread(0x3, "\316\372\355\376\a\0", 0x1000, 0x6000) = 4096 0
mmap(0x4D3000, 0x2000, 0x1, 0x12, 0x3, 0x3) = 0x4D3000 0
mmap(0x4D5000, 0x1000, 0x3, 0x12, 0x3, 0x3) = 0x4D5000 0
mmap(0x4D6000, 0x1EF0, 0x1, 0x12, 0x3, 0x3) = 0x4D6000 0
close(0x3) = 0 0
stat64("/usr/lib/libstdc++.6.dylib\0", 0xBFFFE690, 0x1) = 0 0
stat64("/usr/lib/libgcc_s.1.dylib\0", 0xBFFFE690, 0x1) = 0 0
stat64("/usr/lib/libSystem.B.dylib\0", 0xBFFFE560, 0x1) = 0 0
stat64("/usr/lib/libc++abi.dylib\0", 0xBFFFE5D0, 0x1) = 0 0
stat64("/usr/lib/system/libcache.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcopyfile.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdispatch.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdnsinfo.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdyld.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libkeymgr.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/liblaunch.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libmacho.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libquarantine.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libremovefile.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_c.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_info.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_network.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_notify.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libunc.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libunwind.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libxpc.dylib\0", 0xBFFFE360, 0x1) = 0 0
open("/dev/dtracehelper\0", 0x2, 0xBFFFF5B0) = 3 0
ioctl(0x3, 0x80086804, 0xBFFFF540) = 0 0
close(0x3) = 0 0
__sysctl(0xBFFFF1FC, 0x2, 0xBFFFF1F4) = 0 0
bsdthread_register(0x92C9F6BC, 0x92C9F6E0, 0x1000) = 0 0
thread_selfid(0x92C9F6BC, 0x92C9F6E0, 0x1000) = 2500945 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0xAC308375) = 0x4D8000 0
mprotect(0x4D8000, 0x44, 0x1) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4D8034) = 0x4DA000 0
mprotect(0x4DA000, 0x1000, 0x0) = 0 0
mprotect(0x4E6000, 0x1000, 0x0) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4DB000) = 0x4E7000 0
mprotect(0x4E7000, 0x1000, 0x0) = 0 0
mprotect(0x4F3000, 0x1000, 0x0) = 0 0
mmap(0x0, 0x1000, 0x3, 0x1002, 0x1000000, 0x4E8000) = 0x4F4000 0
mprotect(0x4F4000, 0x1000, 0x1) = 0 0
mprotect(0x4D8000, 0x44, 0x3) = 0 0
mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x4F4000) = 0x4F5000 0
munmap(0x4F5000, 0xB000) = 0 0
munmap(0x600000, 0xF5000) = 0 0
mprotect(0x4D8000, 0x44, 0x1) = 0 0
getpid(0x4D8000, 0x44, 0x1) = 32993 0
__mac_syscall(0x973E8E8E, 0x2, 0xBFFFF0C8) = 0 0
stat64("/AppleInternal\0", 0xBFFFF130, 0xBFFFF0C8) = -1 Err#2
audit_session_self(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 5635 0
geteuid(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 0 0
getegid(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 0 0
getaudit_addr(0xBFFFF0A8, 0x30, 0xBFFFF0C8) = 0 0
csops(0x80E1, 0x7, 0xBFFFECF8) = 0 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0xACA5EB00) = 0x4F5000 0
mprotect(0x4F5000, 0x44, 0x1) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4F5034) = 0x600000 0
mprotect(0x600000, 0x1000, 0x0) = 0 0
mprotect(0x60C000, 0x1000, 0x0) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x601000) = 0x60D000 0
mprotect(0x60D000, 0x1000, 0x0) = 0 0
mprotect(0x619000, 0x1000, 0x0) = 0 0
mprotect(0x4F4000, 0x1000, 0x3) = 0 0
mprotect(0x4F4000, 0x1000, 0x1) = 0 0
mprotect(0x4F5000, 0x44, 0x3) = 0 0
mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x4F4004) = 0x61A000 0
munmap(0x61A000, 0xE6000) = 0 0
munmap(0x800000, 0x1A000) = 0 0
mprotect(0x4F5000, 0x44, 0x1) = 0 0
getrlimit(0x1003, 0xBFFFF8DC, 0x1) = 0 0
setrlimit(0x1003, 0xBFFFF8DC, 0x1) = -1 Err#22
getrlimit(0x1008, 0xBF835C60, 0x1) = 0 0
fstat64(0x1, 0xBF836090, 0x1F) = 0 0
mmap(0x0, 0x1000000, 0x3, 0x1002, 0x2000000, 0xACA5B3E0) = 0x800000 0
munmap(0x1000000, 0x800000) = 0 0
PS2: If I remove the previously mentioned linking flag, the program runs, with no error. But when I input real data to the program, then I get
Segmentation fault: 11
I remember that this program had a problem with the stack, so it had to be increased. In Linux I did this and works
const rlim_t kStackSize = 256L * 1024L * 1024L; // min stack size = 64 Mb
struct rlimit rl;
int result;
result = getrlimit(RLIMIT_STACK, &rl);
if (result == 0)
{
if (rl.rlim_cur < kStackSize)
{
rl.rlim_cur = kStackSize;
result = setrlimit(RLIMIT_STACK, &rl);
if (result != 0)
{
fprintf(stderr, "setrlimit returned result = %d\n", result);
}
}
}
but in OS X, since that did not work, I used the previously mentioned linking flag, and had no problem is OS X Snow Leopard, so it seems I still have the stack overflow problem in OS X Lion but the linking flag does not solve this. What could I do?
I encountered this issue when building a product on Mountain Lion (10.8,) and then running on Lion. (10.7). The cause was that I made some changes to my build environment.
(I'm using mkbundle to ship a product that uses Mono.)
The fix was very simple, I had to tell clang that generated binaries need to work on OSX 10.6. I added the following argument to clang:
-mmacosx-version-min=10.6
Problem solved!
In OS X Lion (but also 10.5) the stack size hard limit is 65532 kbytes (just under 64 MiB).
This can be seen with:
bswift$ ulimit -Hs
65532
Even as root, I couldn't increase this value.
The soft limit defaults to only 8 MiB:
bswift$ ulimit -Ss
8192
Try raising the value to this maximum before starting you application:
bswift$ ulimit -Ss unlimited
bswift$ ulimit -Ss
65532
Note: segmentation fault (SIGSEGV) (number 11) you observed is the signal sent to the process when the stack limit is exceeded according to man setrlimit
Note: Since the ulimit command needs to be a shell builtin, you will find it documented in man bash
This could be a permissions issue.
To diagnose further, run your program from the terminal with sudo dtruss prefixed. See which syscall it runs before throwing the error.
Example: sudo dtruss /path/to/application
You can also diagnose it with the Xcode or GDB debuggers.