[fpc-pascal] teventobject.create fails with error 161

Snorkl e tony.caduto at gmail.com
Sat Oct 15 09:51:47 CEST 2016


Sven,
Your idea worked.  I downloaded the FPC source and made that change and
then built everything to another directory.
modified the fpc.cfg to not point to the FPC dir in the Lazarus folder and
made the path changes in the Lazarus IDE.
Compiled the project with the fresh build and did the same stress test and
no issues with error 161.

Should I do bug report in the FPC bug tracker?  Do you think the fix will
be able to be included in the next FPC release?

Thanks again.


On Fri, Oct 14, 2016 at 3:41 PM, Sven Barth <pascaldragon at googlemail.com>
wrote:

> Am 14.10.2016 20:31 schrieb "Snorkl e" <tony.caduto at gmail.com>:
> >
> > Yep, I used heaptr, my code is clean.
> > Sometimes it would happen after 3 connects/disconnects and sometimes
> after 500.
> > With the GUID as the event name it has never happened again and I really
> stress tested it.
> >
> > It sounds like windows bug to me, but who knows.
>
> Looking at the code of the RTL it could be a FPC bug. FPC calls
> CreateEvent() basically like this:
>
> Result := CreateEvent(..., PChar(Name));
>
> Now the point is that by Name being a String the result of PChar(Name) is
> always a valid string consisting only of #0. That however is not equal to
> Nil which the documentation on MSDN states as necessary for an anonymous
> event.
>
> Are you able to compile FPC and its RTL yourself? In that case I'd like to
> ask you to adjust the function BasicEventCreate in
> $fpcdir/rtl/win/systhrd.inc like this:
>
> var
>   n: PChar;
> begin
>   new(plocaleventrec(result));
>   if Length(Name) = 0 then
>     n := Nil
>   else
>     n := PChar(Name);
>   plocaleventrec(result)^.FHandle := CreateEvent(EventAttributes,
> AManualReset, InitialState, n);
> end;
>
> With this and rebuilt RTL, packages and Co I'd ask you to test your code
> again and report back whether that solves the problem.
>
> Regards,
> Sven
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20161015/0c36a3a7/attachment.html>


More information about the fpc-pascal mailing list