Open simonjwright opened 3 years ago
Simple (and less simple) reproducers failed to actually reproduce the issue, so I’ve started a new branch issue_5, with changes that work (on my Debian Stretch VMware Fusion vm).
OK. The example now works for me.
alex@mint-vm$ ./interrupt_handling-harness
Interrupt_Handling.Harness.
---------------------------
This program demonstrates handling a Signal, which is the
nearest thing to an interrupt available in standard OSs.
On Mac OS X and Linux systems, run the program and type C-c
(ctrl-c) to see the interrupt being reported.
On Windows, this doesn't work from a Cygwin Bash shell;
instead, run from a Command Shell started from Start/Run.
entered state IDLE
Interrupt_Handling.Device.T running
Interrupt_Handling.Device.T started
^CInterrupt_Handling.Device.T released
entered state INTERRUPTED
entered state IDLE
entered state IDLE
entered state IDLE
^CInterrupt_Handling.Device.T released
entered state INTERRUPTED
entered state IDLE
entered state IDLE
^CInterrupt_Handling.Device.T released
entered state INTERRUPTED
entered state IDLE
entered state IDLE
^CInterrupt_Handling.Device.T released
entered state INTERRUPTED
entered state IDLE
^Z
[1]+ Stopped ./interrupt_handling-harness
Did you find out what was causing the problem?
Did you find out what was causing the problem?
No; in gdb, I could see the interrupt triggering the task blocked on the PO, but then nothing happened.
Hmmm. I guess this would be something to report to AdaCore.
Situation as of 2022-04-09: on Debian 11, macOS x86_64 the original (unfixed) demo works with GCC 10 but fails with GCC 11.
On macOS x86_64 and aarch64, it fails with GCC 12.
In all these cases, the simple Attach_Handler
version works; and, this is the approach that anyone working on an embedded platform is going to be using, I think.
Not sure this demo is worth preserving in its present form. I certainly wouldn’t want to present it to AdaCore without some better idea of what’s going on.
Well, the problem appears to happen when the handling PO is allocated rather than being declared directly; this works
type Handler is new Ada.Finalization.Limited_Controlled with record
Handling_PO : Handling;
Attached_Interrupt : Ada.Interrupts.Interrupt_ID := 0;
Old_Handler : Ada.Interrupts.Parameterless_Handler;
end record;
provided you use ’Unrestricted_Access
:
procedure Attach (H : in out Handler;
To : Ada.Interrupts.Interrupt_ID) is
begin
Ada.Interrupts.Exchange_Handler
(Old_Handler => H.Old_Handler,
New_Handler => H.Handling_PO.Trigger'Unrestricted_Access,
Interrupt => To);
H.Attached_Interrupt := To;
end Attach;
Now I might be able to produce a demo!
As reported in issue #4, the Interrupt Handling example, which is supposed to catch and report C-c, doesn’t do so on Linux Mint (or, it turns out, on Debian stretch).
Works fine on macOS Catalina.