Re: [fpc-pascal] First pas2js public release

2017-12-17 Thread Snorkl e
Wow, nice job 

On Dec 17, 2017 2:29 AM, "Michael Van Canneyt" 
wrote:

>
>
> On Sun, 17 Dec 2017, Sven Barth via fpc-pascal wrote:
>
> Am 17.12.2017 08:01 schrieb "code dz" :
>>
>> good news & thanks for the effort
>>
>> is it similar to Emscripten ?
>>
>>
>> Not really. Emscripten (and WebAsm) has the goal to convert native
>> programs
>> that rely on pointers. It is essentially an assembly language in
>> JavaScript. Pas2JS is on the other hand a transpiler and does not - as
>> Michael explained - support native features like pointers. Also if you
>> look
>> at the generated code you can still understand it without much effort.
>>
>
> Completely correct.
>
> Michael.
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FreePascal and MySQL ?

2017-11-20 Thread Snorkl e
You don't need to use a stream just do
Dataset.fieldbyname('somecolumn').asstring:=mystringlist.text


On Nov 20, 2017 10:02 AM, "Terry A. Haimann"  wrote:

> Hello,
>
> This is probably a dumb question.  But I have data in a tstringlist that
> I want to upload into a MediumText MySQL column.  It looks to me as if
> you do something like:
>
> Stream := TMemoryStream.Create;
> MySL.SaveToStream(Stream);
> Blobfield(BcfQuery.FieldByName('JobMemo')).
> LoadFromStream(Stream);
>
> But what I don't understand is how I indicate what row to add the
> MediumText field to.  Is there some way to combine this with an insert
> or update statement.  I have done a lot in the past with MySQL and
> FreePascal, but I have mostly or entirely worked with standard columnar
> data, i.e. (Strings, floats and integers).
>
> Thanks in advance,
>
> Terry H.
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Running Freepascal programs on other computers

2017-06-28 Thread Snorkl e
Are you by chance running it from a shared smb folder or something like
that?  I run all my fpc apps on Windows 10, but from a local drive and
don't get warnings.

On Jun 28, 2017 11:56 AM, "James Richters" 
wrote:

When I run any freepascal program that I compiled on my windows 10 desktop
computer on any other PC, I always get a warning:

We could not verify who created this file, are you sure you want to run
this file?



When I search for a way to fix this, I get a bunch of results telling how
to bypass the windows protection and let the file run without the warning,
but I don’t see any results on how to actually properly take care of this,
so the program actually CAN be properly verified and run without the
warning and without modifying the windows installation.



Does anyone know how this is normally achieved, and how to implement this
with my freepascal console applications?



James



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-18 Thread Snorkl e
Synapse and fpc works great with serial port, I have a daemon I wrote 4
years ago that reads serial data from a phone PBX runs 24X7 and never an
issue.

On Jun 18, 2017 11:17 AM, "Bo Berglund" <bo.bergl...@gmail.com> wrote:

> On Sun, 18 Jun 2017 09:46:06 -0500, Snorkl e
> <tony.cad...@gmail.com> wrote:
>
> >Couldn't you read the serial port data and then stream it with Synapse to
> >the remote location?
> >You can use Synapse to read the serial port data and sent via TCP/IP.
> >
>
> Probably, but I was hoping for some ready-made example to get going a
> bit faster...
> I did another piece of software a year or so ago only involving
> TCP/IP, also for remote control, but then I used an Indy TCP client
> component.
> My problem is getting my head around serial port handlers, which I
> have so-so experience of in the past. No RS232 work with FPC/Lazarus
> earlier and in Delphi I used AsyncPro components, but these are so
> complex that one is lost amongst all properties to set...
>
> I would like a dead simple serial component where I could just specify
> the comm parameters (baud, start/stop bits, handshaking and port) then
> just open the connection and wait for receive *events*.
>
> Yes, it is easier for me to have components with event generation on
> data reception rather than using blocking components, which I must
> make threads for and then figure out how to channel the data from the
> thread into the main application...
>
>
> --
> Bo Berglund
> Developer in Sweden
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-18 Thread Snorkl e
Couldn't you read the serial port data and then stream it with Synapse to
the remote location?
You can use Synapse to read the serial port data and sent via TCP/IP.



On Jun 18, 2017 2:05 AM, "Bo Berglund"  wrote:

> I need to implement a serial to TCP gateway in order to communicate
> between a Windows based control software and a system controller box.
> The software and the controller only talk serial to each other and the
> protocol is proprietary and binary.
> Now I have a situation where the controller is on a remote location
> many thousands of km away from here.
> I have managed to get some help on the remote site to hook up the
> controller serial port to a serial to USB cable plugged into a
> Raspberry Pi, which I can reach via VPN from here. So I installed
> serial2net on the RPi, making it publish the serial port as a TCP port
> (#2091). This part works OK, so whatever is sent on the TCP socket
> connection gets transferred to the RS232 serial line and vice versa.
>
> So far so good, but now I also need some kind of serial port to TCP
> converter on the Windows 7 PC I use in my end, which is handling the
> VPN connection.
>
> So I wonder if there are any FPC examples around for conversion serial
> to TCP (where the TCP part is a client rather than a server), which
> can compile on Windows. I cannot use any RPi in this end because I
> cannot get the RPi to connect by VPN to the remote location...
>
> Ready made example or suggestions on how to go about writing a
> converter in FPC are welcome!
>
>
> --
> Bo Berglund
> Developer in Sweden
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC clean room project

2017-01-03 Thread Snorkl e
They might with a change of ownership, who knows these days,  but the fact
they did use it in the past would not look good for any litigation from
some bottom feeder.

On Jan 3, 2017 4:36 PM, "Sven Barth"  wrote:

> Am 03.01.2017 19:02 schrieb "Dmitriy Pomerantsev" :
> >
> > Doesn't matter since FPC license allowing that.
>
> You don't get the point, do you? I don't think they'd use FPC themselves
> if they'd sue it the next time around.
>
> Regards,
> Sven
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC clean room project

2017-01-02 Thread Snorkl e
Maybe it's  Niklaus Wirth, could be he's broke and decided it's time to
collect license fees like Microsoft does with Android LOL just kidding.

On Jan 2, 2017 4:07 PM, "Sven Barth"  wrote:

Am 02.01.2017 19:15 schrieb "Santiago A." :
> Nevertheless, as someone has pointed, Embarcadero hasn't make any legal
movement. Maybe because it thinks there is no legal base; or maybe because
it doesn't care that much and thinks it's not worth the bad publicity.

Not to mention that for a little while Embarcadero even used Free Pascal
for their iOS support before they had their own compiler.

Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC clean room project

2017-01-02 Thread Snorkl e
My question is why does this person even care to make such accusations? For
one some of the routines in the run time are extremely generic and could
easily be written exactly the same way and only way to prove it is if
comments made by original coder are still in place.  Sounds like a waste of
time witch hunt to even entertain such thoughts without definitive proof
and if said person holds back on such information that means they are
interested in bottom feeder litigation. Shameful if you ask me.

On Jan 1, 2017 11:23 PM, "Mr Bee"  wrote:

> Hi all,
>
> There's someone accusing that Free Pascal (and some parts of Lazarus) is
> just a reverse engineering of Delphi. Even he said some codes of FPC/Laz
> are taken from Delphi (and Kylix). This is a serious allegation.
>
> I know that isn't true. Or is it? ;)
>
> Can anybody elaborate on this? I'd like to debunk the allegation but I
> don't know where to start and the evidence for it.
>
> Thank you.
>
> Regards,
>
>
> –Mr Bee
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] what is the possible cause of EPrivilege Privileged instruction ?

2016-10-26 Thread Snorkl e
Your not using teventobject in your threads are you?
There is a bug in the RTL which could cause weird issues with threads if
you are using teventobject.create.

On Oct 26, 2016 10:58 AM, "Dennis"  wrote:

> I have a multi threaded program which executes a list of tasks in real
> time.
> It is difficult to debug with a debugger on this program (since debugging
> will pause the execution which will be messy for this application).
>
> So, I log the exceptions to a log file and I found this exception:
> EPrivilegePrivileged instruction
>
> What could possibly raise this exception?
>
> My program is win 32 from Lazarus 1.7  FPC 3.1.1
> and running on Win 7 64 bit.
>
> thanks in advance.
>
> Dennis
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-15 Thread Snorkl e
Sven,
Just a fyi, the mantis bug report form would not let me pick a Severity
<http://bugs.freepascal.org/view_all_set.php?sort=severity=DESC=2>
so its showing up as minor.

On Sat, Oct 15, 2016 at 10:36 AM, Snorkl e <tony.cad...@gmail.com> wrote:

> Sven,
> Bug report added:  http://bugs.freepascal.org/view.php?id=30747
>
> Have a great weekend :-)
>
> On Sat, Oct 15, 2016 at 3:30 AM, Sven Barth <pascaldra...@googlemail.com>
> wrote:
>
>> Am 15.10.2016 09:52 schrieb "Snorkl e" <tony.cad...@gmail.com>:
>> >
>> > 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.
>>
>> Thank you for confirming.
>>
>> > 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?
>> >
>>
>> Please file a bug report so that it's not forgotten. Considering that
>> it's a serious bug regarding events (and maybe others that have names, I'll
>> have to check that) I hope that I'll get approval to have it merged to
>> 3.0.x.
>>
>> Regards,
>> Sven
>>
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>>
>
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-15 Thread Snorkl e
Sven,
Bug report added:  http://bugs.freepascal.org/view.php?id=30747

Have a great weekend :-)

On Sat, Oct 15, 2016 at 3:30 AM, Sven Barth <pascaldra...@googlemail.com>
wrote:

> Am 15.10.2016 09:52 schrieb "Snorkl e" <tony.cad...@gmail.com>:
> >
> > 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.
>
> Thank you for confirming.
>
> > 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?
> >
>
> Please file a bug report so that it's not forgotten. Considering that it's
> a serious bug regarding events (and maybe others that have names, I'll have
> to check that) I hope that I'll get approval to have it merged to 3.0.x.
>
> Regards,
> Sven
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-15 Thread Snorkl e
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 <pascaldra...@googlemail.com>
wrote:

> Am 14.10.2016 20:31 schrieb "Snorkl e" <tony.cad...@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@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-14 Thread Snorkl e
Hi Sven,
Yes I can try that this weekend sometime and will respond with results,.
Thanks for taking a look at that 

On Oct 14, 2016 3:41 PM, "Sven Barth" <pascaldra...@googlemail.com> wrote:

> Am 14.10.2016 20:31 schrieb "Snorkl e" <tony.cad...@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@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-14 Thread Snorkl e
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.

On Oct 14, 2016 1:23 PM, "José Mejuto" <joshy...@gmail.com> wrote:

> El 14/10/2016 a las 20:11, Snorkl e escribió:
>
> Since I solved it by giving the name param a giud, the next thing to ask
>> is why does teventobject fail kind of silently when the name parm is
>> blank over time?
>>
>
> Hello,
>
> To me it looks like a memory corruption, in your program or in the
> library. Have you checked the code with heaptrc activated ?
>
>
> --
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-14 Thread Snorkl e
Hi Sven,


Yes the events get destroyed in the threads destructor. I verified they
were being freed up.


It would usually happen when lots of connect disconnects happened in a
short time.

Once that error 161 popped it could not be recovered from, all new
connections would fail on the teventobject.create.


It would also happen much sooner when compiled as 32bit.


I guess as long a using the GUID works long term it shouldn't be an issue.



"Do you destroy the event again once it's no longer used? Of course if you
require the events the whole time it might indeed be a Windows limitation.


Regards,

Sven"
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-14 Thread Snorkl e
Hi Tomas,

TEventobject.create is the only thing called in the thread constructor, and
teventobject.create is indeed calling a API function in order to create the
event.  There is no other way to find out if teventobject.create failed as
teventobject.handle always has a value even if it fails.
So what I am getting at is its extremely likely getlasterror applies even
though it does not call  winapi directly.

Since I solved it by giving the name param a giud, the next thing to ask is
why does teventobject fail kind of silently when the name parm is blank
over time?

Also keep in mind this is third party code, so I don't really know why they
used teventobject as much as they did, I would imagine they didn't want to
use critical sections all over the place.

And yes the event object does get destroyed when the thread finishes.
I understand what your saying about the differences between getlasterror
and getlastoserror.

I do appreciate the comments :-)

On Oct 14, 2016 12:28 PM, "Tomas Hajny" <xhaj...@hajny.biz> wrote:

> On Fri, October 14, 2016 17:44, Snorkl e wrote:
>
>
> Hi,
>
> > Hi, actually getlasterror only applies to the calling thread,
> > getlastOSerror is the one not to use.
> > Anyway I think I found the solution.
>  .
>  .
>
> I'm glad that you found potential reason of the problem, but your
> assumption regarding GetLastError and GetLastOSError is not entirely
> correct. You're right that GetLastError returns the last error in the
> current thread, because that is written in the respective MSDN
> documentation. I don't think that this is in contradiction to the
> information from Jonas though.
>
> Moreover, the only difference between GetLastError and GetLastOSError is
> the fact that GetLastError is direct part of the MS Windows API (and thus
> it behaves exactly as described in MSDN, but it is platform-specific),
> whereas GetLastOSError is the FPC RTL abstraction for returning error
> information from the underlying operating system (available across
> different platforms). As such, you should rely on the behaviour of
> GetLastOSError only to the level documented in the FPC documentation (in
> other words, certain aspects described in MSDN documentation for
> GetLastError may not be valid for GetLastOSError on all FPC supported
> platforms due to differences in error handling on different platforms).
>
> As an example, direct calls to Windows API bypassing FPC RTL and resulting
> in an error would change the value returned by GetLastOSError on MS
> Windows, whereas direct calls to OS/2 API bypassing FPC RTL and resulting
> in an error would _not_ change the value returned by GetLastOSError on
> OS/2.
>
> The implementation of GetLastOSError for MS Windows (Win32 or Win64)
> consists of a direct call to GetLastError and thus the same caveats apply
> for them on that platform.
>
> Tomas
>
>
> >
> > On Oct 14, 2016 9:23 AM, "Jonas Maebe" <jonas.ma...@elis.ugent.be>
> wrote:
> >
> >> On 14/10/16 02:43, Snorkl e wrote:
> >>
> >>> Anyway, I am using a third party SFTP server lib and it creates a
> >>> thread
> >>> inherited from tthread and in the create event of the tthread
> >>> descendant
> >>> it does this:
> >>> (It uses this thread to read and write data on the socket)
> >>>
> >>> FDataAvailable := TEvent.Create(nil, True, False, '');  //tevent maps
> >>> to
> >>> teventobject
> >>>
> >>> {$IFDEF MSWINDOWS}
> >>>   lasterr:=GetLastError;
> >>>
> >>
> >> GetLastError() will return the error code of the last Windows API call
> >> that has been performed. I doubt TEvent.Create() guarantees not to call
> >> any
> >> Windows API's between creating an event using a Windows event and
> >> returning. E.g., it might allocate or free memory in between, or the FPC
> >> RTL may have done that in the context of handling the constructor call.
> >>
> >> You should only call GetLastError() immediately after calling a Windows
> >> API function yourself. In any other case, you cannot know what may have
> >> transpired in between.
> >>
> >>
> >> Jonas
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-14 Thread Snorkl e
Hi, actually getlasterror only applies to the calling thread,
getlastOSerror is the one not to use.
Anyway I think I found the solution.
Just for kicks I put in a name with a / I.e /test_name and getlasterror
came back with the same error.  So the API is being called somewhere with
teventobject.create, anyway instead of leaving name blank I put a giud in
for the name and low and behold the error stopped.  It appears there is a
limit or a bug on creating unnamed events from a single process.   When you
leave name blank the os must be creating a unique name somehow and it has
some issue with a lot of them being created and destroyed. When I compiled
as 64bit it took much longer for the error to happen.  After I used the
guid for the event name I stress tested the server with 10s of thousands of
connection and disconnecting and that error never happened again.

