Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lynx package is broken on my Yosemite #52

Closed
aureliojargas opened this issue Dec 17, 2014 · 7 comments
Closed

lynx package is broken on my Yosemite #52

aureliojargas opened this issue Dec 17, 2014 · 7 comments

Comments

@aureliojargas
Copy link

I've made a fresh install for Mavericks months ago, and now did an upgrade to Yosemite.

I've followed the update instructions on the Rudix website:

$ curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2014.10/rudix.py | sudo python - install rudix

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
Downloading rudix-2014.10-0.pkg...
####################################################################################################################################################### 100.0%
installer: Package name is Rudix Package Manager 2014.10
installer: Installing at base path /
installer: The install was successful.
$

Then I've tried to install and use lynx:

$ sudo rudix install lynx
Downloading lynx-2.8.8-1.pkg...
####################################################################################################################################################### 100.0%
installer: Package name is Lynx 2.8.8
installer: Installing at base path /
installer: The install was successful.
$ lynx
lynx(74286,0x7fff74e63300) malloc: *** error for object 0x7fc96a514d81: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
$ lynx http://google.com
lynx(74372,0x7fff74e63300) malloc: *** error for object 0x7fb84a41e731: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
$

But Rudix itself is working ok, since I have just installed and used wget after that:

$ sudo rudix install wget
Downloading wget-1.15-1.pkg...
####################################################################################################################################################### 100.0%
installer: Package name is GNU Wget 1.15
installer: Installing at base path /
installer: The install was successful.
$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
$

Please tell me what else I can do to help debugging.

@ruda
Copy link
Member

ruda commented Dec 19, 2014

I cannot reproduce the problem in my machine with Yosemite. I did a clean installation of Rudix (nothing on /usr/local/) and then I've tried to reproduce your steps, but the malloc problem never happens. I did upgrade from Mavericks to Yosemite too.

  • Are you running on Terminal.app?
  • What's the version of Yosemite? Mine is 10.10.1
  • Have you had Homebrew, Macports, Fink installed?
$ otool -L /usr/local/bin/lynx
/usr/local/bin/lynx:
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1151.16.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ md5 /usr/local/bin/lynx
MD5 (/usr/local/bin/lynx) = f1b5c7a5f1ed75788e88514179adff7e

@aureliojargas
Copy link
Author

Hi @ruda, thanks for the help!

Maybe it's a Homebrew clash.

  • Running on Terminal.app
  • Yosemite 10.10.1
  • Homebrew installed, but no Macports or Fink
$ brew update
Already up-to-date.
$ brew list
gdbm        openssl     python3     readline    sqlite      xz
$ otool -L /usr/local/bin/lynx
/usr/local/bin/lynx:
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1151.16.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ md5 /usr/local/bin/lynx
MD5 (/usr/local/bin/lynx) = f1b5c7a5f1ed75788e88514179adff7e

I have just uninstalled and reinstalled lynx, with no luck:

$ sudo rudix -i lynx
Downloading lynx-2.8.8-1.pkg...
######################################################################################################################### 100.0%
installer: Package name is Lynx 2.8.8
installer: Installing at base path /
installer: The install was successful.
$ lynx
lynx(13291,0x7fff7482b300) malloc: *** error for object 0x7f8c68f00001: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

@aureliojargas
Copy link
Author

I have completely uninstalled Homebrew, didn't work.
I have repaired permissions using Disk Utility, didn't work.
I have then dropped the bomb:

sudo rm -rf /usr/local

Then rebooted and made a clean install of Rudix and lynx:

$ cd /usr
$ ls -l
total 8
drwxr-xr-x     5 root  wheel    170 Sep  9 18:41 X11
lrwxr-xr-x     1 root  wheel      3 Dec  9 21:15 X11R6 -> X11
drwxr-xr-x  1046 root  wheel  35564 Dec 22 23:01 bin
drwxr-xr-x   257 root  wheel   8738 Dec 17 06:43 include
drwxr-xr-x   272 root  wheel   9248 Dec 17 06:44 lib
drwxr-xr-x   170 root  wheel   5780 Dec 22 23:01 libexec
drwxr-xr-x   243 root  wheel   8262 Dec 22 23:01 sbin
drwxr-xr-x    44 root  wheel   1496 Dec 17 06:44 share
drwxr-xr-x     4 root  wheel    136 Dec  9 21:07 standalone
$ curl -s https://raw.githubusercontent.com/rudix-mac/rpm/2014.10/rudix.py | sudo python - install rudix
Password:
Downloading rudix-2014.10-0.pkg...
####################################################################################################################################################### 100.0%
installer: Package name is Rudix Package Manager 2014.10
installer: Installing at base path /
installer: The install was successful.
$ sudo rudix -i lynx
Downloading lynx-2.8.8-1.pkg...
####################################################################################################################################################### 100.0%
installer: Package name is Lynx 2.8.8
installer: Installing at base path /
installer: The install was successful.
$ lynx
lynx(1162,0x7fff722e7300) malloc: *** error for object 0x7fe3f951cb71: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

:(

Rechecking:

$ otool -L /usr/local/bin/lynx
/usr/local/bin/lynx:
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1151.16.0)
    /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ md5 /usr/local/bin/lynx
MD5 (/usr/local/bin/lynx) = f1b5c7a5f1ed75788e88514179adff7e

Here's the current state of my /usr/local:

