Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2025-01

InterlockedExchangeAdd64

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Adriaan van Os

I have an arm64 (aarch64) test program on MacOS that calls InterlockedExchangeAdd64 with a target variable that is not 8-byte aligned. Running the test program emits "EBusError: Bus error or misaligned data access".

So far so good.

But now I install a system.ErrorProc and run the same program. It emits, instead of the EBusError, Runtime Error 214.

This puzzles me.

Of course, I can add a bug report.

Regards,

Adriaan van Os

Tomas Hajny
to Adriaan van Os
Adriaan van Os wrote 13 lines
I have an arm64 (aarch64) test program on MacOS that calls InterlockedExchangeAdd64 with a target variable that is not 8-byte aligned. Running the test program emits "EBusError: Bus error or misaligned data access". So far so good. But now I install a system.ErrorProc and run the same program. It emits, instead of the EBusError, Runtime Error 214. This puzzles me. Of course, I can add a bug report.

Is this really a bug? This depends on what you do in your ErrorProc implementation, doesn't it?

Tomas

Adriaan van Os
to Tomas Hajny
Is this really a bug? This depends on what you do in your ErrorProc implementation, doesn't it?

Do a writeln the runtime number and break. But normally, a bus error, doesn't call into System.ErrorProc.

Regards,

Adriaan van Os

Sven Barth
to Adriaan van Os: I have an arm64 (aarch64) test program on MacOS that calls InterlockedExchangeAdd64 with…
Adriaan van Os wrote 12 lines
I have an arm64 (aarch64) test program on MacOS that calls InterlockedExchangeAdd64 with a target variable that is not 8-byte aligned. Running the test program emits "EBusError: Bus error or misaligned data access". So far so good. But now I install a system.ErrorProc and run the same program. It emits, instead of the EBusError, Runtime Error 214. This puzzles me.

This is as designed, because the ErrorProc is what is used by the SysUtils unit to convert runtime errors to exceptions. If you want to implement your own handling, then store the original value of ErrorProc, assign your own handler, do your own handling and at the end call the saved ErrorProc.

Regards,
Sven

Adriaan van Os
to Sven Barth
Sven Barth wrote 19 lines
Am 10.01.2025 um 15:43 schrieb Adriaan van Os via fpc-pascal: > > I have an arm64 (aarch64) test program on MacOS that calls > InterlockedExchangeAdd64 with a target variable that is not 8-byte > aligned. Running the test program emits "EBusError: Bus error or > misaligned data access". > > So far so good. > > But now I install a system.ErrorProc and run the same program. It > emits, instead of the EBusError, Runtime Error 214. > > This puzzles me. This is as designed, because the ErrorProc is what is used by the SysUtils unit to convert runtime errors to exceptions. If you want to implement your own handling, then store the original value of ErrorProc, assign your own handler, do your own handling and at the end call the saved ErrorProc.

I don't want to handle the error, I want a meaningful error. And Runtime Error 214 "Collection overflow" is nonsense.

Regards,

Adriaan van Os

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote 15 lines
> Am 10.01.2025 um 15:43 schrieb Adriaan van Os via fpc-pascal: >> >> But now I install a system.ErrorProc and run the same program. It >> emits, instead of the EBusError, Runtime Error 214. >> >> This puzzles me. > > This is as designed, because the ErrorProc is what is used by the > SysUtils unit to convert runtime errors to exceptions. If you want to > implement your own handling, then store the original value of > ErrorProc, assign your own handler, do your own handling and at the > end call the saved ErrorProc. I don't want to handle the error, I want a meaningful error. And Runtime Error 214 "Collection overflow" is nonsense.

The sole purpose of overriding System.ErrorProc is to handle errors by yourself. If you don't want to handle a particular error, do as Sven said (call the original System.ErrorProc), and then whatever custom error handler that was there before will do its thing. In this case: the error handler that was installed by the SysUtils unit, which will raise an EBusError exception (which seems to be what you want).

Jonas