hydrobyte / McJSON

A Delphi / Lazarus / C++Builder simple and small class for fast JSON parsing.
MIT License
58 stars 20 forks source link

Range check error #5

Closed totyaxy closed 1 year ago

totyaxy commented 1 year ago

Hi!

This simple code cause range check error (in debug mode) at line 1155 (Lazarus 2.2.4 official, x64 on windows)

procedure TForm1.Button1Click(Sender: TObject); var N: TMcJsonItem; begin N := TMcJsonItem.Create; try N.AsJSON := '{"o": {"k1":"v1", "k2":"v2"}}'; ShowMessage(N.Path('o.k2').AsString); finally N.Free; end;

end;

hydrobyte commented 1 year ago

Hi!

I'm not able to reproduce this error with Lazarus version 2.3.0.

Could you debug with 2.2.4 and interpret the range exception error in line 1155? In other words, describe how the code reach a range error with this example?

Regards,

Marcelo.

totyaxy commented 1 year ago

Hi!

I'm not able to reproduce this error with Lazarus version 2.3.0.

I tested under 2.3.0, but the result is same as with 2.2.4.

Try MCJson version from github.

Could you debug with 2.2.4 and interpret the range exception error in line 1155? In other words, describe how the code reach a range error with this example?

I'm not sure I understand you, to tell the truth, in my project I always got range check error, if I use "path". So I created a simple example code, see in the first message in this topic.

Debug mode mean I select Debug Mode in project options/compiler.

Thank you!

hydrobyte commented 1 year ago

Hi,

Please could you test with today's update? I've tested with Lazarus 2.2.0 and it has worked fine.

Note: use the .lpi file that was added.

Also, check if your Decimal Separator is "." within Windows' Region configuration.

Regards,

Marcelo

totyaxy commented 1 year ago

Hi!

Nothing changed with this update. I got range check errors.

Lazarus OFFICIAL 2.2.4 x64 on Windows x64

Do you know what the build mode is?

Project/project options/compilation and linking/build modes. Default is "default". Without debug mode, you can't got range check error.

Thank you!

hydrobyte commented 1 year ago

Hi,

I know what Debug mode is.

Also, could you test the code "as it is" and report some bug? Or, even better, provide a pull request for reparation?

What I think is that your Lazarus installation is broken.

I was able to test this code without problems in two versions, even with 2.2.0 that was nor originally used.

Regards,

I

totyaxy commented 1 year ago

Hi!

My Lazarus install is clean, I installed only for you from te official installer, to test this great library. Because otherwise I use Lazarus trunk 2.3.0 version via fpcupdeluxe.

If I said this error is present, this mean this error is present. Range check error problem for me, because my project is clean, and I got errors only from this library and this bothers me and it indicates a malfunction somewhere in your library.

Thank you for your cooperation!

hydrobyte commented 1 year ago

Hi,

I just ask you to test in Default compilation and report any result or memory leaking bug.

About Range Check, OK, I'll check it again and fix any improper access.

In mean while, try to improve and send a pull request.

Best.

totyaxy commented 1 year ago

In mean while, try to improve and send a pull request.

I can't send a pull request, because I already synced. I do not plain to modify your great code, I think your programming knowledge is better than mine.

totyaxy commented 1 year ago

As I see, range check error is gone, thank you!