[go: up one dir, main page]

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

=== Total 1 memory leaks detected === zend_mm_heap corrupted Segmentation fault #13891

Closed
kamil-tekiela opened this issue Apr 5, 2024 · 2 comments · Fixed by #13892
Closed

Comments

@kamil-tekiela
Copy link
Member

Description

The following test case:

--TEST--
Bug #74892 Url Rewriting (trans_sid) not working on urls that start with #
--INI--
session.use_cookies=0
session.use_only_cookies=0
session.use_trans_sid=1
session.trans_sid_hosts=php.net
--EXTENSIONS--
session
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
ini_set('session.trans_sid_hosts','php.net');
session_id('sessionidhere');
session_start();

?>
<p><a href="index.php">Click This Anchor Tag!</a></p>
<p><a href="index.php#place">External link with anchor</a></p>
<p><a href="http://php.net#foo">External link with anchor 2</a></p>
<p><a href="#place">Internal link</a></p>
--EXPECT--
<p><a href="index.php?PHPSESSID=sessionidhere">Click This Anchor Tag!</a></p>
<p><a href="index.php?PHPSESSID=sessionidhere#place">External link with anchor</a></p>
<p><a href="http://php.net?PHPSESSID=sessionidhere#foo">External link with anchor 2</a></p>
<p><a href="#place">Internal link</a></p>

Resulted in this output:

TEST 1/1 [ext/session/tests/bug74892.phpt]
========DIFF========
--
     <p><a href="index.php?PHPSESSID=sessionidhere#place">External link with anchor</a></p>
     <p><a href="http://php.net?PHPSESSID=sessionidhere#foo">External link with anchor 2</a></p>
     <p><a href="#place">Internal link</a></p>
005+ [Fri Apr  5 20:37:59 2024]  Script:  '/mnt/d/projects/php-src/ext/session/tests/bug74892.php'
006+ /mnt/d/projects/php-src/Zend/zend_string.h(176) :  Freeing 0x00007f921c406740 (32 bytes), script=/mnt/d/projects/php-src/ext/session/tests/bug74892.php
007+ === Total 1 memory leaks detected ===
008+ zend_mm_heap corrupted
009+ Segmentation fault
010+
011+ Termsig=11

But I expected this output instead:
PASS

Happens on Ubuntu in WSL on the current master branch.

PHP Version

master

Operating System

Ubuntu 22.04.4 LTS

@nielsdos
Copy link
Member
nielsdos commented Apr 5, 2024

Given that it doesn't repro under USE_ZEND_ALLOC=0, this is very likely a persistent vs non-persistent allocation mess-up.
Are you taking a look already or shall I?

@kamil-tekiela
Copy link
Member Author

I am busy with other stuff so I am not keen on looking at this myself. But if you create a PR I can review it.

@nielsdos nielsdos self-assigned this Apr 5, 2024
nielsdos added a commit to nielsdos/php-src that referenced this issue Apr 5, 2024
….trans_sid_hosts

The hash tables used are allocated via the persistent allocator.
When using ini_set, the allocation happens via the non-persistent
allocator. When the table is then freed in GSHUTDOWN, we get a crash
because the allocators are mismatched.

As a side note, it is strange that this is designed this way, because it
means that ini_sets persist between requests...

Test credits go to Kamil Tekiela.
nielsdos added a commit that referenced this issue Apr 6, 2024
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
nielsdos added a commit that referenced this issue Apr 6, 2024
* PHP-8.3:
  [ci skip] NEWS
  Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants