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

Calling rados_getxattrs() on a non-existent object causes segmentation faults #32

Open
matthi4s opened this issue May 26, 2018 · 0 comments

Comments

@matthi4s
Copy link
Contributor

While messing around with rados_getxattrs() I got some strange "502 Bad gateway" errors, which were caused by segmentation faults in phprados. I don't really know anything about C and segmentation faults but after some searching and trying I discovered that it only occurs if the given object doesn't exist. It is possible to avoid this by checking with rados_stat() before if the object exists, but I think this should still be fixed and return an error array like the other functions.

Here is the output of my try to mess around with gdb:

GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/php-fpm7.0...(no debugging symbols found)...done.
[New LWP 1880907]
[New LWP 1881270]
[New LWP 1881269]
[New LWP 1881268]
[New LWP 1881267]
[New LWP 1881265]
[New LWP 1881261]
[New LWP 1881260]
[New LWP 1881271]
[New LWP 1881263]
[New LWP 1881266]
[New LWP 1881264]
[New LWP 1881262]
[New LWP 1881272]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `php-fpm: pool www                                                            '.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fb6fdd41428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7fb6ffc918c0 (LWP 1880907))]
(gdb) bt
#0  0x00007fb6fdd41428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007fb6fdd4302a in __GI_abort () at abort.c:89
#2  0x00007fb6fdd837ea in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7fb6fde9ced8 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007fb6fdd8c37a in malloc_printerr (ar_ptr=<optimized out>, ptr=<optimized out>, str=0x7fb6fde99caf "free(): invalid pointer", action=3) at malloc.c:5006
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3867
#5  0x00007fb6fdd9053c in __GI___libc_free (mem=<optimized out>) at malloc.c:2968
#6  0x00007fb6ed64bc2d in librados::RadosXattrsIter::~RadosXattrsIter() () from /usr/lib/librados.so.2
#7  0x00007fb6ed607e94 in rados_getxattrs_end () from /usr/lib/librados.so.2
#8  0x00007fb6ed90dab0 in zif_rados_getxattrs (execute_data=<optimized out>, return_value=0x7fb6faa135c0) at /root/phprados/rados.c:1201
#9  0x0000560d5a6d40cd in ?? ()
#10 0x0000560d5a68f6cb in execute_ex ()
#11 0x0000560d5a6e3cf7 in zend_execute ()
#12 0x0000560d5a64ecb3 in zend_execute_scripts ()
#13 0x0000560d5a5edbb0 in php_execute_script ()
#14 0x0000560d5a4d1fe6 in main ()
(gdb) frame 8
#8  0x00007fb6ed90dab0 in zif_rados_getxattrs (execute_data=<optimized out>, return_value=0x7fb6faa135c0) at /root/phprados/rados.c:1201
1201	    rados_getxattrs_end(iter);
(gdb) info frame
Stack level 8, frame at 0x7ffe347a8fc0:
 rip = 0x7fb6ed90dab0 in zif_rados_getxattrs (/root/phprados/rados.c:1201); saved rip = 0x560d5a6d40cd
 called by frame at 0x7ffe347a9010, caller of frame at 0x7ffe347a8f50
 source language c.
 Arglist at 0x7ffe347a8f48, args: execute_data=<optimized out>, return_value=0x7fb6faa135c0
 Locals at 0x7ffe347a8f48, Previous frame's sp is 0x7ffe347a8fc0
 Saved registers:
  rbx at 0x7ffe347a8f90, rbp at 0x7ffe347a8f98, r12 at 0x7ffe347a8fa0, r13 at 0x7ffe347a8fa8, r14 at 0x7ffe347a8fb0, rip at 0x7ffe347a8fb8
(gdb) info args
execute_data = <optimized out>
return_value = 0x7fb6faa135c0
(gdb) info locals
ioctx_r = <optimized out>
oid = 0x7fb6faa67840
zioctx = 0x7fb6faa13650
iter = 0x560d5aa3f240 <executor_globals>
errDesc = 0x7fb6faa81840 "No such file or directory"
response = <optimized out>

I don't know if this is helpful at all or if you need the whole dump, let me know if you need any more information to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant