How does fabric aggregate crashes? - crashlytics

Does it use only the last function call or a few functions after that ?
Because I have a few callstacks that are different but they do end up in the same function call (a crash handler) and fabric aggregates them all in the same crashes but they have a very different callstack !

Related

How to get the name of the calling program in an asynchronous background task?

How to get the name of the calling program from within an asynchronous remote function call (aRFC) ?
CALL FUNCTION 'BAPI_MATERIAL_SAVEREPLICA' STARTING NEW TASK lv_taskname
DESTINATION IN GROUP DEFAULT
The called BAPI triggers a user exit that I need to disable for this particular calling program. However, the local part of the stack is lost after the RFC and the name of the calling program on the local system is unknown.
The closest solution I could think of was disabling the user exit when the calling program is SAPMSSY1 (RFC calls), but that it not as accurate.
Maybe the parameter CALLER_PROGRAM of the function module RFC_GET_ATTRIBUTES. I'm not sure it works in all kinds of RFC calls.

Met strange error when using pinvoke to call ReadFile in background thread

What I am doing is writing a WPF application to work with our device. The application writes some commands to the device and reads command's response from it. I got pinvoke declarations from pinvoke.net website for CreateFile, WriteFile, ReadFile, etc.
I made a function doing following things, CreateFile(with flag FILE_FLAG_OVERLAPPED
) to open device, WriteFile to send command, ReadFile to read response, WaitForSingleObject and GetOverlappedResult to capture timeout exception if device doesn't respond, and CloseHandle to close device.
This function always worked fine if I called it in UI thread. But I wanted to call it in background thread to keep UI active. So I created a thread in Window_Loaded method(Work is my function's name).
t = new Thread(Work);
t.Start();
Then ReadFile, WaitForSingleObject and GetOverlappedResult group may met error, these three functions returned success and GetOverlappedResult could capture correct read length returned from device. But no actual data read from device filled in the byte array buffer passed to ReadFile function. The failure rate was about 50%.
If I waited thread t to finish, then it always worked fine again.
t = new Thread(Work);
t.Start();
t.join();
Of cause UI would also hang in this situation.
I searched this problem but no exact same question was found. I tried to set background thread's apartment state to STA or MTA explicitly, but it didn't work.
t = new Thread(Work);
t.SetApartmentState(ApartmentState.STA);
t.Start();
It really confuses me. Please help me if you have any idea. Thank you for your reading.
I couldn't find the root cause. But I bypassed it by rewriting read process in C++ function and calling my C++ function with pInvoke.

IDXGIFactory->CreateSwapChain sets system error 0X594

I am working on a system where I want to intercept Direct3D calls to create tiled displays. I am using an APITrace like interceptor to create a message stream and recreating the calls in a second program, much like the old Chromium project. The application side works fine but the program that processes the message stream does not. What I find is that when I call CreateSwapChain() the function returns S_OK but GetLastError() returns 'error = 0x00000594 : Cannot set nonlocal hook without a module handle.' I check the error state with GetLastError() just prior to calling CreateSwapChain() and there is no error. This error makes no sense to me. Can anyone shed any light on this?
I found the problem. The parameters for the CreateSwapChain function the pDesc structure includes an output window handle. Since the message stream is packed with the arguments for the message processing side the window handle has to be replaced with correct handle before the function is called be the processor side.

Exception: The calling thread must be STA, because many UI components require this

I'm trying to use an OCR tool. This tool gets text from PDF and converts it to RTF.
Then I have to convert it to HTML, so I use:
outputText = MarkupConverter.RtfToHtmlConverter.ConvertRtfToHtml(
System.Text.Encoding.Default.GetString(response.fileData));
I put a break point in this line, cause after this row, I got an exception of:
The calling thread must be STA, because many UI components require this.
So I tried to put <STAThread()> above the function:
<STAThread()>
Public Shared Function GetFileTextByOCRTool(path As String) As String
But it doesn't work (I get the same exception)..
Doesn't it (<STAThread()>) define the function as STA?
Any help appreciated!
If you read the STAThreadAttribute documentation you will see the following remark:
Apply this attribute to the entry point method (the Main() method in C# and Visual Basic). It has no effect on other methods. To set the apartment state of threads you start in your code, use the Thread.SetApartmentState or Thread.TrySetApartmentState method before starting the thread.
So you have to mark you application entry point using the attribute (otherwise your main thread will enter the MTA), or if you are calling the component from another thread you need to call Thread.SetApartmentState to set the thread to STA before the thread is started.
Note that once a thread uses COM interop and enters an apartment it is not possible for the thread to leave the apartment and enter another one.
If you are using task or thread pool threads you will not be able to set the apartment state to STA.

What is the difference bewteen handler and callback function?

In my current project, there are lots of networking code, and it use the event handler to handle the input message. Is this mechanism different with the call back function ?
Typically not much. The handler is usually used in the context of a UI application where the UI control will call the handler to handle a UI event. The callback function is traditionally used from the C days (Function pointers) and also in the C++ (Functors) world.
As a general concept I would say that the call back functions are primarily used for Asynchronous execution. Where for example, client side function must look something up on the server and it may take a while. So instead of blocking it says :"Call back at this number (myCallBackFunction) when you are done looking up stuff on the server".
Now event handlers are just that: they handle some predefined events. Usually they wait for users to do something like click a button and then they spring into action. They typically but not necessarily expect some sort of input.
Hope this helps.