Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

NSPredicate also lacks NSSecureCoding and -allowEvaluation

Open
#766 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Quiet
Tech stack
objective-c
Domain
backend

Research direction

Start by reading NSPredicate and its concrete predicate subclasses, especially their encodeWithCoder: implementations; the issue notes that current master already implements coding for compound and comparison predicates and expressions. Compare the GNUstep APIs with the stated NSSecureCoding and allowEvaluation requirements, then run or extend tests for archiving, secure decoding, and predicate evaluation. Done means predicate archives round-trip without crashing and the missing API behavior is covered.

Written by the indexing model from the issue text.

Description

Environment: gnustep-base 1.29.0 (Ubuntu 24.04 packages, GCC ObjC runtime, libobjc.so.4)

Summary:

  • Archiving any NSPredicate with NSKeyedArchiver crashes with SIGSEGV — even [NSPredicate predicateWithValue:YES]. In 1.29.0, -[NSPredicate encodeWithCoder:] and the concrete subclass implementations are // FIXME stubs calling [self subclassResponsibility: _cmd]; instead of a catchable NSInvalidArgumentException, the process segfaults inside objc_msg_lookup during the archive. (Current master`` implements coding for compound/comparison predicates and expressions, so newer builds are partly fixed, but 1.29.x, as shipped by distros, crashes.)
  • NSPredicate does not conform to NSSecureCoding (Apple: conforms since macOS 10.13/iOS 11).
  • NSPredicate does not implement -allowEvaluation (Apple API since macOS 10.9/iOS 7, used after secure decoding). Code portable with Apple Foundation that unarchives predicates must call it, so its absence forces respondsToSelector: workarounds.

Reproduction:

#import <Foundation/Foundation.h>

int main(void)
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];

    NSPredicate *p = [NSPredicate predicateWithValue:YES];  // simplest case
    // Also crashes with: [NSPredicate predicateWithFormat:@"NOT (SELF < 0)"]

    NSLog(@"responds to allowEvaluation: %d",
          [p respondsToSelector:NSSelectorFromString(@"allowEvaluation")]);   // 0
    NSLog(@"conforms to NSSecureCoding: %d",
          [[p class] conformsToProtocol:@protocol(NSSecureCoding)]);          // 0

    NS_DURING
        NSData *d = [NSKeyedArchiver archivedDataWithRootObject:p];           // SIGSEGV here
        NSLog(@"archived %lu bytes", (unsigned long)[d length]);
    NS_HANDLER
        NSLog(@"EXCEPTION: %@", localException);                               // never reached
    NS_ENDHANDLER

    [pool drain];
    return 0;
}

Actual output:

responds to allowEvaluation: 0
conforms to NSSecureCoding: 0
Segmentation fault (core dumped)

Expected: On Apple Foundation the same program archives the predicate successfully and round-trips it via NSKeyedUnarchiver (with -allowEvaluation needed before evaluating a securely decoded predicate). At minimum, an unimplemented encodeWithCoder: should raise a catchable exception rather than segfault.

Impact: Any framework that archives model metadata containing predicates (e.g., CoreData-style validationPredicates in a compiled model) cannot serialize predicates on GNUstep and must fall back to storing predicate format strings.

Dominant language
Objective-C
Stars
997
Forks
305
Avg merge
1d 20h
Merged PRs (30d)
56

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gnustep/libs-base

All issues in gnustep/libs-base

Similar issues

More Objective-C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.