Fwd: Segmentation fault using python PJSUA2 when running tutorial code

LB
Luke Biddle
Mon, Nov 27, 2017 7:11 AM

Hi,

I've been getting a consistent segmentation fault when using the python
SWIG module for PJSUA2. The code I've been running is straight from the
PJSUA2 tutorial (http://www.pjsip.org/docs/book-latest/html/intro_pjsua2.
html#using-in-python-application).

The code begins executing correctly, and will successfully register to the
uri I specify. Then the segfault occurs and halts the program at some point
after the acc.create(acfg) call. The segfault must be related to the
inheritance of pj.Account, based on the following:

  • the contents of the onRegState callback are never printed
  • the segfault also occurs when I define my Account class as empty (with a
    pass in the body)
  • the segfault does not occur if I change the example to instantiate
    pj.Account directly instead of inheriting from it

It also must be something to do with SWIG specifically, as I am able to run
the equivalent C++ example without any crash.

The segfault only happens when the registration is successful.

My setup is using asterisk as a PBX, with the example script registering to
it. Watching asterisk while running the script confirms that the SIP peer
is registering successfully, and the output from the script shows the
"SIP/2.0 200 OK" being returned immediately before the segfault.

I have reproduced the crash using python 2.7, 3.5, 3.6, and on Fedora 25,
Fedora 27, and Ubuntu 16.04.3 LTS.

Has anyone else been seeing this issue? Is it working normally for some
people? Are there any tips for working around it, i.e. getting registration
success/failure, incoming calls, etc, without inheriting Accounts? Or maybe
I'm installing something wrong?

I am compiling and running the latest pjproject from svn (rev 5702). I have
also tried out releases 2.6 and 2.7 with the same results. These are my
compile steps (run as root):
dnf install python-devel python3-devel
dnf install gcc gcc-c++
dnf install kernel-devel
dnf install alsa-lib-devel
dnf install svn
dnf install swig
dnf install java-1.8.0-openjdk
dnf install java-1.8.0-openjdk-devel
dnf install redhat-rpm-config

cd /opt
svn co http://svn.pjsip.org/repos/pjproject/trunk pjproject
cd pjproject
export CFLAGS="$CFLAGS -fPIC" && ./configure
make dep
make
make install
cd pjsip-apps/src/swig/
sed -i '43s/.*/\t$(PYTHON_EXE) setup.py install/' python/Makefile  #
Removes --user flag from setup.py call to install for all users
make
make install

To install asterisk:
dnf install asterisk
dnf install asterisk-sip
Replace sip.conf and extensions.conf with attached copies
systemctl restart asterisk  # Occasionally needs a reboot
asterisk -vvvr  # To watch

Thanks,

Luke

Hi, I've been getting a consistent segmentation fault when using the python SWIG module for PJSUA2. The code I've been running is straight from the PJSUA2 tutorial (http://www.pjsip.org/docs/book-latest/html/intro_pjsua2. html#using-in-python-application). The code begins executing correctly, and will successfully register to the uri I specify. Then the segfault occurs and halts the program at some point after the acc.create(acfg) call. The segfault must be related to the inheritance of pj.Account, based on the following: - the contents of the onRegState callback are never printed - the segfault also occurs when I define my Account class as empty (with a pass in the body) - the segfault does not occur if I change the example to instantiate pj.Account directly instead of inheriting from it It also must be something to do with SWIG specifically, as I am able to run the equivalent C++ example without any crash. The segfault only happens when the registration is successful. My setup is using asterisk as a PBX, with the example script registering to it. Watching asterisk while running the script confirms that the SIP peer is registering successfully, and the output from the script shows the "SIP/2.0 200 OK" being returned immediately before the segfault. I have reproduced the crash using python 2.7, 3.5, 3.6, and on Fedora 25, Fedora 27, and Ubuntu 16.04.3 LTS. Has anyone else been seeing this issue? Is it working normally for some people? Are there any tips for working around it, i.e. getting registration success/failure, incoming calls, etc, without inheriting Accounts? Or maybe I'm installing something wrong? I am compiling and running the latest pjproject from svn (rev 5702). I have also tried out releases 2.6 and 2.7 with the same results. These are my compile steps (run as root): dnf install python-devel python3-devel dnf install gcc gcc-c++ dnf install kernel-devel dnf install alsa-lib-devel dnf install svn dnf install swig dnf install java-1.8.0-openjdk dnf install java-1.8.0-openjdk-devel dnf install redhat-rpm-config cd /opt svn co http://svn.pjsip.org/repos/pjproject/trunk pjproject cd pjproject export CFLAGS="$CFLAGS -fPIC" && ./configure make dep make make install cd pjsip-apps/src/swig/ sed -i '43s/.*/\t$(PYTHON_EXE) setup.py install/' python/Makefile # Removes --user flag from setup.py call to install for all users make make install To install asterisk: dnf install asterisk dnf install asterisk-sip Replace sip.conf and extensions.conf with attached copies systemctl restart asterisk # Occasionally needs a reboot asterisk -vvvr # To watch Thanks, Luke