Newsgroups: php.cvs,php.internals Path: news.php.net Xref: news.php.net php.cvs:128074 php.internals:123110 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 7CB1C1A009C; Thu, 11 Apr 2024 13:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712840877; bh=svu560tiP3Iip+CQvXjfRENEn22o2mkdgUuJbvJe5zw=; h=Date:Subject:To:References:Cc:From:In-Reply-To:From; b=gQCf4UMGrIQ+A8BHK1o0dqTgGxV0S6+xPmUOGrzw+gqbOIrPc07aKXA7SEjuFv7XV A8e43EOhF/h3gdSpsVYrkNbCPQKxUPU6tzs3wKzs/2qrmh2jZy5EiBgEdNMJ7kU9C9 +qKkUbUImPb2rLQIuC1bm/AhdurX9R3WVDELEet+zALGgFGaYlg0H+Li66nGLSB0Je UuT0fNN9nOtGNnnhJkzfp9HC9JxWgFaue3XUVkOu9zQNZrEoIKxpjH9kxmvdxd3YOt KjDuakqfQ3IH4dqEw9QxShoi9Upz2xN3TyDxflfE9zA/UbzEsItaJLOPhk/mF1RONP tcF89+2rWrVZA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AC1841801C7; Thu, 11 Apr 2024 13:07:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS; Thu, 11 Apr 2024 13:07:54 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5F9BC114008C; Thu, 11 Apr 2024 09:07:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 11 Apr 2024 09:07:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beccati.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1712840841; x=1712927241; bh=SNnTkDw/S+fvt62Gun5QYiLbxBEkFvrisU++H2cC6AA=; b= iYxny6STa7hDA8dZtL80zT9QjkcE/GD2qviBDiLO88uOM17A/8LlBIyM87Wv+lsG cT1kkAn8XM4ncokAX+VKmmnYM53OXCOqEJY7aG2/zg/WrsiiLOTR3LKxlgAox0D3 MKQiyLIrrLR86HJ3+wLmXkhBWrQCPpXIFwIQ83qTOg5iZpHakobCRyEN5dohFdXF GmtJIjaf9vfSo7H4aoB1qmLRBGhw2quLhrh6qVh9gfDAElREZUfoLaWGMsvMBwvL Evo3pd+Epn3UslrytZ1uoDGyEzx0v4M0c5w4zRRgv2ImR/KQEUeqQ1HuyEvsDVoF 23mfkQJFoTHGt8xNqngsnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712840841; x= 1712927241; bh=SNnTkDw/S+fvt62Gun5QYiLbxBEkFvrisU++H2cC6AA=; b=B cK3ApEXl/Mr45OtUkZpIk/PAc1IMQTLjVzTrK5iEIawzCj/KuT+3bN9kIl/wJt/+ r6/lWjut1s3U5faayIhN2AZ83IwMAW0yca40gLl5dCml0GRDEC1ipfPOaDAAShBl TwAizSlpX2YoSmdvpA/MLExMC3I0q6hq0pNr5hCskCHUy98U6MzNp0phEH39uWDr 5nCRK3hdnAZKE47U95oyqqKN5qKwnJRFlW92Cs82frV8EZ4Lrf0ENuiEhOTiOoIs AoWu4nLGmDoDNx5QSPdpF3R9q2Rb0IgQzuG9ONWtxCOtjmPeQWVTu1UWN3+Rc0GM thquQcuJhdTXov0CDastA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehkedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhevhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeforght thgvohcuuegvtggtrghtihcuoehphhhpsegsvggttggrthhirdgtohhmqeenucggtffrrg htthgvrhhnpeejjeevveegleetudeivdeiuefhheeuveektedvffegveejiedtjeegfeei veegvdenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhmhihsqhhlrdgtohhmpdgsvg gttggrthhirdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepphhhphessggvtggtrghtihdrtghomh X-ME-Proxy: Feedback-ID: i6f4c46c2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Apr 2024 09:07:20 -0400 (EDT) Message-ID: <2906b71c-811e-40ff-a58b-a306a5ee4f96@beccati.com> Date: Thu, 11 Apr 2024 15:07:16 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PHP-DEV] Re: [PHP-CVS] [php-src] master: ext/mysqlnd: support ER_CLIENT_INTERACTION_TIMEOUT To: Appla , Kamil Tekiela References: Content-Language: it Cc: php-cvs@lists.php.net, "internals@lists.php.net" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: php@beccati.com (Matteo Beccati) Hi, I've left a comment on github, but perhaps it is best I also post here: The commit is breaking several tests on doctrine/dbal. Spedifically 2 tests on the 3.8.x branch and 5 tests on the 4.0.x: https://github.com/mbeccati/php-latest-builds/runs/23707742797 This could mean it is not working properly or it is not fully safe for 8.2 / 8.3. Cheers Il 10/04/2024 13:38, Appla via Kamil Tekiela ha scritto: > Author: Appla (Appla) > Committer: Kamil Tekiela (kamil-tekiela) > Date: 2024-04-10T13:33:04+02:00 > > Commit: https://github.com/php/php-src/commit/5035b8509016c4cf2cda883b4d3f245054a71626 > Raw diff: https://github.com/php/php-src/commit/5035b8509016c4cf2cda883b4d3f245054a71626.diff > > ext/mysqlnd: support ER_CLIENT_INTERACTION_TIMEOUT > > Closes GH-13618. > > Changed paths: > A ext/mysqli/tests/bug81335.phpt > M NEWS > M ext/mysqlnd/mysqlnd_enum_n_def.h > M ext/mysqlnd/mysqlnd_result.c > M ext/mysqlnd/mysqlnd_wireprotocol.c > > > Diff: > > diff --git a/NEWS b/NEWS > index bfd2617878d5f..e96e9bbc4fe06 100644 > --- a/NEWS > +++ b/NEWS > @@ -16,6 +16,8 @@ PHP NEWS > > - MySQLnd: > . Fix shift out of bounds on 32-bit non-fast-path platforms. (nielsdos) > + . Fixed bug #81335 (PHP Warning, Packets out of order after connection > + timeout). (Appla) > > - OpenSSL: > . Fixed bug GH-10495 (feof on OpenSSL stream hangs indefinitely). > diff --git a/ext/mysqli/tests/bug81335.phpt b/ext/mysqli/tests/bug81335.phpt > new file mode 100644 > index 0000000000000..26f6bcd7e2d14 > --- /dev/null > +++ b/ext/mysqli/tests/bug81335.phpt > @@ -0,0 +1,34 @@ > +--TEST-- > +Bug #81335: Packets out of order after connection timeout > +--EXTENSIONS-- > +mysqli > +--SKIPIF-- > + +if (PHP_OS === 'WINNT') die('skip on windows'); > +if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); > + > +require_once 'connect.inc'; > +if (!$link = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) die("skip cannot connect"); > +if (mysqli_get_server_version($link) < 80024 || str_contains(mysqli_get_server_info($link), 'MariaDB')) { > + die("skip: Due to many MySQL Server differences, the test requires >= 8.0.24"); > +} > +?> > +--FILE-- > + + > +require_once 'connect.inc'; > +mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); > +$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket); > +$mysqli->query('SET WAIT_TIMEOUT=1'); > +usleep(1000000 * 1.1); > +try { > + $mysqli->query('SELECT 1 + 1'); > +} catch(mysqli_sql_exception $e) { > + echo $e->getMessage(); > + echo "\n"; > + echo $e->getCode(); > +} > +?> > +--EXPECTF-- > +The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior. > +4031 > diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h > index 110e62c71bab0..00b46e8c7d22d 100644 > --- a/ext/mysqlnd/mysqlnd_enum_n_def.h > +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h > @@ -130,6 +130,7 @@ > #define CR_INVALID_PARAMETER_NO 2034 > #define CR_INVALID_BUFFER_USE 2035 > #define CR_LOAD_DATA_LOCAL_INFILE_REJECTED 2068 > +#define CR_CLIENT_INTERACTION_TIMEOUT 4031 > > #define MYSQLND_EE_FILENOTFOUND 7890 > > diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c > index 0331518d7d3d6..cf5013ed42d51 100644 > --- a/ext/mysqlnd/mysqlnd_result.c > +++ b/ext/mysqlnd/mysqlnd_result.c > @@ -185,7 +185,7 @@ mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * s) > UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status); > > if (FAIL == (ret = PACKET_READ(conn, &rset_header))) { > - if (conn->error_info->error_no != CR_SERVER_GONE_ERROR) { > + if (conn->error_info->error_no != CR_SERVER_GONE_ERROR && conn->error_info->error_no != CR_CLIENT_INTERACTION_TIMEOUT) { > php_error_docref(NULL, E_WARNING, "Error reading result set's header"); > } > break; > diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c > index fed191c74fa52..16ca9aaf29d42 100644 > --- a/ext/mysqlnd/mysqlnd_wireprotocol.c > +++ b/ext/mysqlnd/mysqlnd_wireprotocol.c > @@ -267,6 +267,19 @@ mysqlnd_read_header(MYSQLND_PFC * pfc, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER > pfc->data->packet_no++; > DBG_RETURN(PASS); > } > + // @see https://dev.mysql.com/worklog/task/?id=12999 > + if (header->size > 0) { > + zend_uchar *buf = mnd_emalloc(header->size); > + if ((PASS == pfc->data->m.receive(pfc, vio, buf, header->size, conn_stats, error_info)) && buf[0] == ERROR_MARKER) { > + php_mysqlnd_read_error_from_line(buf + 1, header->size - 1, > + error_info->error, sizeof(error_info->error), > + &error_info->error_no, error_info->sqlstate > + ); > + mnd_efree(buf); > + DBG_RETURN(FAIL); > + } > + mnd_efree(buf); > + } > > DBG_ERR_FMT("Logical link: packets out of order. Expected %u received %u. Packet size=%zu", > pfc->data->packet_no, header->packet_no, header->size); > @@ -294,7 +307,9 @@ mysqlnd_read_packet_header_and_body(MYSQLND_PACKET_HEADER * packet_header, > DBG_INF_FMT("buf=%p size=%zu", buf, buf_size); > if (FAIL == mysqlnd_read_header(pfc, vio, packet_header, stats, error_info)) { > SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT); > - SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); > + if (error_info->error_no == 0) { > + SET_CLIENT_ERROR(error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); > + } > DBG_ERR_FMT("Can't read %s's header", packet_type_as_text); > DBG_RETURN(FAIL); > } -- Matteo Beccati Development & Consulting - http://www.beccati.com/