libera/#ecl - IRC Chatlog
Search
15:44:55
AmateurLisper
I have a weird issue that I would appreciate help on that only occurs in 64 bit ECL on Windows, but does occur whether I compile it with MSYS2 MinGW64 or Visual Studio Community.
15:45:02
AmateurLisper
Error does not occur if I use Cygwin64. Error does not occur in SBCL, CCL, or 32 bit ECL regardless of how I compile it, or whether I run it on Linux or Windows.
15:45:16
AmateurLisper
I can believe I am making a mistake in how I compile the 64 bit ECL with both MSYS2 MinGW64 and Visual Studio Community, but I don't know what mistake I'm making on both, but somehow it works fine in Cygwin64.
15:45:25
AmateurLisper
When using CFFI, if I try to access a member of a cstruct, then with-foreign-slots works to access the members, but mem-ref will give an error like "2414741438416 is not of type (INTEGER 0 4294967295)". Likewise if a cstruct contains another cstruct as a member, then regardless of whether I try mem-ref or with-foreign-slots I get a similar error.
15:45:33
AmateurLisper
If someone wants to see a short snippet of code that demonstrates the error I could paste it in here, or put it somewhere that you suggest.
15:49:10
jackdaniel
a comment before the last one mentions a fix you could apply locally, while the last comment suggests the /right thing/, that is to use uintptr_t
15:51:47
AmateurLisper
So, do I need to edit ffi.d or is there a change in my code that I can make? Unfortunately I don't know enough to understand what is meant by "Changing the type of ADDR on the C-INLINE form to :UINT64-T lets me make pointers larger than 32-bits; I imagine the proper fix would be to add size_t to ecl_foreign_type_table and use that instead?"
16:03:09
jackdaniel
well, in that case you will need to wait for someone implementing that. the issue here is that the function ffi:make-pointer assumes that the pointer fits in the variable of type unsigned_long - while true for most compilers windows made a choice to make unsigned long the same for both 32 bit and 64 bit platforms, hence the pointer can't be stored there
16:03:59
jackdaniel
a bandaid solution is to modify the function make-pointer in src/lsp/ffi.lsp and replace :unsigned-long with :uint64-t (mind, that this will break on 32 bit platforms)
16:04:22
jackdaniel
the right solution is to make the unsigned pointer type part of the ffi api in ecl
16:40:56
AmateurLisper
So, just to make sure I understand correctly, this works in Cygwin64 because :unsigned-long on Cygwin64 is actually 64-bit?
17:01:14
jackdaniel
mind that what windows compiler does is also conforming, because the C standard doesn't specify how many bits the unsigned long has, only the lower limit
17:13:23
AmateurLisper
Thank you so much for your help. Make is still running right now. When that's done I'll be able to make sure I did this right :)
17:47:42
AmateurLisper
Changing that bit of code to (:object :unsignlong #+:WIN64 :uint64-t #-:WIN64 :unsigned-long) worked perfectly :)
17:48:23
AmateurLisper
I haven't tried 32 bit, but it worked under MinGW64, which is good enough for me.
17:57:13
AmateurLisper
I have no idea where to propose that solution, or if it is already in the works.
17:58:09
jackdaniel
as I said - it is a relatively easy one, it is just that my time is quite limited lately.
19:30:55
AmateurLisper
A possible second issue: If I try to set a heap size greater than 4 GB then I get 8589934592 is not of type (INTEGER 0 4294967295). Is that another :unsigned-long not being 64-bit issue?
19:36:47
AmateurLisper
At least reproducing it is easy. Just call ecl.exe --heap-size <number greater than 4294967295>
19:39:20
AmateurLisper
Thank you, I hadn't had time to try yet, but that makes sense. It's probably another issue of :unsigned-long being different on Win64 than basically anywhere else.