-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Convert CURL resources to objects #5402
Conversation
@cmb69 Could you please have a look? Unfortunately, I don't understand a couple of things:
|
Thanks for working on this!
|
@cmb69 Thank you very much! I'll try to align the PR according to your suggestions :) |
ff5eb09
to
33f4713
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is in much better shape now, some tests even pass locally. However, for example the ext/curl/tests/bug48203_multi.phpt
test hangs indefinitely. I haven't manage to find out the root cause, but I see that the 2nd consecutive curl_init()
invocation makes it behave like that.
As a general note, we cannot assume that |
c2030b3
to
abb4182
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed most of the existing review comments (cloning support is underway). Unfortunately, I have no idea how to trick cp
to be null
. What should I do with it?
f2cc479
to
61843c6
Compare
Now, only 3 curl tests fail locally. |
61843c6
to
20dd09b
Compare
bdc7120
to
318c386
Compare
e56cb9a
to
6a1841b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see anything obviously wrong in the curl multi implementation.
I've pushed some fixed for leaks and a segfault. However, I'm not sure the fix is ideal: https://github.com/php/php-src/pull/5402/files#diff-ab7a9164033bd55887d45d0a6cb837eeR542-R548 The problem is that the multi handle holds on to the easy handles, but the easy handles may end up being freed first. The "verify handle" loop then causes use after free. We can check detect this situation, but I'm still a bit uncertain about safety. In particular, wouldn't curl_multi_cleanup still try to access the easy handles? As I'm not getting valgrind errors anymore, something must protect against that, but I'm not sure what. |
Hm, I guess that can't happen, because curl will automatically remove the easy handle from the multi handle if the easy handle is destroyed. So this should be safe. I think it may make sense to make curl_multi_close() not a complete no-op though, and do a loop to remove all easy handles from the multi handle in there. If cycles are involved, one would not be able to get predictable cleanup order otherwise. |
@nikic Thank you very much for your efforts to fix this! I'll try to implement the suggested improvement for |
@nikic I've just added the for-loop, but I don't get why it's better than calling Besides, undortunately, the test still fails for me with a segfault (and a memory leak). I ran
|
Looks like there's an assertion failure when running guzzle tests:
|
@nikic Thank you very much for the help! I have a good friend at Guzzle, I'll talk to him about the migration. :) What's the problem with the last commit? P.S: I've run the regular tests locally, and the |
Ah, sorry, I thought that the last commit was yours. But in fact, it was mine. That said, I'll revert it. |
The valgrind log you posted doesn't really look related. Just to double check, it does not occur on master when running under valgrind? |
I pushed a fix for the last commit, so no need to revert anymore. |
@nikic Haha, you're right, it occurs :) If I knew this before that also it fails on master... |
@kocsismate Mind to label these PRs with |
@carusogabriel Unfortunately, I can't create new labels. |
btw is this merged.. ? I can see that it is, right? Not asking in bad way.. but doesn't this need an RFC? Maybe one exists but I can't find it here.. |
@gmponos It's merged. See the comment from php-pulls (b516566). This doesn't need an RFC because resources are a legacy data structure which should be eliminated. Since there is no |
Hi @kocsismate @nikic
The above problems have caused many community components down Solving the backward compatibility problem of I'm not fond of the idea (fix them) too, but I am obliged to admit the fact that BC break has a huge impact on the PHP community |
@twose The situation for us is probably a bit different than for swoole. Swoole is at a bit of a disadvantage here, because most libraries will not be willing to make changes, even very simple changes, to make code work with swoole, if it works with normal PHP. On the other hand, they don't have much choice when it comes to PHP support :) Of the most important curl consumers, composer did not require updates, Symfony is already compatible with objects and Guzzle is being made compatible in guzzle/guzzle#2715. Of course, there is a long tail of less significant libraries. But at least based on the examples we have, the effort to be compatible with PHP 8 is quite minimal, as far as curl is concerned. |
Note that that PR is somewhat in complete. All phpdoc saying "resource" will need to be careful checked. Because there are no resource types in the language, we won't have errors shown to us by runtime typing. |
@GrahamCampbell Changes to phpdoc type hints are not relevant to this discussion, because that's something we cannot mitigate from the php-src side. You'll want to talk with the phpstan maintainer on how you can avoid false-positive warnings, or just disable checks. |
@nikic You're right, PHP kernel changes will force the community to make changes, it's good for us too, Thank you for your hard work :) |
In 8+ curl using objects instead of resources php/php-src#5402
The curl extension API was upgraded from a resource to an object in php/php-src#5402.
The curl extension API was upgraded from a resource to an object in php/php-src#5402.
This is a train-wreck yet... So I'd like to ask for a preliminary feedback before I start converting all the functions to use object.