Modify

Opened 5 years ago

Closed 2 years ago

Last modified 22 months ago

#9873 closed defect (fixed)

ruby 1.9.2 http stack problem: symbol 'getipnodebyname'

Reported by: anonymous Owned by: developers
Priority: normal Milestone: Chaos Calmer 15.05
Component: packages Version: Backfire 10.03.1 RC5
Keywords: Cc:

Description

The socket.so file built as a part of ruby-core is faulty. Making an http connection using it produces:

ruby: can't resolve symbol 'getipnodebyname'

I was able to resolve it by grabbing socket.so from the 10.03 backfire build and dropping it in (ruby 1.9.1). Looking at the ruby code: http://www.oschina.net/code/explore/ruby-1.9.2-p0/ext/socket/getaddrinfo.c , it looks like that method should never be called except when the build is ipv6.

I'm not sure why the underlying call is unavailable in this version. However, it effects the trunk and all of the backfire 10.03.1 rcs.

Here is some sample code to reproduce:
require 'net/http'
class HttpSample
def downloadGoogleHome
http_response = Net::HTTP.get_response(URI.parse('http://www.google.com/'))
puts http_response.body
end
s = HttpSample.new
s.downloadGoogleHome
end

Attachments (2)

update-to-p320_and_fix_getipnodebyname_problem.patch (3.6 KB) - added by luizluca@… 3 years ago.
Patch that fixes the bug and also updates to 1.9.2p320
update-to-1.9.3p286_and_fix_getipnodebyname_problem.patch (3.6 KB) - added by luizluca@… 3 years ago.
Alternative fix (same as 1.9.2p320) that also updates to 1.9.3p286

Download all attachments as: .zip

Change History (25)

comment:1 Changed 5 years ago by ineiti@…

Hi,
I ran into the same problem. But my connectivity is really restricted at the moment. Do you mind attaching socket.so here, or seding it to my e-mail ineiti@…?
Thanks

comment:2 Changed 4 years ago by anonymous

This is still a problem in the Backfire branch (at least when building with eglibc as libc library).

comment:3 Changed 4 years ago by anonymous

This still exists in attitude_adjustment_beta2

comment:4 Changed 3 years ago by jens

Still not fixed in RC1

comment:5 Changed 3 years ago by anonymous

Issue is still not fixed in trunk.

Can someone Upload the mentioned socket.so? Would be great.

Changed 3 years ago by luizluca@…

Patch that fixes the bug and also updates to 1.9.2p320

comment:6 Changed 3 years ago by luizluca@…

I found the problem. In the past, someone suggested to use the option --enable-wide-getaddrinfo in order to allow to enable IPv6 (ticket 4819). However, I'm not sure but this option seems to be related to pre-xp windows compilation of ruby. When enabled, it implements alternatives code for getnameinfo and getaddrinfo (flag GETADDRINFO_EMU) and they depend on the getipnodebyname that does not exist in Linux. If this option is removed, you get something more sane.

Now back to IPv6. Without the wide option, you get this message:

Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
you cannot compile IPv6 socket classes with broken these functions.
You can try --enable-wide-getaddrinfo.

This is because the wide getaddrinfo() and getnameinfo() test failed. The --enable-ipv6 wasn't present. It just enabled it as the OS supports it (I removed from package Makefile). Checking the test at ext/socket/mkmf.log, I found the test:

checking for wide getaddrinfo... -------------------- no
"mips-openwrt-linux-uclibc-gcc ...
... and the test c code

The code compiles correctly. Generally this is enough for the test but checking who generated this log (extconf.rb), I found this:

(checking_for("wide getaddrinfo") {try_run(<<EOF)} && :os)

The "try_run" part might really try to run the code. Who wrote this did not considered the possibility of cross compiling. The generated binary, indeed, really run when copied to the target machine but it would never run at the host machine.

I'll ignore this test if crosscompiling (as ruby tk module does) and post the diff here. Also, I tried to fix the bug by updating ruby to p320, that brings many fixes (including one that was manually patched in the package). As it was interesting, I kept it in the patch.

I'll check later for the 1.9.3pXXX and I'll send the fix upstream

Regards,

comment:7 Changed 3 years ago by luizluca@…

I reported upstream at http://bugs.ruby-lang.org/issues/7856. I opted to not send the patch as, in new versions, this problem is present also in other new checks. They might know better than me how to fix this once and for all.

The 1.9.3p286 update also compiles correctly, without missing symbols. I'll also attach an alternative patch to the previous one. Tomorrow I'll run the "make test-all" in a raspberry with openwrt as my home router is too small for a ruby installation.

Changed 3 years ago by luizluca@…

Alternative fix (same as 1.9.2p320) that also updates to 1.9.3p286

comment:8 Changed 3 years ago by luizluca@…

I confirm that the patch fixes the problem. I can use socket and gem without problems.

I also runned a bunch of tests from ruby's test directory (from source) and most of it worked. The failures where in mktemp stuff, csv reading, dynamic loading (because it used the ldd command) and a GDBm one. I guess nothing related to the network problem.

comment:9 Changed 3 years ago by A3

Hello,
sorry for the dumb question, but how exactly I can apply the patch? I checked the following link http://wiki.openwrt.org/doc/devel/patches#adding.a.new.patch but I can't figure it out. Please can someone post the commands that I must run to apply the latest patch on existing by default in AA 12.09 - ruby 1.9.2-p0-1

comment:10 Changed 3 years ago by luizluca@…

A3,

Not a dumb question. This patch must be applied to openwrt ruby root directory (attitude_adjustment/feeds/packages/lang/ruby) with a patch -p0 <update....patch command.

Afterwards, ruby package must be recompiled (make package/ruby/compile). This is done generally in a normal Linux machine and not inside your router. It will generate new package files for ruby. Those you can upload to your router and install with opkg.

What is the target are you using? ar71xx?

BTW, I'll try to compile ruby-1.9.3-p429 and update the patch.

comment:11 Changed 3 years ago by luizluca@…

I just sent a patch http://patchwork.openwrt.org/patch/3754/

If you uses ar71xx, I have ruby already compiled for openwrt 12.04

comment:12 Changed 3 years ago by anonymous

Hi there,

thank you for writing :) Yes, I'm using ar71xx, but I have AA 12.09 installed. Will it be a problem? If not please can you share the file. Please, Please :)

comment:13 follow-up: Changed 3 years ago by anonymous

Yes, I mistyped the version! It is 12.09 AA (I was with ubuntu LTS version in mind)

Here:

https://docs.google.com/file/d/0B54xzz44RpW6YlpaQXV3M2hTQVk/edit?usp=sharing

It's a zip with all ruby packages. Just unzip it and copy what you want to your router (like in /tmp). Just pay attention to void downloading any ruby package but these.

You might want to install, at least, these:

opkg install /tmp/libruby_1.9.3-p429-1_ar71xx.ipk /tmp/ruby-core_1.9.3-p429-1_ar71xx.ipk /tmp/ruby_1.9.3-p429-1_ar71xx.ipk

comment:14 Changed 3 years ago by A3

You are the man. Thank you very much! Everything work flawlessly. Thank you once again

comment:15 Changed 2 years ago by hauke

There is a new ruby version in trunk, please try if this problem still exists in an unpatched trunk version.

comment:16 in reply to: ↑ 13 Changed 2 years ago by anonymous

Replying to anonymous:

Yes, I mistyped the version! It is 12.09 AA (I was with ubuntu LTS version in mind)

Here:

https://docs.google.com/file/d/0B54xzz44RpW6YlpaQXV3M2hTQVk/edit?usp=sharing

It's a zip with all ruby packages. Just unzip it and copy what you want to your router (like in /tmp). Just pay attention to void downloading any ruby package but these.

You might want to install, at least, these:

opkg install /tmp/libruby_1.9.3-p429-1_ar71xx.ipk /tmp/ruby-core_1.9.3-p429-1_ar71xx.ipk /tmp/ruby_1.9.3-p429-1_ar71xx.ipk

I patched as described here but now I get the error:

root@OpenWrt:~# puppet agent --server=puppet --no-daemonize --verbose
/usr/lib/ruby/1.9/rubygems.rb:12:in `<top (required)>': uninitialized constant Gem::QuickLoader (NameError)

from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'

ruby-gems needs to be updated as well.

comment:17 Changed 2 years ago by aspamkiller@…

Problem still exists?

BARRIER BREAKER (Bleeding Edge, r39860)

root@tplink:~$ gem install haml
/usr/lib/ruby/1.9/yaml.rb:84:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/bin/ruby: can't resolve symbol 'getipnodebyname'

comment:18 Changed 2 years ago by luizluca@…

Yes, still exists. Ruby have a problem with crosscompiling.
I created a fix but nobody applied the patch I proposed or even commented it.

My patch from 9 months ago should fix the problem. However, it is getting old as ruby is already at version 2.1.1. Generally the update process is easy.

If someone with commit access is willing to accept the patch, I could even update it to version 2.1.1. However, I'm not doing it if I have no chance of it to be applied.

comment:19 Changed 2 years ago by kyle@…

I've used your fix! :) And build packages off of them! http://download.xkyle.com/openwrt/12.09/kirkwood/

But yea, I agree: OpenWrt Devs: Please accept Luiz's ruby patches :(

comment:20 Changed 2 years ago by luizluca@…

I updated the patch based on openwrt trunk package (which still contains the network problem):

12.09:
https://github.com/luizluca/openwrt-aa-packages/tree/fix_n_update-ruby

trunk:
https://github.com/luizluca/openwrt-packages/tree/ruby-fix_network

I have this and others packages compiled but currently nowhere to publish. My dropbox public links are banned (I abused them with a ubuntu image with a non-pae kernel). Something like ubuntu PPA would be nice.

comment:21 Changed 2 years ago by hauke

  • Resolution set to fixed
  • Status changed from new to closed

This was fixed in r40630. Thank you for the patch.

comment:22 Changed 2 years ago by treffer@…

Thank you hauke!

While you are at it: any chance that http://patchwork.openwrt.org/patch/4312/ (puppet package) gets merged, too? It was blocked by this patch....

comment:23 Changed 22 months ago by jow

  • Milestone changed from Backfire 10.03.2 to Chaos Calmer (trunk)

Milestone Backfire 10.03.2 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.