Skip to content

Fix hashtable inconsist when specify an invalid path to ini: phar.cache_... - #161

Closed
reeze wants to merge 1 commit into
php:PHP-5.3from
reeze:fix-phar-test-failed
Closed

reeze wants to merge 1 commit into
php:PHP-5.3from
reeze:fix-phar-test-failed

Conversation

@reeze

@reeze reeze commented Aug 14, 2012

Copy link
Copy Markdown
Contributor

when specify an invalide phar.cache_list in PHP5.3 will report hashtable inconsist.

$php -d phar.cache_list=/invalid a.php

The reason and the fix is almost the same as @laruence ever fixed bug#62597 (segfault in php_stream_wrapper_log_error with ZTS build) in PHP-5.4 e7535e0 .
but crash in different place. so I didn't fill a bug.
either merge or cherry-pick from 5.4 are fine for me :)

BT:

Breakpoint 1, _php_stream_open_wrapper_ex (path=0x100d36838 "/a", mode=0x1009dde00 "rb", options=18, opened_path=0x7fff5fbfe528, context=0x0, __php_stream_call_depth=0, __zend_filename=0x1009e5ba0 "/Users/reeze/Opensource/php-test/php-src-5.3/ext/phar/phar.c", __zend_lineno=1503, __zend_orig_filename=0x0, __zend_orig_lineno=0, tsrm_ls=0x100e03a20) at streams.c:1936
1936        php_stream *stream = NULL;
(gdb) c
Continuing.

Breakpoint 2, php_stream_tidy_wrapper_error_log (wrapper=0x100a9a0a0, tsrm_ls=0x100e03a20) at streams.c:230
230     if (wrapper && FG(wrapper_errors)) {
(gdb) c
Continuing.
/Users/reeze/Opensource/php-test/php-src-5.3/Zend/zend_hash.c(463) : ht=0x10050b050 is inconsistent
/Users/reeze/Opensource/php-test/php-src-5.3/Zend/zend_hash.c(70) : Bailed out without a bailout address!

And this fixed the following failed tests(PHP-5.3):

Phar: copy-on-write test 13 [cache_list] [ext/phar/tests/cache_list/copyonwrite13.phar.phpt]
Phar: copy-on-write test 14 [cache_list] [ext/phar/tests/cache_list/copyonwrite14.phar.phpt]
Phar: copy-on-write test 21 [cache_list] [ext/phar/tests/cache_list/copyonwrite21.phar.phpt]
Phar: copy-on-write test 22 [cache_list] [ext/phar/tests/cache_list/copyonwrite22.phar.phpt]
Phar: copy-on-write test 4a [cache_list] [ext/phar/tests/cache_list/copyonwrite4a.phpt]
Phar front controller other [ext/phar/tests/cache_list/frontcontroller1.phpt]
Phar front controller mime type extension is not a string [cache_list] [ext/phar/tests/cache_list/frontcontroller11.phpt]
Phar front controller PHP test [cache_list] [ext/phar/tests/cache_list/frontcontroller2.phpt]
Phar: phpinfo display 3 [ext/phar/tests/phpinfo_003.phpt]

…he_list

This fixed the following failed tests(This is PHP-5.3 only):

Phar: copy-on-write test 13 [cache_list] [ext/phar/tests/cache_list/copyonwrite13.phar.phpt]
Phar: copy-on-write test 14 [cache_list] [ext/phar/tests/cache_list/copyonwrite14.phar.phpt]
Phar: copy-on-write test 21 [cache_list] [ext/phar/tests/cache_list/copyonwrite21.phar.phpt]
Phar: copy-on-write test 22 [cache_list] [ext/phar/tests/cache_list/copyonwrite22.phar.phpt]
Phar: copy-on-write test 4a [cache_list] [ext/phar/tests/cache_list/copyonwrite4a.phpt]
Phar front controller other [ext/phar/tests/cache_list/frontcontroller1.phpt]
Phar front controller mime type extension is not a string [cache_list] [ext/phar/tests/cache_list/frontcontroller11.phpt]
Phar front controller PHP test [cache_list] [ext/phar/tests/cache_list/frontcontroller2.phpt]
Phar: phpinfo display 3 [ext/phar/tests/phpinfo_003.phpt]
@travisbot

Copy link
Copy Markdown

This pull request fails (merged 3a083f2 into da14cdd).

@php-pulls

Copy link
Copy Markdown

Comment on behalf of laruence at php.net:

thanks, fixed in : 8848778

@php-pulls php-pulls closed this Aug 14, 2012
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 12, 2026
…uctors, events and init

Mago php#152 merged Mago master's named constructors (php#161), events (php#162) and
the `init` accessor (php#169), so this branch pinned a Mago without them, and
the spec examples that use them still failed here.

The engine now builds from Mago 1b517f4. The generated header changes only
in the commit it names. Six more spec examples pass and leave the baseline,
written with the `cp` command `sharp/bin/test --spec` prints:
- §9.1 constructor-call-this, named-constructors and set-once
- §15 extern-event, extern-event-effects and standalone-event

ext/sharp/sharp_unit.h   <- names Mago 1b517f4
sharp/baseline/spec      <- the six examples that now pass leave it
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
Problem

master gained named constructors (php#161), which take bit 46 of `MetadataFlags` for
`NAMED_CONSTRUCTOR` and build a `MethodParts` of their own.

Solution

`MetadataFlags::EVENT` moves to bit 47, and a named constructor listens to no
event, as an operator does.

Files

crates/
├── codex/src/metadata/flags.rs               <- EVENT is 1 << 47
└── names/src/binding.rs                      <- of_named_constructor sets `on: None`
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
Problem

Section 15 lands in fewer PRs: a listener's `on` clause joins `emit` in one
mago-sharp PR, instead of a third PR of its own. feat/events-on also brings
master's named constructors (php#161) and `init` accessor (php#169), which take bits
46 and 47 of `MetadataFlags`. Each branch had its own test of what an event
is.

Solution

- `MetadataFlags::EVENT` is `1 << 48`, after `NAMED_CONSTRUCTOR` and `INIT`.
- The listener checks use `is_event_class`, the one test `emit` uses, so an
  `extern event` counts only on a class for both.
- The fingerprint tests keep both new rows.

Files

crates/
├── codex/src/metadata/flags.rs               <- EVENT is 1 << 48
├── analyzer/src/statement/class_like/listener.rs <- uses is_event_class
└── fingerprint/tests/signature_changes.rs    <- both rows
heyJordanParker added a commit to heyJordanParker/php-sharp that referenced this pull request Oct 13, 2026
Problem: master merged php#161, named constructors, and php#162, events and the
interface's get-only property, after d3adf51, the last master this branch
merged. Both change `new`, the class member parser, the checker's walk, the
analyzer's `return` and lambda lowering, which the generics slice changes too,
so 15 files conflicted and the PR could not merge.

Solution: merge 7236cd0 with no rebase, keeping both sides' behavior in
every conflict, then fix four places where one side stopped the other's
behavior from taking effect:

Keep both sides of each conflict:
- `new` carries both the type arguments and the named constructor, so
  `new PaginatedList<Order>(rows)` and `new Artifact.fromJson(json)` both lower
- the `return` check takes master's named constructor return type and this
  branch's `expect_type` and generic `static` type
- a lambda keeps this branch's lowering, which also captures its method's
  type arguments; master's `Node` argument to `closure_uses` read only a span
- the checker's notes name type parameters and named constructors together

Write `Class<Order>` as a member's type again:
- master's nested-type refusal took any member that starts with `class` for a
  nested class; `class` followed by `<` is now the type `Class<…>`, since a
  declared class names itself first

Refuse a named constructor in a generic class with a true message:
- a named constructor runs as a static method, which a generic class's type
  arguments reach only in R4, so a generic class declared one with the false
  error "`Box` needs its type argument"; it is now "not supported yet", and a
  call of one adds no type argument error the user has no place to write

Check a generic interface's property against the header's type argument:
- master's check compared a class's property with the interface's raw type
  parameter, so `string item` under `: Holder<int>` compiled; the stated type
  now reads `TItem` as the header's `int`

Keep an event's header type arguments for the engine:
- an event's header, as in `: Holder<int>`, now lowers its type text list as
  a class's does, so the engine knows the event is a `Holder<int>`

crates/
├── analyzer/
│   ├── src/expression/instantiation.rs        <- `new` takes type arguments and a named constructor
│   ├── src/statement/class_like/mod.rs        <- both signature checks, the localized interface property type
│   ├── src/statement/return.rs                <- named constructor return type with expect_type
│   └── tests/sharp.rs                         <- both sides' tests, the named constructor call and generic interface property tests
├── codex/src/scanner/
│   ├── class_like.rs                          <- an event declares no type parameters
│   └── function_like.rs                       <- an event's parameters read an empty type context
├── names/
│   ├── src/binding.rs                         <- a named constructor declares no type parameters
│   └── src/internal/walker.rs                 <- the event walk beside the method type parameters
├── semantics/
│   ├── src/internal/checker/sharp.rs          <- both sides' places and notes, the generic class named constructor refusal
│   └── tests/sharp.rs                         <- the arity test, the merged notes, the refusal test
├── sharp-bridge/
│   ├── src/lower.rs                           <- named constructor and generic `new`, lambdas, the event's header type arguments
│   └── tests/lower.rs                         <- both sides' tests, the event header test
└── syntax/
    ├── src/cst/cst/instantiation.rs           <- `new` holds both fields
    ├── src/cst/node.rs, src/walker/mod.rs     <- both fields are walked
    ├── src/parser/internal/class_like/method.rs  <- `class<` is the type `Class<…>`
    ├── src/parser/internal/expression.rs      <- a named constructor call has no type arguments
    ├── src/parser/internal/instantiation.rs   <- `new` parses type arguments, no named constructor
    ├── src/parser/internal/statement.rs       <- the event statement beside a `Class<…>` local
    └── tests/sharp.rs                         <- named constructors leave the not-supported rows
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

Successfully merging this pull request may close these issues.

4 participants