Skip to content

cygwin-x64版本在协程中用file_get_contents取URL会崩溃 #5760

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

Open
skyshore2001 opened this issue May 9, 2025 · 0 comments
Open

Comments

@skyshore2001
Copy link

似乎仅在windows上发生,测试过swoole-cli 5.1.7和4.8.7。

测试程序如下,正常运行完成后应显示"done",但常常运行中就崩溃掉,看不到"done"显示出来。
在5.1.7版本上测试有时能成功,有时很快崩溃,崩溃时没有消息。
而在4.8.7上更容易重现,崩溃时显示消息:0 [main] swoole-cli 1522 cygwin_exception::open_stackdumpfile: Dumping stack trace to swoole-cli.exe.stackdump

<?php

// 无论是否hook,都会可能崩溃
//Co::set(['hook_flags' => SWOOLE_HOOK_ALL]);

Co\run(function () {
	global $cnt;
	$cnt = 0;
	for ($i=0; $i<100; ++$i) {
		go(function () {
			global $cnt;
			for ($i=0; $i<300; ++$i) {
				$url = "http://127.0.0.1:8081/1.txt";
				$rv = file_get_contents($url);    // 可以用下面的服务端代码配合测试
				if ($cnt % 1000 == 0) {
					echo("$cnt\n");
				}
				++ $cnt;
			}
		});
	}
});
echo('done');

写个服务端程序配合上面file_get_contents访问:

<?php
$server = new Swoole\Http\Server("0.0.0.0", 8081, SWOOLE_PROCESS);
$server->set([
	'worker_num'=>1
]);

$server->on('Request', function ($req, $res) {
	$id = rand(100,999);
	$res->end("[0,$id]");
});

$server->start();
@skyshore2001 skyshore2001 changed the title windows版在协程中用file_get_contents取URL会崩溃 cygwin-x64版本在协程中用file_get_contents取URL会崩溃 May 11, 2025
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