k-john-gough / gpcp

Gardens Point Component Pascal is an implementation of the Component Pascal Language (CP). There are implementations for both the CLR and the JVM.
Other
59 stars 16 forks source link

Can't compile Form.cp example #27

Closed 1997tn closed 1 year ago

1997tn commented 1 year ago

gpcp.exe has stopped working

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
   at GPBinFiles.GPBinFiles.findOnPath(Char[] pathName, Char[] fileName) in c:\U
sers\john\CurrentProjects\CVS-GPCP-NET\sources\libs\csharp\GPBinFiles.cs:line 95

   at NewSymFileRW.SymFileReader.Parse(BlkId scope) in NewSymFileRW.cp:line 1162

   at NewSymFileRW.ImpResScope.ReadThisImport(BlkId imp) in NewSymFileRW.cp:line
 2147
   at NewSymFileRW.NewSymFileRW.WalkImports(ScpSeq& imps, BlkId modI) in NewSymF
ileRW.cp:line 2182
   at CPascalP.CPascalP.ImportList(BlkId modScope) in CPascalP.cp:line 467
   at CPascalP.CPascalP.CPmodule() in CPascalP.cp:line 235
   at CPascalP.CPascalP.Module() in CPascalP.cp:line 3437
   at CPascalP.CPascalP.Parse() in CPascalP.cp:line 3457
   at CPascal.CPascal.Compile(Char[] nam, Int32& retVal) in CPascal.cp:line 138
   at gpcp.gpcp..CPmain(String[] A_0) in gpcp.cp:line 42

This is my environment variables:

set CROOT=%userprofile%\Downloads\gpcp-NET set PATH=%PATH%;%CROOT%\bin set CPSYM=.;%CROOT%\symfiles;%CROOT%\symfiles\NetSystem

k-john-gough commented 1 year ago

Hi 1997tn

Ok. Same problem as last time. Not only RTS.dll needs to be in the same directory as your executable but ALL the libraries that your program used (either explicitly or indirectly) that are not part of the .NET runtime. That means: RTS.dll, GPFiles.dll, GPBinFiles.dll, GPTextFiles.dll and so on.

Here is a batch file, CopyNetLibs.bat from the sources directory of the binary distribution of GPCP.

@echo off REM REM Load up given directory with REM {RTS|GP*Files}.{pdb|dll} files REM if defined CROOT goto :more echo CROOT is not defined, terminating goto :EOF

:more if NOT "%1"=="" goto :copy echo Usage: CopyNetLibs target_bin_directory goto :EOF

:copy copy %CROOT%\bin\RTS. %1 copy %CROOT%\bin\GPFiles.* %1

Notice that this copies not just the executables .dll, but also the debug symbol files .pdb.

Hope this helps! Cheers John


From: 1997tn @.> Sent: Tuesday, 10 January 2023 5:21 AM To: k-john-gough/gpcp @.> Cc: Subscribed @.***> Subject: [k-john-gough/gpcp] Can't compile Form.cp example (Issue #27)

gpcp.exe has stopped working

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at GPBinFiles.GPBinFiles.findOnPath(Char[] pathName, Char[] fileName) in c:\U sers\john\CurrentProjects\CVS-GPCP-NET\sources\libs\csharp\GPBinFiles.cs:line 95

at NewSymFileRW.SymFileReader.Parse(BlkId scope) in NewSymFileRW.cp:line 1162

at NewSymFileRW.ImpResScope.ReadThisImport(BlkId imp) in NewSymFileRW.cp:line 2147 at NewSymFileRW.NewSymFileRW.WalkImports(ScpSeq& imps, BlkId modI) in NewSymF ileRW.cp:line 2182 at CPascalP.CPascalP.ImportList(BlkId modScope) in CPascalP.cp:line 467 at CPascalP.CPascalP.CPmodule() in CPascalP.cp:line 235 at CPascalP.CPascalP.Module() in CPascalP.cp:line 3437 at CPascalP.CPascalP.Parse() in CPascalP.cp:line 3457 at CPascal.CPascal.Compile(Char[] nam, Int32& retVal) in CPascal.cp:line 138 at gpcp.gpcp..CPmain(String[] A_0) in gpcp.cp:line 42

— Reply to this email directly, view it on GitHubhttps://github.com/k-john-gough/gpcp/issues/27, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEC5EFDKZWO3V6WM77IUKG3WRRQMZANCNFSM6AAAAAATVZLRNY. You are receiving this because you are subscribed to this thread.Message ID: @.***>

1997tn commented 1 year ago

@k-john-gough Your CopyNetLibs.bat script doesn't work. Instead of creating a bin directory, it created a file named bin.

1997tn commented 1 year ago

As I'm too lazy to populate my own bin directory, I use something like this instead:

gpcp /bindir=%CROOT%\bin Form.cp

(note: binaries output will be %CROOT%\bin not the current directory).

It worked for Hello.cp but not Form.cp. This is the error message:

Unhandled Exception: System.Exception: Overflow: Use -hsize > current 8209

cfbsoftware commented 1 year ago

Read the Gardens Point Component Pascal Release Notes before you proceed any further. For this particular issue refer to Section 2.7 Setting the hash table size

1997tn commented 1 year ago

Read the Gardens Point Component Pascal Release Notes before you proceed any further. For this particular issue refer to Section 2.7 Setting the hash table size

Thank you. Btw, I notice the document said the maximum for hsize is 66000 but when I used this value gpcp told me hsize must be in the range 0..65000

k-john-gough commented 1 year ago

Thanks Chris. The error message "hSize must be in the range 0..65000" is slightly inaccurate. The particular hashing algorithm that GPCP uses requires a number of elements that must be a prime number.

The NameTable.cp file has a table of primes that GPCP chooses from. It chooses the prime from the table that is at least as great as the number requested. The largest number in the table is 65521, which is large enough to process System.Windows.Forms, the largest symbol file in the library. Although 1997tn's program is small it imports SWF, which blows up the default-sized table.

If you want the gory details, any requested hSize bigger that 46691 gets a table with 65521 elements. So if you ask for 65000 you will get tthe maximum-size table anyway.

So, yes, the error message is misleading, but the alternative would be to let people say /hSize=1000000 and think that this is what you get. Of course, with modern machines it would be fine to have larger sized tables, but no-one has ever reported a program which overflows the current largest size. John


From: 1997tn @.> Sent: Friday, 20 January 2023 2:42 AM To: k-john-gough/gpcp @.> Cc: K John Gough @.>; Mention @.> Subject: Re: [k-john-gough/gpcp] Can't compile Form.cp example (Issue #27)

Closed #27https://github.com/k-john-gough/gpcp/issues/27 as completed.

— Reply to this email directly, view it on GitHubhttps://github.com/k-john-gough/gpcp/issues/27#event-8313998972, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEC5EFBPEWMLQ64CPJNHVNDWTFVG3ANCNFSM6AAAAAATVZLRNY. You are receiving this because you were mentioned.Message ID: @.***>