Win 8.1 App crashes on user device - How to debug? - windows-store-apps

last week I published my first Windows 8.1 app on the Windows Store. So far everything works fine but now two user reported that the app crashes immediately when being launched.
Additionally I discovered that there is a CrashDump listed in the Reports/Quality section of the Dashboard. I dowloaded the CrashDump and tried to find the source of the problem using WinDbg by following this instruction: http://blogs.msdn.com/b/ntdebugging/archive/2014/01/13/debugging-a-windows-8-1-store-app-crash-dump.aspx
I was able to follow the instruction almost up to the end but then the sos library is not found:
0:006> .sympath SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols
...
0:006> .exr -1
ExceptionAddress: 769eb1d7 (combase+0x000fb1d7)
ExceptionCode: c000027b
ExceptionFlags: 00000001
NumberParameters: 2
Parameter[0]: 03f3f32c
Parameter[1]: 00000001
0:006> !error c000027b
Error code: (NTSTATUS) 0xc000027b (3221226107) - Anwendungsinterne Ausnahme.
0:006> .ecxr
eax=03f3f030 ebx=00000000 ecx=00000000 edx=00000000
esi=03f3f360 edi=03f3f030 eip=769eb01f esp=03f3f314
ebp=03f3f3bc iopl=0 nv up ei pl nz ac po nc cs=001b
ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000212
combase+0xfb01f: 769eb01f 6a03 push 3
0:006> knL
*** Stack trace for last set context - .thread/.cxr resets it
...
0:006> dt 03f3f32c combase!_STOWED_EXCEPTION_INFORMATION_HEADER*
0x05f182e4
+0x000 Size : 0x28
+0x004 Signature : 0x53453032
0:006> .formats 0x53453032
Evaluate expression:
Hex: 53453032
Decimal: 1397043250
Octal: 12321230062
Binary: 01010011 01000101 00110000 00110010
Chars: SE02
Time: Wed Apr 09 13:34:10 2014
Float: low 8.46917e+011 high 0
Double: 6.90231e-315
0:006> dt -a1 03f3f32c combase!_STOWED_EXCEPTION_INFORMATION_V2*
[0] # 03f3f32
---------------------------------------------
0x05f182e4
+0x000 Header : _STOWED_EXCEPTION_INFORMATION_HEADER
+0x008 ResultCode : 80131500
+0x00c ExceptionForm : 0y01
+0x00c ThreadId : 0y000000000000000000010001100101 (0x465)
+0x010 ExceptionAddress : 0x76943bff Void
+0x014 StackTraceWordSize : 4
+0x018 StackTraceWords : 0xa
+0x01c StackTrace : 0x04c6c010 Void
+0x010 ErrorText : 0x76943bff "趍ﯰ???" +0x
+0x020 NestedExceptionType : 0x314f454c
+0x024 NestedException : 0x05f1be44 Void
0:006> !error 80131500
Error code: (HRESULT) 0x80131500 (2148734208) - <Unable to get error code text>
0:006> dpS 0x04c6c010 La 7697a9f1 combase!RoOriginateLanguageException+0x3b [d:\blue_gdr\com\combase\winrt\error\error.cpp # 1083]
63da3bc6 mscorlib_ni+0x9b3bc6
63e41976 mscorlib_ni+0xa51976
63e415c1 mscorlib_ni+0xa515c1
5b72f9df System_Runtime_WindowsRuntime_ni+0x1f9df
5b72f965 System_Runtime_WindowsRuntime_ni+0x1f965
6372de66 mscorlib_ni+0x33de66
5b72f934 System_Runtime_WindowsRuntime_ni+0x1f934
5b6bff16 Windows_UI_ni+0x9ff16
64492a36 clr!COMToCLRDispatchHelper+0x28
0:006> !sos.pe
The call to LoadLibrary(sos) failed, Win32 error 0n2
"The system cannot find the file specified."
Please check your debugger configuration and/or network access.
0:006> .loadby sos clr
The call to LoadLibrary(c:\symbols\clr.dll\52E0B78469b000\sos) failed, Win32 error 0n126
"The system cannot find the file specified."
Please check your debugger configuration and/or network access.
I does not have experience with this kind of debugging and without the instruction I would not have known any of the commands that I had to use in WinDbg.
Does anyone have an idea how to go on from here?
I have uploaded the CrashDump to my OneDrive. Would be great if anyone with more experience could have a look at it:
http://1drv.ms/1gZzrRK
Is it somehow possible to get additional information from the users who reported the crash to the support? Can they extract a crash dump / error report from their systems?
Is there any possibility to supply a changed version to these users to check if these changes influence the problem?
Thank you very much!

In order to get more insight into what your app is doing when it's running on users' devices, you could add logging of some kind. Local logging to file is an option, but a poor one, since you have to let your user dig into hidden files to retreive your application log. It might be acceptable though, depending on your scenario. In that case you might want to look at this logging sample for Windows Store Apps that uses EWT to log.
Alternatives would be using some kind of logging framework. I haven't got any experience in any of those so I couldn't tell you which one to use.
As for getting a changed version to your user: simply build an app-package locally, put it on OneDrive and send them a link to it. They can sideload the app themselves (although it requires running a Powershell script and logging in with a live-account). I've used this approach with several clients and it's workable.

Related

How to call Output Menu Item and execute Report in Batch Mode?

I have an issue in BATCH mode.
If I call this line command:
Args parameters = new Args();
MenuFunction menuFunction;
parameters.record(myCurrentTableRecord);
parameters.caller(this);
menuFunction = new MenuFunction(menuitemoutputstr(Report_Name), MenuItemType::Output);
menuFunction.run(parameters);
in Client mode, it work well. Generate the report.
If I execute this command in BATCH mode I get an error like this:
An exception of type 'System.InvalidCastException' occurred in Dynamics.Ax.Application.dll26.netmodule but was not handled in user code
System.InvalidCastException: Unable to cast object of type 'Dynamics.Ax.Application.Report_NameContract' to type 'Dynamics.Ax.Application.TradeDocumentReportContract'.
at
Dynamics.Ax.Application.TradeDocumentReportController.Prerunmodifycontract() in TradeDocumentReportController.preRunModifyContract.xpp:line 8
at Dynamics.Ax.Application.SrsPrintMgmtController.Outputreports() in SrsPrintMgmtController.outputReports.xpp:line 65
at Dynamics.Ax.Application.ReportName.Runprintmgmt() in Report_Name.runPrintMgmt.xpp:line 28
at Dynamics.Ax.Application.SrsPrintMgmtController.Run() in SrsPrintMgmtController.run.xpp:line 30
at Dynamics.Ax.Application.SysOperationController.Startoperation() in SysOperationController.startOperation.xpp:line 10
at Dynamics.Ax.Application.SrsReportRunController.Startoperation() in SrsReportRunController.startOperation.xpp:line 19
at Dynamics.Ax.Application.SrsPrintMgmtController.Startoperation() in SrsPrintMgmtController.startOperation.xpp:line 14
at Dynamics.Ax.Application.SrsPrintMgmtFormLetterController.Startoperation() in SrsPrintMgmtFormLetterController.startOperation.xpp:line 14
at Dynamics.Ax.Application.Report_Name.main(Args _args) in Report_Name.main.xpp:line 14
The Class used to define my Report extends the TradeDocumentReportController class.
I executed a Full CIL , restarted my AOS/Report Services etc...
There is any way to execute the report in BACTH Mode? Have I to pass any parameters?
Thanks in advice.
Enjoy.
From the looks of it, Report_NameContract doesn't extend TradeDocumentReportContract.
It might be a good idea for you to debug the batch job using Visual Studio by attaching to process Ax32Serv.exe, if you want to see what exactly is going on and where the process doesn't work as expected.

How to force gfortran to stop at First NaN?

My Configuration: Cygwin64, Win7 64 bit, gfortran 4.8.3
I did go through all the Q/A pairs I managed to find, this one is the closest to my problem
Force gfortran to stop program at first NaN
PROBLEM: The fortran code
real :: init_with_NaN ! -finit-real=nan
res = 10 * init_with_NaN
The code is compiled with the following gfortran flags
COLLECT_GCC_OPTIONS='-funderscoring' '-O0' '-g' '-c' '-fmessage-length=0' '-O0' '-g' '-ffpe-trap=invalid,zero,overflow,underflow,precision,denormal' '-Wall' '-c' '-fmessage-length=0' '-Wpedantic' '-std=f2003' '-fall-intrinsics' '-fbacktrace' '-fimplicit-none' '-Wextra' '-Wformat=1' '-Wconversion' '-Wfatal-errors' '-finit-real=nan' '-Wuninitialized' '-fbounds-check' '-v' '-o' 'fsignal_test.o' '-mtune=generic' '-march=x86-64'
Once the code is run, instead of getting a SIGFPE, res is set to be NaN and execution continues.
This is a sub-problem of a million dollar question:
Does gfortran -ffpe-trap=invalid flag really stops the program once it detects a NaN anywhere in the program ? Especially on Cygwin64 env?
A little research showed that:
1) Acc.to https://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html, -ffpe-trap works on MOST systems, not all :(
2) Acc. to Division by zero does not throw SIGFPE
"You don't get a signal because the default behavior on most machines
is to pollute your data with NaNs (not-a-number) and infinities. You
have to enable floating point exceptions, and how you do that is
machine specific. Look at the system header fenv.h, if you have one.
The function fesettrapenable enables catching floating point
exceptions on many machines.
Unfortunately, there is no standard function to turn floating point
exceptions handling on"
3) I have checked my cygwin env, fenv.h exists in multiple places but there is no fesettrapenable function anywhere under any *.h file under cygwin64.
4) I do get SIGFPEs: like sqrt(-1), div by zero, overflow, underflow, precision
Here is the full Fortran test project in Eclipse, use it at your hearts content to learn about exceptions on your own platform:
https://drive.google.com/file/d/0B9U1dlb_UCPqU194XzhDNTNkUUU/view?usp=sharing

django: South does not generate the same index names depending on platform

I'm working on a django application with a MySQL backend. I use south to migrate my schema.
I've just written a migration that drops indexes on some columns, because of a foreign key change AND a name change for said colums.
I did not want to go through the "add the column"->"copy the data"->"remove the old column".
So my migration code chunks look like this (sample given for one table):
# Change FK link from 'reference_workobject' to 'assets_asset'
db.delete_foreign_key('reference_snapshot', 'workObject_id')
db.delete_index('reference_snapshot', ['workObject_id'])
db.rename_column('reference_snapshot', 'workObject_id', 'asset_id')
db.alter_column('reference_snapshot', 'asset_id',
self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['assets.Asset'])
But I get an error that looks like:
DatabaseError: (1091, "Can't DROP 'reference_snapshot_6232368c; check that column/key exists")
Indeed, I fed my development DB (Windows 7 workstation) with a dump from the production server (CentOS 6.5). And I saw that the call to the index name generation (db.create_index_name) does not return the same value on the distinct platforms.
>>> # On WINDOWS
>>> db.create_index_name('reference_snapshot',['workObject_id'])
'reference_snapshot_6232368c'
>>> # On Linux
>>> db.create_index_name('reference_snapshot',['workObject_id'])
'reference_snapshot_9dcdc974'
After investigation, I saw that south should generate my index name as follows:
index_name = '%s_%x' % (table_name, abs(hash((column_name,))) % 2**32)
EDIT
Executing such code snippet yields the same value on both platforms. However the call to create_index_namedoes not. Paradox. Maybe south is not using the code I thought it would.
The call to that snippet of code does actually yields differents results.
>>> # On windows
>>> hash((column_name,))
1965709063
>>> # On Linux
>>> hash((column_name,))
-791966850447943929
If the 32 bits truncation/padding (% 2**32) part was made without the call to abs(), though, the results would be the same.
I conclude from this that the hashing is 32 bits based on windows (even if I use a 64bits python), and 64 bits based on linux.
end edit
So I'm stuck as I can't use the production dumps on windows so as to test my migrations.
Any ideas? Maybe monkey-patching something on my dev workstation could do the trick.
Thanks
Too bad. We can't help but suffer the differences in hash implementation.
However I've just read that the index name calculation will now (as of django 1.5) use md5 because of Python3's randomization in hash(). http://south.aeracode.org/ticket/1222

An exported aliases symbol doesn't exist in PDB file (RegisterClipboardFormat has RegisterWindowMessage internal name)

I'm trying to set a breakpoint in user32!RegisterClipboardFormat
Evidently, this function is exported (link /dump /exports - it is right there). Before downloading the PDB file from the Microsoft symbol server, I'm able to find this function:
0:001> lm m user32
start end
76eb0000 76fcf000 USER32 (export symbols) c:\Windows\system32\USER32.dll
0:001> x user32!RegisterClipboardFormat*
76ec4eae USER32!RegisterClipboardFormatA (<no parameter info>)
76ec6ffa USER32!RegisterClipboardFormatW (<no parameter info>)
No problems. I'm able to 'bu' any of these functions. But when I download the PDB symbols from the Microsoft PDB server:
0:001>
start end module name
76d50000 76e6f000 USER32 (pdb symbols) c:\symbols\user32.pdb\561A146545614951BDB6282F2E3522F72\user32.pdb
0:000> x user32!RegisterClipboardFormat
WinDBG cannot find the symbols. However, it can find RegisterWindowMesssage:
0:000> x user32!RegisterWindowMessage*
76d64eae USER32!RegisterWindowMessageA = <no type information>
76d66ffa USER32!RegisterWindowMessageW = <no type information>
Note that the functions have the same addresses (This is on Windows 8. Not sure about previous versions). This is probably achieved by the optimizer or in the DEF file (func1=func2 in the EXPORT section). 'link /dump /exports' shows RegisterWindowMessage and RegisterClipboardFormat have the same RVA.
Problem is that I spent way too much time on this. So my questions are:
Is there is an easy way, from within WinDBG to find out missing aliased export symbols.
Say I want to break only on RegisterClipboardFormatW. If I recall correctly, there should be a JMP instruction somewhere (in the calling module import table). How do I find that symbol? Is there a way to find this entry in all calling modules?
Since RegisterWindowMessage and RegisterClipboardFormat have the same RVA, they share the same implementation. Apparently Windows does not make any distinction between the two and both clipboard format and window messages share the same domain of identifiers.
For your first question -- how to find out which implementation function corresponds to exported function. (assuming you have symbols fixed up) First figure out RVA of the export:
C:\>link /dump /exports C:\Windows\Syswow64\user32.dll |findstr RegisterClipboardFormat
2104 24F 00020AFA RegisterClipboardFormatA
2105 250 00019EBD RegisterClipboardFormatW
Then in WinDbg find starting address where DLL is loaded from. Commands lm or lml list all modules, you just need to find the module you are after:
0:001> lml
start end module name
75460000 75560000 USER32
Using RVA as offset to the starting address, get symbol that corresponds to it:
0:002> ln 75460000+00020AFA
(75480afa) USER32!RegisterWindowMessageA | (75480b4a) USER32!MsgWaitForMultipleObjects
Exact matches:
0:002> ln 75460000+00019EBD
(75479ebd) USER32!RegisterWindowMessageW | (75479eea) USER32!NtUserGetProcessWindowStation
Exact matches:
So here we actually found out that RegisterClipboardFormat actually calls into RegisterWindowMessage.
Your second question -- how to put breakpoint only on RegisterClipboardFormat, and not on RegisterWindowMessage. In general it is impossible, because they share the same implementation. For example, your app might call GetProcAddress("RegisterClipboardFormat") and you will have hard time figuring out if it called to one function or another. However if you know that the call was made through imported function, then you can do this. All imported functions are declared in import address table in your application. If you put an access breakpoint on the entry in import address table, you can break before the call is made. This might be compiler specific, but I know that Visual C++ assigns symbolic names to entries in import address table. In this case putting breakpoint is easy:
ba r4 MyModule!_imp_RegisterClipboardFormatA

