Forum: Ruby-core [Ruby 1.9-Bug#3761][Open] List of possible casting issues under LLP64

Posted by Luis Lavena (Guest)
on 2010-08-29 20:46
(Received via mailing list)
Bug #3761: List of possible casting issues under LLP64
http://redmine.ruby-lang.org/issues/show/3761

Author: Luis Lavena
Status: Open, Priority: Normal
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.3dev (2010-08-29 trunk 29141) [i386-mingw32]

Hello,

working on getting Ruby (trunk and 1.9.2) build under mingw-w64 
compiler. Since Windows uses LLP64 instead of LP64, sveral warnings from 
compilation in 32bits might shed some light for fixing.

These warnings are around pointer casting:

<pre><code>
In file included from ../../../../ruby/thread.c:204:0:
../../../../ruby/thread_win32.c: In function 'w32_wait_events':
../../../../ruby/thread_win32.c:126:13: warning: comparison between 
signed and unsigned integer expressions
../../../../ruby/thread_win32.c:129:13: warning: comparison between 
signed and unsigned integer expressions
../../../../ruby/thread_win32.c: In function 'w32_resume_thread':
../../../../ruby/thread_win32.c:170:30: warning: comparison between 
signed and unsigned integer expressions


../../../../../../ruby/ext/openssl/ossl_hmac.c: In function 
'ossl_hmac_hexdigest':
../../../../../../ruby/ext/openssl/ossl_hmac.c:162:49: warning: 
comparison between signed and unsigned integer expressions
../../../../../../ruby/ext/openssl/ossl_hmac.c: In function 
'ossl_hmac_s_hexdigest':
../../../../../../ruby/ext/openssl/ossl_hmac.c:225:49: warning: 
comparison between signed and unsigned integer expressions

../../../../../../ruby/ext/openssl/ossl_pkcs7.c: In function 
'ossl_pkcs7_sym2typeid':
../../../../../../ruby/ext/openssl/ossl_pkcs7.c:376:18: warning: 
comparison between signed and unsigned integer expressions

../../../../../../ruby/ext/openssl/ossl_pkey_ec.c: In function 
'ossl_ec_group_set_seed':
../../../../../../ruby/ext/openssl/ossl_pkey_ec.c:1110:89: warning: 
comparison between signed and unsigned integer expressions

../../../../../../ruby/ext/openssl/ossl_ssl_session.c: In function 
'ossl_ssl_session_to_der':
../../../../../../ruby/ext/openssl/ossl_ssl_session.c:208:15: warning: 
comparison between signed and unsigned integer expressions


../../../../../../ruby/ext/socket/raddrinfo.c: In function 
'init_addrinfo':
../../../../../../ruby/ext/socket/raddrinfo.c:581:27: warning: 
comparison between signed and unsigned integer expressions
../../../../../../ruby/ext/socket/raddrinfo.c: In function 
'inspect_sockaddr':
../../../../../../ruby/ext/socket/raddrinfo.c:939:35: warning: 
comparison between signed and unsigned integer expressions
../../../../../../ruby/ext/socket/raddrinfo.c:952:48: warning: 
comparison between signed and unsigned integer expressions
../../../../../../ruby/ext/socket/raddrinfo.c:965:35: warning: 
comparison between signed and unsigned integer expressions
../../../../../../ruby/ext/socket/raddrinfo.c:987:49: warning: 
comparison between signed and unsigned integer expressions
</code></pre>
Posted by Luis Lavena (Guest)
on 2010-09-23 15:44
(Received via mailing list)
Issue #3761 has been updated by Luis Lavena.


Hello wanabe

I see in r29320 that you added mingw64 but specified basic_machine as 
i386-pc

I believe that is not correct. mingw-w64 targeting 64bits should be 
x86_64 as as architecture, no?

Thank you.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by _ wanabe (Guest)
on 2010-09-23 16:26
(Received via mailing list)
Issue #3761 has been updated by _ wanabe.


Hello,

> I see in r29320 that you added mingw64 but specified basic_machine as i386-pc
>
> I believe that is not correct. mingw-w64 targeting 64bits should be x86_64 as as architecture, no?

Sorry, you are right.
I will change it as soon as possible.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by _ wanabe (Guest)
on 2010-09-23 16:54
(Received via mailing list)
Issue #3761 has been updated by _ wanabe.


> I will change it as soon as possible.
Oh, already fixed at r29324. Thanks to Nakada-san.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by Luis Lavena (Guest)
on 2010-09-23 17:42
(Received via mailing list)
Issue #3761 has been updated by Luis Lavena.


Thank you wanabe and Nakada-san.

I'm having other warnings related to gc:

<pre><code>
x86_64-w64-mingw32-gcc -O3 -g -Wextra -Wno-unused-parameter 
-Wno-parentheses -Wpointer-arith -Wwrite-strings 
-Wno-missing-field-initializers -Wno-long-long -I. 
-I.ext/include/x86_64-mingw32 -I../include -I.. -include ruby/config.h 
-include ruby/missing.h -DRUBY_EXPORT   -o gc.o -c ../gc.c
../gc.c: In function ‘obj_free’:
../gc.c:2193:10: warning: cast from pointer to integer of different size 
[-Wpointer-to-int-cast]
../gc.c: In function ‘rb_objspace_call_finalizer’:
../gc.c:2908:7: warning: cast from pointer to integer of different size 
[-Wpointer-to-int-cast]
</code></pre>

Looking at both lines of the warnings seems that pointer is been casted 
to (long)

Changing that to size_t (the supposed to be pointer size) solve the 
issue in both part of the equality check:

From:

if ((long)RANY(obj)->as.data.dfree == -1) {

To:

if ((size_t)RANY(obj)->as.data.dfree == (size_t)-1) {

But I'm unsure of the implications. The warning is solve but I'm 
ignorant on the correctness.

What do you think?

Thank you for working on this.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by Luis Lavena (Guest)
on 2010-09-23 20:04
(Received via mailing list)
Issue #3761 has been updated by Luis Lavena.


Mr. wanabe:

In r29320 you also introduced Exports::Mingw64 which is never going to 
be called becase RUBY_PLATFORM is x86_64-mingw32. It differs form 
mswin32 and mswin64 because MinGW is still mingw32, just it changes the 
architecture.

The attached patch brings the new regexp from Mingw64 into Mingw32 
itself so symbols are properly exported for 64bits (there is no 
mangling/underscore as 32bits one)

Please verify the correctness of this patch and feel free to apply it. 
If doesn't fit this Bug report, I can open a new one for it.

Thank you in advance for your time.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by Luis Lavena (Guest)
on 2010-09-23 20:05
(Received via mailing list)
Issue #3761 has been updated by Luis Lavena.

File export-symbols-for-dll-under-64bits.patch added

Forgot to attach the file.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Posted by _ wanabe (Guest)
on 2010-09-26 15:27
(Received via mailing list)
Issue #3761 has been updated by _ wanabe.

Status changed from Assigned to Closed
% Done changed from 0 to 100

This issue was solved with changeset r29346.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/3761
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.