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

make test crash when using pcre jit #23

Closed
rainerjung opened this issue Dec 29, 2012 · 5 comments
Closed

make test crash when using pcre jit #23

rainerjung opened this issue Dec 29, 2012 · 5 comments

Comments

@rainerjung
Copy link

make test crashes with a segfault if configure was run with pcre jit enabled.
Crash happens in rx.t, e.g. in

./msc_test "-t" "op" "-n" "rx" "-p" "" "-D" "0" "-r" "1"

Stack shows that the problem is in apache2/re_operators.c:

998         rc = msc_fullinfo(regex, PCRE_INFO_JIT, &jit);
999         if ((rc != 0) || (jit != 1)) {

1000 *error_msg = apr_psprintf(rule->ruleset->mp,
1001 "Rule %pp [id "%s"][file "%s"][line "%d"] - "
1002 "Execution error - "
1003 "Does not support JIT (%d)",
1004 rule,((rule->actionset != NULL)&&(rule->actionset->id != NULL)) ? rule->actionset->id : "-",
1005 rule->filename != NULL ? rule->filename : "-",
1006 rule->line_num,rc);
1007 }

The rule used here has non-null actionset, but the id is set to 0xffffffff which can't be printed with %s.

The crash can be avoided by e.g. the following patch to tests/msc_test.c:

--- msc_test.c 2012-12-29 20:22:37.515480000 +0100
+++ msc_test.c 2012-12-29 20:23:32.392925000 +0100
@@ -325,9 +325,6 @@
*errmsg = apr_psprintf(g_mp, "Failed to create rule for op "%s": %s", name, *errmsg);
return -1;
}

  • if (data->rule->actionset != NULL) {
  •    data->rule->actionset->id = "1";
    
  • }

/* Create a fake variable */
data->var = (msre_var *)apr_pcalloc(g_mp, sizeof(msre_var));

Note that I don't know why the test entered the error path in line 999 above. It shouldn't crash though.

@brenosilva
Copy link
Contributor

Hello Rainer,

I cannot reproduce this issue. Could you tell me what pcre version and linux distro you are using ?
Thanks

@brenosilva
Copy link
Contributor

Can you try replace the *errmsg in re_operators.c to:

                *error_msg = apr_psprintf(rule->ruleset->mp,
                        "Rule %pp [id \"%s\"][file \"%s\"][line \"%d\"] - "
                        "Execution error - "
                        "Does not support JIT (%d)",
                        rule,((rule->actionset != NULL)&&((rule->actionset->id != NULL)&&
                                (rule->actionset->id != NOT_SET_P))) ? rule->actionset->id : "-",
                        rule->filename != NULL ? rule->filename : "-",
                        rule->line_num,rc);

Let me know if it fix the issue

@rainerjung
Copy link
Author

PCRE Version: PCRE 8.32

OS:

  • Solaris 10 Sparc gcc 4.7.2
  • SuSE SLES 11 x86_64 platform gcc
  • REHL 6 x86_64 platform gcc

all with custom build Apache

Of course it only happens with "--enable-pcre-jit".

Full configure line:

./configure
--without-curl
--with-apxs=/path/to/my/apache/bin/apxs
--with-apr=/path/to/my/apache/bin/apr-1-config
--with-apu=/path/to/my/apache/bin/apu-1-config
--with-libxml=/path/to/my/libxml2
--with-lua=/path/to/my/lua
--with-pcre=/path/to/my/pcre
--enable-pcre-jit
--disable-mlogc

Will test your suggested patch and report back.

@rainerjung
Copy link
Author

Yes, your patch fixes the test failures for me on all platforms.

Note that the same test against NULL but not against NOT_SET_P happens in 9 places in re_operators.c. Not sure whether the test against NOT_SET_P is needed in all those places.

Some similar checks occur in re.c. The file apache2_config.c seems OK to me.

@brenosilva
Copy link
Contributor

Fixed

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

2 participants