$ find /usr/local | grep -v share/locale
/usr/local
/usr/local/bin
/usr/local/bin/lynx
/usr/local/bin/rudix
/usr/local/etc
/usr/local/etc/lynx.cfg
/usr/local/etc/lynx.cfg.default
/usr/local/etc/lynx.lss
/usr/local/etc/lynx.lss.default
/usr/local/share
/usr/local/share/doc
/usr/local/share/doc/lynx
/usr/local/share/doc/lynx/AUTHORS
/usr/local/share/doc/lynx/CHANGES
/usr/local/share/doc/lynx/COPYHEADER
/usr/local/share/doc/lynx/COPYHEADER.asc
/usr/local/share/doc/lynx/COPYING
/usr/local/share/doc/lynx/COPYING.asc
/usr/local/share/doc/lynx/INSTALLATION
/usr/local/share/doc/lynx/PROBLEMS
/usr/local/share/doc/lynx/README
/usr/local/share/doc/rudix
/usr/local/share/doc/rudix/LICENSE
/usr/local/share/doc/rudix/README
/usr/local/share/doc/rudix/rudix.pdf
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man1/lynx.1
/usr/local/share/man/man1/rudix.1

Now I have removed lynx from Rudix, installed Homebrew and it's lynx:

$ sudo rudix -r lynx
Password:
Forgot package 'org.rudix.pkg.lynx' on '/'.
$ rm -f /usr/local/etc/lynx.*
$ hash -r
$ lynx
-bash: lynx: command not found
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
...
$ brew doctor
Your system is ready to brew.
$ brew install lynx
==> Installing lynx dependency: openssl
...
==> Installing lynx
...
$ which lynx
/usr/local/bin/lynx
$ lynx
lynx(29511,0x7fff722e7300) malloc: *** error for object 0x7fb6dbf082d1: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

:(

It's not Rudix's fault, because Homebrew's lynx is raising the same error. There must be something weird in my machine elsewhere. I'll close this issue, thanks for the help!

@ruda
Copy link
Member

ruda commented Jan 22, 2015

Oh, sad to hear that :(
But if you're in mood, you can try to set a brake point, as the error message said, to try to get more information about the problem.

lldb /path/to/lynx
(lldb) b malloc_error_break
(lldb) run
(lldb) bt

@aureliojargas
Copy link
Author

I have no clue about C, thanks for the commands!

$ lldb /usr/local/bin/lynx 
(lldb) target create "/usr/local/bin/lynx"
Current executable set to '/usr/local/bin/lynx' (x86_64).
(lldb) b malloc_error_break
Breakpoint 1: where = libsystem_malloc.dylib`malloc_error_break, address = 0x000000000001319f
(lldb) run
Process 26242 launched: '/usr/local/bin/lynx' (x86_64)
lynx(26242,0x7fff7308c300) malloc: *** error for object 0x100505841: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 26242 stopped
* thread #1: tid = 0x2c4de, 0x00007fff8752f19f libsystem_malloc.dylib`malloc_error_break, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00007fff8752f19f libsystem_malloc.dylib`malloc_error_break
libsystem_malloc.dylib`malloc_error_break:
-> 0x7fff8752f19f:  pushq  %rbp
   0x7fff8752f1a0:  movq   %rsp, %rbp
   0x7fff8752f1a3:  nop    
   0x7fff8752f1a4:  nopl   (%rax)
(lldb) bt
* thread #1: tid = 0x2c4de, 0x00007fff8752f19f libsystem_malloc.dylib`malloc_error_break, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00007fff8752f19f libsystem_malloc.dylib`malloc_error_break
    frame #1: 0x00007fff875208c5 libsystem_malloc.dylib`free + 314
    frame #2: 0x00000001000554c3 lynx`LYsetRcValue + 841
    frame #3: 0x0000000100055738 lynx`read_rc + 358
    frame #4: 0x0000000100026887 lynx`main + 2369
    frame #5: 0x00007fff8b2e95c9 libdyld.dylib`start + 1
    frame #6: 0x00007fff8b2e95c9 libdyld.dylib`start + 1
(lldb) 

Hey, wait! read_rc No, that can't be...

Yes. It was the ~/.lynxrc file :/

Just removed my old file and created an empty new one, then lynx worked fine. SOLVED!

Thank you @ruda for your assistance!

@aureliojargas
Copy link
Author

For the record, the offending ~/.lynxrc config that caused lynx to crash was:

user_mode = ADVANCED

@ruda
Copy link
Member

ruda commented Jan 23, 2015

The problem relies on LYSkipBlanks(), which alters the pointer if the string contains blank, so FREEing will fail. I've made a patch to fix this problem, it seems to work.

--- src/LYrcFile.c.orig 2015-01-23 00:30:07.000000000 -0200
+++ src/LYrcFile.c  2015-01-23 00:30:11.000000000 -0200
@@ -661,8 +661,10 @@
     ParseUnionPtr q;
     BOOL changed = TRUE;
     char *value = NULL;
+    char *orig_value = NULL;

     StrAllocCopy(value, param);
+    orig_value = value;
     value = LYSkipBlanks(value);
     CTRACE2(TRACE_CFG, (tfp, "LYrcFile %s:%s\n", name, value));

@@ -754,7 +756,7 @@
    changed = FALSE;
    break;
     }
-    FREE(value);
+    FREE(orig_value);

     return changed;
 }

@ruda ruda reopened this Jan 23, 2015
ruda added a commit that referenced this issue May 5, 2015
When .lynxrc has user_mode = ADVANCED, running lynx will
crash it with a malloc error message like this:

lynx(2572,0x7fff70d81300) malloc: *** error for object 0x7fae82511611: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

The patch LYrcFile.c.patch fix this problem reported
on issue #52 [#52]

Signed-off-by: Rudá Moura <ruda.moura@gmail.com>
@ruda ruda closed this as completed Aug 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants