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

Coredump on Ubuntu when using polls #40

Open
csaoh opened this issue Feb 27, 2013 · 11 comments
Open

Coredump on Ubuntu when using polls #40

csaoh opened this issue Feb 27, 2013 · 11 comments
Labels

Comments

@csaoh
Copy link
Contributor

csaoh commented Feb 27, 2013

This code (the example code from uv_poll_start with only php://stdout replaced)

<?php
$fd = fopen("php://temp","w+");

$poll = uv_poll_init(uv_default_loop(), $fd);
uv_poll_start($poll, UV::WRITABLE, function($poll, $stat, $ev, $conn){
        fwrite($conn, "Hello");
        fclose($conn);
        uv_poll_stop($poll);
});

uv_run();

results in

Aborted (core dumped)

It works fine on OS X though.

(I had to use gcc4.4 as described in #24 to make it work in the first place)

@chobie
Copy link
Owner

chobie commented Feb 27, 2013

hmm. I have to take a look around php's "php://temp" implementation.
epoll returns EPERM error at this time. so i guess it's not using file descriptor.

Program received signal SIGABRT, Aborted.
0x00007ffff55a8425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff55a8425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff55abb8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff0cbccc6 in uv__io_poll (loop=0x7ffff0ed81c0, timeout=-1) at src/unix/linux/linux-core.c:162
#3  0x00007ffff0ca73bd in uv_run (loop=0x7ffff0ed81c0, mode=UV_RUN_DEFAULT) at src/unix/core.c:294
#4  0x00007ffff0c98434 in zif_uv_run (ht=0, return_value=0x7ffff7fcfa78, return_value_ptr=0x0, this_ptr=0x0, return_value_used=0)
    at /home/chobie/src/src/php-uv/php_uv.c:3353
#5  0x00000000009fd967 in execute_internal (execute_data_ptr=0x7ffff7f9b0e8, return_value_used=0) at /var/tmp/php-build/source/5.4.12/Zend/zend_execute.c:1480
#6  0x00007ffff0ee88bb in xdebug_execute_internal (current_execute_data=0x7ffff7f9b0e8, return_value_used=0)
    at /var/tmp/php-build/source/xdebug-2.2.1/xdebug.c:1483
#7  0x00000000009ff554 in zend_do_fcall_common_helper_SPEC (execute_data=0x7ffff7f9b0e8) at /var/tmp/php-build/source/5.4.12/Zend/zend_vm_execute.h:644
#8  0x0000000000a06798 in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0x7ffff7f9b0e8) at /var/tmp/php-build/source/5.4.12/Zend/zend_vm_execute.h:2223
#9  0x00000000009fde0e in execute (op_array=0x7ffff7fd08b8) at /var/tmp/php-build/source/5.4.12/Zend/zend_vm_execute.h:410
#10 0x00007ffff0ee8441 in xdebug_execute (op_array=0x7ffff7fd08b8) at /var/tmp/php-build/source/xdebug-2.2.1/xdebug.c:1391
#11 0x00000000009c018f in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /var/tmp/php-build/source/5.4.12/Zend/zend.c:1315
#12 0x000000000093367c in php_execute_script (primary_file=0x7fffffffd6c0) at /var/tmp/php-build/source/5.4.12/main/main.c:2492
#13 0x0000000000b09455 in do_cli (argc=2, argv=0x7fffffffeaa8) at /var/tmp/php-build/source/5.4.12/sapi/cli/php_cli.c:988
#14 0x0000000000b0a58e in main (argc=2, argv=0x7fffffffeaa8) at /var/tmp/php-build/source/5.4.12/sapi/cli/php_cli.c:1364
(gdb) q

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

i does the same with any file, if i recall it right. will doublecheck tomorrow

@chobie
Copy link
Owner

chobie commented Feb 28, 2013

o.O. probably i missed something. i'll check this in this weekend.

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

Yep, i confirm,

<?php
$fd = fopen("testfile","w+");

$poll = uv_poll_init(uv_default_loop(), $fd);
uv_poll_start($poll, UV::WRITABLE, function($poll, $stat, $ev, $conn){
        fwrite($conn, "Hello");
        fclose($conn);
        uv_poll_stop($poll);
});

uv_run();

results in the same thing. Same for UV::READABLE flag

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

Looks like it enters

if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
      if (errno != EEXIST)
        abort();

in linux.core.c, line 160

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

Alriiiight. It's a problem within libuv. When I asked about it on IRC, i got answered "not very nice, but uv_poll_t is not meant to work with files". Sooo, i don't really know what to do about it.

Either someone (I'll give a look at it right now) fixes the issue on linux, or I have to find another way to do it, and I'm pretty positive I can't use uv_fs_poll since it doesn't take an fd, and for react I need it...

@chobie
Copy link
Owner

chobie commented Feb 28, 2013

@csaoh thank you for asking on IRC. I also realized it's libuv issue. it's able to work with node-v0.8.21 tag.

for now, let's switch libuv version.

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

Now it does nothing at all, both on OSX and linux. I also have this message

[Thu Feb 28 14:24:31 2013]  Script:  '/Users/andrey/test.php'
/Users/andrey/www/php-libev/libev.c(396) :  Freeing 0x10DAEAD88 (8 bytes), script=/Users/andrey/test.php
Last leak repeated 4 times
=== Total 5 memory leaks detected ===

@chobie
Copy link
Owner

chobie commented Feb 28, 2013

hmm. my osx and ubuntu box passed the testcases.
probably did you forget git submodule update after git pull --rebase ?
i updated submodule reference so it requires update and re-generate uv.

git pull --rebase
git submodule update
phpize --clean
cd libuv
make clean
make
# now, it generate uv.a
cd ..
./configure
make

and that error message did not (directly) relate php-uv. just php-libev doesn't free some emalloc'ed variables.

@csaoh
Copy link
Contributor Author

csaoh commented Feb 28, 2013

Sorry, works fine !

@steverhoades
Copy link

Unfortunately, this issue is still present as of 1.0.0-rc2. I have added a test in my PR #59 to account for this. I think that it might make more sense to only allow fds that uv_poll_init can act on, and throw E_ERRORS for any stream types that are not of type *socket ?

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

No branches or pull requests

3 participants