Segfault with APR 1.3.9 on Mac OS X 10.6.1

View: New views
2 Messages — Rating Filter:   Alert me  

Segfault with APR 1.3.9 on Mac OS X 10.6.1

by Hyrum K. Wright-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all.

I recently upgraded to APR 1.3.9, and almost all of the Subversion  
unit tests started failing.  Upon further investigation, there is a  
segfault inside the apr_psprintf() function of APR.  I believe this  
might be related to this the "Better handling of APR_OFF_T_FMT for  
Darwin 10 depending on -arch setting of compiler" item listed in  
CHANGES.  I'm running Mac OS X 10.6.1, on an early-2008-era MacBook  
Pro.  Please let me know if you need additional about my environment.

Using APR 1.3.9, I was able to tickle the bug using the attached 40-
line program, giving the following output:

[[[
hyrum-wrights-macbook-pro-2:test Hyrum$ gcc -Wall -g -o apr-test apr-
test.c -I/opt/local/include/apr-1/ -lapr-1 -L/opt/local/lib
hyrum-wrights-macbook-pro-2:test Hyrum$ ./apr-test
Running with apr version '1.3.9'
Segmentation fault
hyrum-wrights-macbook-pro-2:test Hyrum$ gdb ./apr-test
GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56  
UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and  
you are
welcome to change it and/or distribute copies of it under certain  
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for  
details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for  
shared libraries ... done

(gdb) r
Starting program: /Users/Hyrum/dev/test/apr-test
Reading symbols for shared libraries ++. done

Running with apr version '1.3.9'

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00007fff8004ec00 in strlen ()
(gdb) bt
#0  0x00007fff8004ec00 in strlen ()
#1  0x0000000100006594 in apr_vformatter ()
#2  0x000000010001043c in apr_pvsprintf ()
#3  0x00000001000106db in apr_psprintf ()
#4  0x0000000100000e6e in main (argc=1, argv=0x7fff5fbff8e0) at apr-
test.c:31
(gdb)
]]]

Running the same program with APR 1.3.8 gives:

[[[
hyrum-wrights-macbook-pro-2:test Hyrum$ gcc -Wall -g -o apr-test apr-
test.c -I/opt/local/include/apr-1/ -lapr-1 -L/opt/local/lib
apr-test.c: In function ‘main’:
apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
argument 4 has type ‘apr_off_t’
apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
argument 5 has type ‘apr_off_t’
apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
argument 6 has type ‘apr_off_t’
hyrum-wrights-macbook-pro-2:test Hyrum$ gdb ./apr-testGNU gdb  
6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and  
you are
welcome to change it and/or distribute copies of it under certain  
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for  
details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for  
shared libraries ... done

(gdb) r
Starting program: /Users/Hyrum/dev/test/apr-test
Reading symbols for shared libraries ++. done

Running with apr version '1.3.8'
'42 10 11 12 itsy bitsy spider'

Program exited normally.
(gdb)
]]]

Hopefully this helps fix the problem.  Oh, and http://www.apache.org/dist/apr/CHANGES-APR-1.3 
  hasn't yet been updated to reflect 1.3.9.

Cheers,
-Hyrum



apr-test.c (806 bytes) Download Attachment

Re: Segfault with APR 1.3.9 on Mac OS X 10.6.1

by Jim Jagielski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It looks like you're trying to compile in both architectures....
Try with 'gcc -arch i386'

Most likely it is because the libs are 32 bit and you are trying
to run a 64bit app.

On Oct 12, 2009, at 2:42 PM, Hyrum K. Wright wrote:

> Hi all.
>
> I recently upgraded to APR 1.3.9, and almost all of the Subversion  
> unit tests started failing.  Upon further investigation, there is a  
> segfault inside the apr_psprintf() function of APR.  I believe this  
> might be related to this the "Better handling of APR_OFF_T_FMT for  
> Darwin 10 depending on -arch setting of compiler" item listed in  
> CHANGES.  I'm running Mac OS X 10.6.1, on an early-2008-era MacBook  
> Pro.  Please let me know if you need additional about my environment.
>
> Using APR 1.3.9, I was able to tickle the bug using the attached 40-
> line program, giving the following output:
>
> [[[
> hyrum-wrights-macbook-pro-2:test Hyrum$ gcc -Wall -g -o apr-test apr-
> test.c -I/opt/local/include/apr-1/ -lapr-1 -L/opt/local/lib
> hyrum-wrights-macbook-pro-2:test Hyrum$ ./apr-test
> Running with apr version '1.3.9'
> Segmentation fault
> hyrum-wrights-macbook-pro-2:test Hyrum$ gdb ./apr-test
> GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3  
> 01:19:56 UTC 2009)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and  
> you are
> welcome to change it and/or distribute copies of it under certain  
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for  
> details.
> This GDB was configured as "x86_64-apple-darwin"...Reading symbols  
> for shared libraries ... done
>
> (gdb) r
> Starting program: /Users/Hyrum/dev/test/apr-test
> Reading symbols for shared libraries ++. done
>
> Running with apr version '1.3.9'
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
> 0x00007fff8004ec00 in strlen ()
> (gdb) bt
> #0  0x00007fff8004ec00 in strlen ()
> #1  0x0000000100006594 in apr_vformatter ()
> #2  0x000000010001043c in apr_pvsprintf ()
> #3  0x00000001000106db in apr_psprintf ()
> #4  0x0000000100000e6e in main (argc=1, argv=0x7fff5fbff8e0) at apr-
> test.c:31
> (gdb)
> ]]]
>
> Running the same program with APR 1.3.8 gives:
>
> [[[
> hyrum-wrights-macbook-pro-2:test Hyrum$ gcc -Wall -g -o apr-test apr-
> test.c -I/opt/local/include/apr-1/ -lapr-1 -L/opt/local/lib
> apr-test.c: In function ‘main’:
> apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
> argument 4 has type ‘apr_off_t’
> apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
> argument 5 has type ‘apr_off_t’
> apr-test.c:33: warning: format ‘%ld’ expects type ‘long int’, but  
> argument 6 has type ‘apr_off_t’
> hyrum-wrights-macbook-pro-2:test Hyrum$ gdb ./apr-testGNU gdb  
> 6.3.50-20050815 (Apple version gdb-1344) (Fri Jul  3 01:19:56 UTC  
> 2009)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and  
> you are
> welcome to change it and/or distribute copies of it under certain  
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for  
> details.
> This GDB was configured as "x86_64-apple-darwin"...Reading symbols  
> for shared libraries ... done
>
> (gdb) r
> Starting program: /Users/Hyrum/dev/test/apr-test
> Reading symbols for shared libraries ++. done
>
> Running with apr version '1.3.8'
> '42 10 11 12 itsy bitsy spider'
>
> Program exited normally.
> (gdb)
> ]]]
>
> Hopefully this helps fix the problem.  Oh, and http://www.apache.org/dist/apr/CHANGES-APR-1.3 
>  hasn't yet been updated to reflect 1.3.9.
>
> Cheers,
> -Hyrum
>
> <apr-test.c>