How do I debug an ExternalCallback that crashes the image?
The callback is defined as:
ExternalCallback
block: [ :time :event :sequencer :data | Transcript display: time; cr. nil ] descriptor: (ExternalDescriptor
callingConvention: 'stdcall:'
returnType: 'void'
argumentTypes: 'word FluidEvent* FluidSequencer* lpvoid').
Based on this definition (from https://www.fluidsynth.org/api/group__sequencer.html#gae6bb99d73ba67f0b7e15883b78bfae85):
typedef void(* fluid_event_callback_t) (unsigned int time, fluid_event_t *event, fluid_sequencer_t *seq, void *data)
Every time the callback gets invoked, the body gets executed and then the image crashes. I suspect it has to do with the return type, but I've tried returning nil, 0, 1, true, false, and self all to no avail.
DPRO.ERRORS just has some gobbledygook about an unhandled Win32 exception, ...
and if I put a halt statement in the callback, the crash seems to somewhere around a call to ProcessScheduler>>callback:return:, which again points to an issue with the return type.
From searching this group, the problem seems to recur over and over again and there don't seem to be any general solutions.
I can see that the callback descriptor is incorrect - the first argument is an unsigned int, so would be 32-bits not 16, i.e. `dword` not `word`. This would cause you other problems than the crash you describe, however.
It suggests you have got the calling convention wrong. To be sure you'd have to examine the original source and build definition (if not documented), but the chances are that it is using the default C calling convention, so cdecl, not stdcall. Usingthe wrong one of these would certainly result in a crash on return, because these employ different conventions at to whether caller or callee is responsible for adjusting the stack pointer.
Which you are choosing to disparage because you don't understand it? It is likely that the details require to diagnose the fault are in that gobbledygook. I'd imagine the exception code is one of the stack fault codes.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 512 |
Nodes: | 16 (2 / 14) |
Uptime: | 84:29:58 |
Calls: | 10,018 |
Calls today: | 1 |
Files: | 13,847 |
D/L today: |
1 files (9K bytes) |
Messages: | 6,365,519 |