Connecting to a remote MySQL server from a Delphi program through SSL

I don't have a good knowledge of SSL principles, but just want the encryption to work for me.
I have a DB and a user with "REQUIRE X509" specified.
The necessary certificates have been created as described in MySQL docs, and work well - i can connect to the server from Windows command line.
The problem arises, when i try to do the same from my program using MySQL Client API (without SSL, the program also works fine).
The unit used is: http://www.audio-data.de/mysql.html.
These are my action paths:
1) if i just add mysql_ssl_set() call (with proper params) before mysql_real_connect(), the last one gives generic SSL Connection Error.
2) the MySQL docs in en/mysql-ssl-set.html say, that the function always returns 0. But when i checked that, it appeared that the result is the number 11150848. Then i wrote it like that:
showmessage(inttostr(mysql_ssl_set(mys, '.\certs\client-key.pem', '.\certs\client-cert.pem', '.\certs\ca-cert.pem', nil)));
...and repeated the line 8 times.
Each time it returned a slightly greater number - 11158528, 11158784, 11159040, ... and two zeroes for the last two calls.
After which mysql_real_connect() was finally successful! The program even managed to execute some queries, return proper results for them (i know the data), but then it crashed with an Access Violation: write of address ... at some place.
The crash point varied between runs and slight changes to code.
It looks much like a version incompatibility issue. I tried libraries from both MySQL 5.0 and 5.1 Windows installations (the server is 5.1 and runs under Linux remotely; however, 5.0 mysql-client programs do not have troubles when SSL-connecting to it), but with no success.
Is anybody familiar with the issue? Thanks a lot for the help & sorry for the mistakes in the question.
As I see the mysql_ssl_set declaration is incorrect. It is declared:
function mysql_ssl_set(_mysql: PMYSQL; key, cert, ca, capath: PAnsiChar): longint; stdcall;
But the mysql.h contains:
my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
const char *cert, const char *ca,
const char *capath, const char *cipher);
That explains the garbage in return value, AV's and so on.