So windows limit or bug? Or could it be a bug in  FPC?

On Oct 14, 2016 9:23 AM, "Jonas Maebe" <jonas.ma...@elis.ugent.be> wrote:

> On 14/10/16 02:43, Snorkl e wrote:
>
>> Anyway, I am using a third party SFTP server lib and it creates a thread
>> inherited from tthread and in the create event of the tthread descendant
>> it does this:
>> (It uses this thread to read and write data on the socket)
>>
>> FDataAvailable := TEvent.Create(nil, True, False, '');  //tevent maps to
>> teventobject
>>
>> {$IFDEF MSWINDOWS}
>>   lasterr:=GetLastError;
>>
>
> GetLastError() will return the error code of the last Windows API call
> that has been performed. I doubt TEvent.Create() guarantees not to call any
> Windows API's between creating an event using a Windows event and
> returning. E.g., it might allocate or free memory in between, or the FPC
> RTL may have done that in the context of handling the constructor call.
>
> You should only call GetLastError() immediately after calling a Windows
> API function yourself. In any other case, you cannot know what may have
> transpired in between.
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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

2016-10-13 Thread Snorkl e
Hi, Just wondering if anyone has any ideas.
I am using FPC 3.0 by the way.

Anyway, I am using a third party SFTP server lib and it creates a thread
inherited from tthread and in the create event of the tthread descendant it
does this:
(It uses this thread to read and write data on the socket)

FDataAvailable := TEvent.Create(nil, True, False, '');  //tevent maps to
teventobject

{$IFDEF MSWINDOWS}
  lasterr:=GetLastError;
  if (lasterr <> 0)   then
begin
 msg:=SysErrorMessage(lasterr);
 SetLastError(NO_ERROR);  //<--I added this an attempt to recover
from the error
 raise Exception.Create(SCannotCreateEvent+':'+msg);
end;
{$ENDIF}


after the call to FDataAvailable it always has a handle pointer, but what
seems very random like GetLastError will return non 0 always with code 161
which is invalid path name.
When this occurs all new connections will fail, the process becomes useless
and I have stop it.

If I remove the call to getlasterror and ignore it, the threads go into
100% cpu usage in the while loops used to read or write when the error does
occur.

Users can actually connect but not transfer any data.

Also when I compile as 64bit the odds of this happening go way down and I
can sometimes transfer 1 files before it happens, on 32bit it happens
much more frequently.

Apparently this is only a issue on Windows hence the compiler defs for
MSWINDOWS.

I did report this issue to the vendor and they said they are looking into
it but that could take months.

Anyone have any ideas one why teventobject.create is failing? Even though
it does have a hander pointer is it possible it's somehow a bad pointer?

This happens on windows 7 through 10 and even on PCs with lots of
resources(32gb ram, SSD hard drive and no corporate bloatware.

Thanks,

T
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Delphi may have Linux support next year

2016-08-30 Thread Snorkl e
Big deal, we can do all that and more with Lazarus and FPC

On Aug 30, 2016 12:16 AM, "Anthony Walter"  wrote:

> I don't know it's been posted here yet, but over at the Embarcadero
> community website a new roadmap has been published.
>
> http://community.embarcadero.com/article/news/16418-
> product-roadmap-august-2016
>
> Interestingly it seems like Delphi might support Linux next year. From the
> wording it would seem to indicate that the compiler will be able to target
> Linux 64 bit, the RTL will work, along with some data access components.
>
> Translation: Delphi users who get this updated version next year will be
> able to write and compile CLI programs and/or shared libraries on AMD64
> enabled Windows, OSX, and Linux computers. Don't expect a visual library or
> Firemonkey support for Linux anytime soon if ever.
>
> What might be interesting is if the Delphi command line compiler could run
> on AMD64 Linux, but that's yet to be seen.
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal