Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-14 Thread Sven Barth via fpc-pascal
Am 10.09.2022 um 01:41 schrieb James Richters: I thought I would make my own IncArray() function: Procedure IncArray(Var TheArray); Begin SetLength(TheArray,Length(TheArray)+1); End; But I get a 'Type Mismatch' Any ideas how this could be done? Is this even possible without specifying

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread James Richters via fpc-pascal
>With FPC 3.2.0 and newer you can do "Concat(MyArray, [TheNewElement])" or (if >modeswitch ArrayOperators is active) "MyArray := MyArray + [TheNewElement]". I have a lot of arrays of records, but I just build the record into the array elements, like this:

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread Sven Barth via fpc-pascal
Luca Olivetti via fpc-pascal schrieb am Fr., 9. Sep. 2022, 15:29: > I don't know if it is more or less efficient than using a dynamic array > but I think it's nicer. > It internally uses a dynamic array as well, but duplicates the size with each growth and keeps track of a separate count of

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal schrieb am Fr., 9. Sep. 2022, 14:58: > I still end up with a lot of > SetLength(MyArray,Length(MyArray)+1); > Every time I want to add one more thing to the array. > With FPC 3.2.0 and newer you can do "Concat(MyArray, [TheNewElement])" or (if modeswitch

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread Luca Olivetti via fpc-pascal
El 9/9/22 a les 14:58, James Richters via fpc-pascal ha escrit: Is there some nifty way to increase a dynamic array by 1 that is more elegant? Inc(MyArray); would sure be nice If I know that I have to regularly add a single element to an array, instead of using a dynamic array I just use a

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread James Richters via fpc-pascal
I only recently learned about using Low() and High() and it is so much nicer than For I:= 0 to Length(MyArray)-1 Do That I actually went though all my code replacing the Length() - 1's with High() I still end up with a lot of SetLength(MyArray,Length(MyArray)+1); Every time I want to add one

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread Luca Olivetti via fpc-pascal
El 8/9/22 a les 16:53, Anthony Walter via fpc-pascal ha escrit: > curious minds want to know: what was the fix? In a separate part of the pool table initialization, I was precalculating the midpoints and normals for bumper rails. I had carelessly written this code:   for I := 0 to

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-09 Thread Adriaan van Os via fpc-pascal
Peter B via fpc-pascal wrote: I suggest trying without optimisations and/or using cmem, to see if that changes the outcome. I would rather use a system memory debugger to find the cause of the corruption. Regards, Adriaan van Os

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
> curious minds want to know: what was the fix? In a separate part of the pool table initialization, I was precalculating the midpoints and normals for bumper rails. I had carelessly written this code: for I := 0 to Length(Rails) do RailInit(Rails[I], I);

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread wkitty42--- via fpc-pascal
On 9/8/22 9:54 AM, Anthony Walter via fpc-pascal wrote: Please ignore this post. I fixed the issue. curious minds want to know: what was the fix? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!*

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
Please ignore this post. I fixed the issue. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Peter B via fpc-pascal
I suggest trying without optimisations and/or using cmem, to see if that changes the outcome. Also, if the array is corrupted prior to the setlength, then iterating the array with a trivial   with... Writeln(Color) or whatever, should trigger an exception. That could then be used at various

Re: [fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Jonas Maebe via fpc-pascal
On 2022-09-08 09:30, Anthony Walter via fpc-pascal wrote: Is there a known edge case issue connected to setting the length of dynamic arrays? No, and the location where you're getting the crash suggests an issue in your program that has corrupted the heap manager state. Jonas

[fpc-pascal] Access Violation When SetLength(DynArray, Value)

2022-09-08 Thread Anthony Walter via fpc-pascal
Is there a known edge case issue connected to setting the length of dynamic arrays? I have a program that simulates a billiards game, and during the rerack balls method of TPoolTable the number of pool balls on the table varies based on the rerack option used. Currently, I am having a problem

Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE

2020-11-13 Thread James Richters via fpc-pascal
It's not a really recent trunk, maybe from 8 months ago or so.. It is a really really large program, but it's something I've been working on for many years and I have not experienced this until just recently, and I haven't changed anything. Just for fun I tried compiling it on Win32 and

Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE

2020-11-12 Thread Vojtěch Čihák via fpc-pascal
fpc-pascal@lists.freepascal.org Datum: 12.11.2020 09:30 Předmět: Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE On 11/11/2020 22:26, James Richters via fpc-pascal wrote: > I'm suddenly getting an access violation when compiling after a file changed with the FPC text IDE: &g

Re: [fpc-pascal] Access Violation on second compile with FPC Text IDE

2020-11-12 Thread C Western via fpc-pascal
On 11/11/2020 22:26, James Richters via fpc-pascal wrote: I'm suddenly getting an access violation when compiling after a file changed with the FPC text IDE: Recompiling because of I:\Programming\Gcode\Mill\pastep.pas sysinit.pp(0) Error: Compilation raised exception internally Error: Compiler

[fpc-pascal] Access Violation on second compile with FPC Text IDE

2020-11-11 Thread James Richters via fpc-pascal
I'm suddenly getting an access violation when compiling after a file changed with the FPC text IDE: Recompiling because of I:\Programming\Gcode\Mill\pastep.pas sysinit.pp(0) Error: Compilation raised exception internally Error: Compiler exited Error: Access violation I haven't changed

Re: [fpc-pascal] access violation?

2018-07-31 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Di., 31. Juli 2018, 18:15: > > > > On Jul 30, 2018, at 11:08 PM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > If the method doesn't access Self then there is nothing you can do. > > Is this something the compiler team would be interested in

Re: [fpc-pascal] access violation?

2018-07-31 Thread Ryan Joseph
> On Jul 30, 2018, at 11:08 PM, Sven Barth via fpc-pascal > wrote: > > If the method doesn't access Self then there is nothing you can do. Is this something the compiler team would be interested in adding? I’d like to get an error when calling methods on nil. It’s seems like pretty basic

Re: [fpc-pascal] access violation?

2018-07-30 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Mo., 30. Juli 2018, 18:05: > > > > On Jul 28, 2018, at 2:03 AM, Sven Barth via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > The method you provided below would not fail anyway, because it doesn't > dereference Self. If you'd however access for example a

Re: [fpc-pascal] access violation?

2018-07-30 Thread Ryan Joseph
> On Jul 28, 2018, at 2:03 AM, Sven Barth via fpc-pascal > wrote: > > The method you provided below would not fail anyway, because it doesn't > dereference Self. If you'd however access for example a field of your class > then a check should be inserted inside the method. For some reason it

Re: [fpc-pascal] access violation?

2018-07-28 Thread Sven Barth via fpc-pascal
Am 27.07.2018 um 19:41 schrieb Ryan Joseph: On Jul 27, 2018, at 11:24 AM, Mattias Gaertner wrote: You can't if you compile with -CR. The RTL is not compiled with objectchecks, so it works there. According to this test not only can you call methods on nil objects but it calls the method

Re: [fpc-pascal] access violation?

2018-07-27 Thread Ryan Joseph
> On Jul 27, 2018, at 2:17 PM, Mattias Gaertner > wrote: > > You are right. I just tested myself. > Either I'm confusing the flag or it has been changed. > Once upon a time Lazarus used the same trick and I had to change the > code as some users wanted use the flag. Do you need me to file a

Re: [fpc-pascal] access violation?

2018-07-27 Thread Mattias Gaertner
On Fri, 27 Jul 2018 11:41:51 -0600 Ryan Joseph wrote: >[...] > How do I disable this? I just ran this test program with -CR and I still > calls the method statically. You are right. I just tested myself. Either I'm confusing the flag or it has been changed. Once upon a time Lazarus used the

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 3:22 PM, Michael Van Canneyt wrote: > In order to have robust, maintainable and portable (to either other >> platform or even language) a developer should respect high-level rules and >> never depend on low-level rules to be the same on any platform. >> > > Do I have

Re: [fpc-pascal] access violation?

2018-07-27 Thread Michael Van Canneyt
On Fri, 27 Jul 2018, Dmitry Boyarintsev wrote: From high-level (OOP) such actions are not welcomed (and are enforced using -CR in case of FPC). In order to have robust, maintainable and portable (to either other platform or even language) a developer should respect high-level rules and

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 1:06 PM, Ryan Joseph wrote: > I had no idea you could do that! > Obviously, it speaks high of your abilities ;) You've been able to accomplish your tasks without use of hacks (of any kind), playing strict by the rules. I’m totally confused now. Since when was it ok to

Re: [fpc-pascal] access violation?

2018-07-27 Thread Ryan Joseph
> On Jul 27, 2018, at 11:24 AM, Mattias Gaertner > wrote: > > You can't if you compile with -CR. > The RTL is not compiled with objectchecks, so it works there. > >> According to this test not only can you call methods on nil objects but >> it calls the method statically (like a class

Re: [fpc-pascal] access violation?

2018-07-27 Thread Mattias Gaertner
On Fri, 27 Jul 2018 11:06:11 -0600 Ryan Joseph wrote: >[...] > I’m totally confused now. Since when was it ok to call methods on nil > objects? You can't if you compile with -CR. The RTL is not compiled with objectchecks, so it works there. > According to this test not only can you call

Re: [fpc-pascal] access violation?

2018-07-27 Thread Ryan Joseph
> On Jul 27, 2018, at 10:16 AM, Dmitry Boyarintsev > wrote: > > type > TRobust = class(TObject) > public > v : Integer; > procedure RobustMethod; > end; > > procedure TRobust.RobustMethod; > begin > if Self = nil then Exit; // remove or comment out this line to start >

Re: [fpc-pascal] access violation?

2018-07-27 Thread Dmitry Boyarintsev
On Fri, Jul 27, 2018 at 11:15 AM, Ryan Joseph wrote: > I never use Free directly so I had no idea. How is that even accomplished > in the language? I thought it was just a method and behaved accordingly. > > If it is magic then how do we call other methods on nil objects? There are > times that

Re: [fpc-pascal] access violation?

2018-07-27 Thread Ryan Joseph
> On Jul 26, 2018, at 11:36 PM, Michael Van Canneyt > wrote: > > It is by design. > > And - OMG !! - it is even documented: I never use Free directly so I had no idea. How is that even accomplished in the language? I thought it was just a method and behaved accordingly. If it is magic

Re: [fpc-pascal] access violation?

2018-07-27 Thread Victor Campillo
On 27/07/18 07:36, Michael Van Canneyt wrote: It is by design. And - OMG !! - it is even documented: https://www.freepascal.org/docs-html/current/rtl/system/tobject.free.html There is no need to search the docs, it is even more quick just jump to the implementation of free and see what it

Re: [fpc-pascal] access violation?

2018-07-26 Thread Michael Van Canneyt
On Thu, 26 Jul 2018, Ryan Joseph wrote: I was doing some testing today (Mac) and discovered that calling Free on a nil object didn’t cause a EAccessViolation exception. Why doesn’t that crash? It is by design. And - OMG !! - it is even documented:

[fpc-pascal] access violation?

2018-07-26 Thread Ryan Joseph
I was doing some testing today (Mac) and discovered that calling Free on a nil object didn’t cause a EAccessViolation exception. Why doesn’t that crash? var c: TObject; begin c := nil; c.Free; Regards, Ryan Joseph

Re: [fpc-pascal] Access violation in an empty project declaring heaptrc

2016-03-03 Thread silvioprog
On Thu, Mar 3, 2016 at 4:05 AM, Sven Barth wrote: [...] > That is the memory that had been used before the memory manager of the > heaptrc unit had been setup. Remember that there's first the System unit > initialization and only then the initialization of the

Re: [fpc-pascal] Access violation in an empty project declaring heaptrc

2016-03-02 Thread Sven Barth
Am 03.03.2016 03:07 schrieb "silvioprog" : > Now, if you compile and run this project below with -gh: > > program project1; > > {$mode objfpc}{$H+} > > begin > end. > > You will get: > > Heap dump by heaptrc unit > 47 memory blocks allocated : 1173/1280 > 47 memory blocks

[fpc-pascal] Access violation in an empty project declaring heaptrc

2016-03-02 Thread silvioprog
Hello, Just create a project like this: program project1; {$mode objfpc}{$H+} uses heaptrc; begin end. Now, compile and try to run that, you will get this error: Heap dump by heaptrc unit 0 memory blocks allocated : 0/0 0 memory blocks freed : 0/0 0 unfreed memory blocks : 0 True heap

[fpc-pascal] Access violation that I do not understand while creating a class instance

2012-01-23 Thread ik
Hello, In the following code ( https://github.com/ik5/redit_client.fpc/blob/master/tests/test_parser.lpr#L55), when I point, I have access violation when trying to create TRedisErrorReturnType.Create It does not happen for TRedisStatusReturnType.Create for example, that have the same parent as

[fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread Roland Turcan
Hello all, It often happens to me, that during compilation FPC raises an exception and often is enough just to clean up directories where are *.o and *.ppu located. Sometimes it depends also on a problem in my code, but it is very difficult to distinguish where the problem is. Can I build FPC

Re[2]: [fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread Roland Turcan
Hello Jonas, At first, thank you for your reply. 12.3.2009 10:09 - Jonas Maebe jonas.ma...@elis.ugent.be JM Roland Turcan wrote on do, 12 mrt 2009: It often happens to me, that during compilation FPC raises an exception and often is enough just to clean up directories where are *.o and

Re: Re[2]: [fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread Jonas Maebe
Roland Turcan wrote on do, 12 mrt 2009: 12.3.2009 10:09 - Jonas Maebe jonas.ma...@elis.ugent.be JM Roland Turcan wrote on do, 12 mrt 2009: Can I build FPC with debug information to get more details where the exception occured and not to get only addresses from stack, but nothing more. JM

Re: Re[2]: [fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread Tomas Hajny
On Thu, March 12, 2009 12:17, Roland Turcan wrote: 12.3.2009 10:09 - Jonas Maebe jonas.ma...@elis.ugent.be JM Roland Turcan wrote on do, 12 mrt 2009: It often happens to me, that during compilation FPC raises an exception and often is enough just to clean up directories where are *.o and

Re: Re[2]: [fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread Tomas Hajny
On Thu, March 12, 2009 12:51, Jonas Maebe wrote: Roland Turcan wrote on do, 12 mrt 2009: . . I have longer time a difficulty to solve this message when I try to build fpc with sudo make clean all: Makefile:2279: *** No libgdb.a found, supply NOGDB=1 to disable debugger support. of

Re: [fpc-pascal] Access violation during compilation and linking

2009-03-12 Thread C Western
Jonas Maebe wrote: Roland Turcan wrote on do, 12 mrt 2009: 12.3.2009 10:09 - Jonas Maebe jonas.ma...@elis.ugent.be JM Roland Turcan wrote on do, 12 mrt 2009: Can I build FPC with debug information to get more details where the exception occured and not to get only addresses from stack, but