Hello Fred,

you wrote on Tue, 15 Aug 2023 01:39:42 +0000:

> Yeeeep, I get it.
> In mseapplication.pas,
> constructor tcustomapplication.create(aowner: tcomponent);
> At the end, line 1248 there is a "lock" and, strangely for NetBSD and
> OpenBSD it blocks the application when 2x click on the binary from a
> window manager.
> This fix it:
>  {$if not defined(openbsd) and not defined(netbsd)}
>  lock;
>  {$endif}
> Tested deeply on both openbsd and netbsd, all is working perfectly, even

So this nullifies my suspicion about a possibly missingcontrolling terminal.

But - did you also test it with threaded applications (e.g. the ide)?
As I see it, this "lock" uses a system mutex data structure which is used
for thread interlocking and such things to avoid mixed-up data accesses and
race conditions, even possible dead locks. If it is missing or not properly
initialized, bad things might happen, especially in situations where that
is very difficult to track down...

The data structure is defined in "kernel/mselibc.pas", and the pertaining
section is this:
 __SIZEOF_PTHREAD_MUTEX_T = {$ifdef CPU64}40{$else}24{$endif};
  Ppthread_mutex_t = ^pthread_mutex_t;

{$ifndef netbsd}  
  pthread_mutex_t = array[0..__SIZEOF_PTHREAD_MUTEX_T-1] of byte;
  pthread_mutex_t = record
         ptm_magic : dword;
         ptm_errorcheck: char;
         ptm_pad: array[0..2] of char;
         ptm_interlock: char;
         ptm_pad2: array[0..2] of char;
         ptm_owner: pointer;
         ptm_waiter: pointer;
         ptm_recursed: dword;
         ptm_spare2: pointer;
Well - for (at least) netbsd this defines a record of size _28_ or 40 bytes
in size, PROVIDED the mutex record is byte-aligned in netbsd. If that
was NOT the case, this definition might be out of order and possibly too
small in size, depending on the declaration. Thus, accesses _may_ cause
"irritations" to the system, making it behave erratically.

Sorry, I don't have any access to a netbsd system right now (would have to
find one and install it in a VM), so I cannot test whether this bears any
relevance to the problem. I only suspect that it might be able to cause
problems in some situations, and it should be expected to do so for use on
older, 32-bit, machines.
Just warning.
(And, you know, I was bitten by a well-meant "enhancement" to the db stuff
myself. I'm going to build a pertaining sample application now to test this
myself, and I do have some use for one anyway.)

(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
Mit freundlichen Grüßen, S. Schicktanz

mseide-msegui-talk mailing list

Reply via email to