rudix-mac / rudix

Build system target on macOS with precompiled packages
https://rudix.org
BSD 3-Clause "New" or "Revised" License
194 stars 35 forks source link

lynx package is broken on my Yosemite #52

Closed aureliojargas closed 8 years ago

aureliojargas commented 9 years ago

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 commented 9 years ago

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.

$ 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 commented 9 years ago

Hi @ruda, thanks for the help!

Maybe it's a Homebrew clash.

$ 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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

user_mode = ADVANCED
ruda commented 9 years ago

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;
 }