Skip to content

Commit

Permalink
Sigsegv extension
Browse files Browse the repository at this point in the history
  • Loading branch information
fntlnz committed Jul 30, 2015
1 parent 5daadc9 commit 0dfc77b
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .travis/sigsegv-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.deps
.libs/sigsegv.la
.libs/sigsegv.lai
.libs/sigsegv.o
.libs/sigsegv.so
Makefile
Makefile.fragments
Makefile.global
Makefile.objects
acinclude.m4
aclocal.m4
autom4te.cache/output.0
autom4te.cache/requests
autom4te.cache/traces.0
config.guess
config.h
config.h.in
config.h.in~
config.log
config.nice
config.status
config.sub
configure
configure.in
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
modules/sigsegv.la
modules/sigsegv.so
run-tests.php
sigsegv.la
sigsegv.lo
25 changes: 25 additions & 0 deletions .travis/sigsegv-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## What is this?

This is an extension written for testing purposes.


## Provided functionalities

| Function | Expected result |
|-----------|----------------------------------|
| sigsegv() | segmentation fault (core dumped) |


## Build

```
phpize
./configure --with-sigsegv
make -j
```

## Usage

```
php -d extension=modules/sigsegv.so -r "sigsegv();"
```
8 changes: 8 additions & 0 deletions .travis/sigsegv-extension/config.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dnl config.m4 for extension sigsegv

PHP_ARG_WITH(sigsegv, whether to enable sigsegv support,
[ --enable-sigsegv Enable sigsegv])

if test "$PHP_SIGSEGV" != "no"; then
PHP_NEW_EXTENSION(sigsegv, sigsegv.c, $ext_shared)
fi
13 changes: 13 additions & 0 deletions .travis/sigsegv-extension/php_sigsegv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef PHP_SIGSEGV_H
#define PHP_SIGSEGV_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"

#define PHP_SIGSEGV_NAME "sigsegv"
#define PHP_SIGSEGV_VERSION "0.0.1"

#endif /* PHP_SIGSEGV_H */
30 changes: 30 additions & 0 deletions .travis/sigsegv-extension/sigsegv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "php_sigsegv.h"

PHP_FUNCTION (sigsegv) {
char *damn_pointer = "I am a damn pointer";
*damn_pointer = "So bad!";
}

PHP_MINIT_FUNCTION (sigsegv) {
return SUCCESS;
}

const zend_function_entry sigsegv_functions[] = {
PHP_FE(sigsegv, NULL)
PHP_FE_END};

zend_module_entry sigsegv_module_entry = {
STANDARD_MODULE_HEADER,
PHP_SIGSEGV_NAME,
sigsegv_functions,
PHP_MINIT(sigsegv),
NULL,
NULL,
NULL,
NULL,
PHP_SIGSEGV_VERSION,
STANDARD_MODULE_PROPERTIES };

#ifdef COMPILE_DL_SIGSEGV
ZEND_GET_MODULE(sigsegv)
#endif

0 comments on commit 0dfc77b

Please sign in to comment.