mingw64 pjsip sizeof(fd_set) always double sizeof(pj_fd_set_t) causing assertion in sock_select.c

MA
Michael A. Leonetti
Thu, Jun 27, 2019 4:08 PM

Hello all,

Long time user first time caller. Nice to meet you all!

I'm trying to get pjsip to work on Windows. I've compiled pjsip into my
program that I'm writing in an msys2/mingw environment (64-bit). It
compiles fine. However, when I run it in my program I'm getting an assertion

|// Line 49 of
../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)|

Every time I run the program.

When I do some digging people talk about increasing
PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function
before the asserts to see what the sizes are:

|// My PJ_FD_ZERO
variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES:
%d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set:
%I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}|

The program will output something like this:

|10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized
10:27:43.507sip_endpoint.c .Creatingendpoint
instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080|

However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t
increases /as it should/ but! the sizeof(fd_set) also becomes slight
less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide says
that I cannot set the size of fd_set so I am very confused how the size
is getting set! I don't see anywhere in the pjsip code that this is
being set.

So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle.

How can I fix this so my code will stop asserting?

The bash script that I ran to configure pjsip

|#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true CLEAN_BEFORE_BUILD=false
TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am
Makefile.in"whilegetopts ":pdj:o:c"opt;docase$opt
inj)JOPT="$OPTARG";;c)echo "Clean before build is
set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=', 'read -r -a
BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption
in"${BUILD_OPTS[@]}";do# Set individualcase$option
inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option ${option}"exit
esacdone;;?)echo "Invalid option: -${OPTARG}">&2exit 1;;:)echo
"Option -${OPTARG} requires an argument.">&2exit 1;;esacdone# Make the
outmkdir out OUT_PREFIX="$( pwd )/out"export
PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true
];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main
directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd #
pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true
]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure
CFLAGS="${MAKEFLAGS}
-I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\
--prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \
--disable-ffmpeg \ --enable-libsamplerate \ --disable-video \
--enable-shared \ --disable-static \ --disable-libyuv \
--with-external-speex \ --with-gnutls \ ||exit
if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it
breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j $JOPT
||exit # Note, had issue with writing to
//c/.../pkgconfig/libproject.pcmake install ||exit fi|

--
Michael A. Leonetti
As warm as green tea

Hello all, Long time user first time caller. Nice to meet you all! I'm trying to get pjsip to work on Windows. I've compiled pjsip into my program that I'm writing in an msys2/mingw environment (64-bit). It compiles fine. However, when I run it in my program I'm getting an assertion > |// Line 49 of > ../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)| Every time I run the program. When I do some digging people talk about increasing PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function before the asserts to see what the sizes are: > |// My PJ_FD_ZERO > variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES: > %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: > %I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}| The program will output something like this: > |10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized > 10:27:43.507sip_endpoint.c .Creatingendpoint > instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080| However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t increases /as it should/ but! the sizeof(fd_set) also becomes slight less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide says that I cannot set the size of fd_set so I am very confused how the size is getting set! I don't see anywhere in the pjsip code that this is being set. So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle. How can I fix this so my code will stop asserting? *The bash script that I ran to configure pjsip* > |#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true CLEAN_BEFORE_BUILD=false > TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am > Makefile.in"whilegetopts ":pdj:o:c"opt;docase$opt > inj)JOPT="$OPTARG";;c)echo "Clean before build is > set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=', 'read -r -a > BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption > in"${BUILD_OPTS[@]}";do# Set individualcase$option > inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option ${option}"exit > esacdone;;\?)echo "Invalid option: -${OPTARG}">&2exit 1;;:)echo > "Option -${OPTARG} requires an argument.">&2exit 1;;esacdone# Make the > outmkdir out OUT_PREFIX="$( pwd )/out"export > PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true > ];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main > directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd # > pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true > ]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure > CFLAGS="${MAKEFLAGS} > -I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\ > --prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \ > --disable-ffmpeg \ --enable-libsamplerate \ --disable-video \ > --enable-shared \ --disable-static \ --disable-libyuv \ > --with-external-speex \ --with-gnutls \ ||exit > if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it > breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j $JOPT > ||exit # Note, had issue with writing to > //c/.../pkgconfig/libproject.pcmake install ||exit fi| -- Michael A. Leonetti As warm as green tea
MA
Michael A. Leonetti
Fri, Jun 28, 2019 3:44 PM

All,

In tracking this bug it looks like on configure the flags for PJ_WIN32
are not being set for the build. The system isn't being detected as
mingw although it is provided in the target as seen below:
x86_64-w64-mingw32

checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
checking target system type... x86_64-w64-mingw32

For this reason, it seems that WIN64 is not being detected and pj_sock_t
is not being set to the proper value as shown below in
pjlib/include/pj/types.h:

/** Socket handle. */
#if defined(PJ_WIN64) && PJ_WIN64!=0
    typedef pj_int64_t pj_sock_t;
#else
    typedef long pj_sock_t;
#endif

And thus pj_fd_set_t is smaller than fd_set probably because fd_set is
using a bigger type for fd.

That's at least what I've come up with.

Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1 which
it is being detected?

Michael A. Leonetti
As warm as green tea

On 6/27/19 12:08 PM, Michael A. Leonetti wrote:

Hello all,

Long time user first time caller. Nice to meet you all!

I'm trying to get pjsip to work on Windows. I've compiled pjsip into
my program that I'm writing in an msys2/mingw environment (64-bit). It
compiles fine. However, when I run it in my program I'm getting an
assertion

|// Line 49 of
../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)|

Every time I run the program.

When I do some digging people talk about increasing
PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function
before the asserts to see what the sizes are:

|// My PJ_FD_ZERO
variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES:
%d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set:
%I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}|

The program will output something like this:

|10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized
10:27:43.507sip_endpoint.c .Creatingendpoint
instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080|

However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t
increases /as it should/ but! the sizeof(fd_set) also becomes slight
less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide
says that I cannot set the size of fd_set so I am very confused how
the size is getting set! I don't see anywhere in the pjsip code that
this is being set.

So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle.

How can I fix this so my code will stop asserting?

The bash script that I ran to configure pjsip

|#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true CLEAN_BEFORE_BUILD=false
TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am
Makefile.in"whilegetopts ":pdj:o:c"opt;docase$opt
inj)JOPT="$OPTARG";;c)echo "Clean before build is
set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=', 'read -r -a
BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption
in"${BUILD_OPTS[@]}";do# Set individualcase$option
inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option
${option}"exit esacdone;;?)echo "Invalid option: -${OPTARG}">&2exit
1;;:)echo "Option -${OPTARG} requires an argument.">&2exit
1;;esacdone# Make the outmkdir out OUT_PREFIX="$( pwd )/out"export
PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true
];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main
directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd

pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true

]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure
CFLAGS="${MAKEFLAGS}
-I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\
--prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \
--disable-ffmpeg \ --enable-libsamplerate \ --disable-video \
--enable-shared \ --disable-static \ --disable-libyuv \
--with-external-speex \ --with-gnutls \ ||exit
if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it
breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j
$JOPT ||exit # Note, had issue with writing to
//c/.../pkgconfig/libproject.pcmake install ||exit fi|

--
Michael A. Leonetti
As warm as green tea


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

All, In tracking this bug it looks like on configure the flags for PJ_WIN32 are not being set for the build. The system isn't being detected as mingw although it is provided in the target as seen below: x86_64-w64-mingw32 > checking build system type... x86_64-w64-mingw32 > checking host system type... x86_64-w64-mingw32 > checking target system type... x86_64-w64-mingw32 For this reason, it seems that WIN64 is not being detected and pj_sock_t is not being set to the proper value as shown below in pjlib/include/pj/types.h: > /** Socket handle. */ > #if defined(PJ_WIN64) && PJ_WIN64!=0 >     typedef pj_int64_t pj_sock_t; > #else >     typedef long pj_sock_t; > #endif And thus pj_fd_set_t is smaller than fd_set *probably* because fd_set is using a bigger type for fd. That's at least what I've come up with. Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1 which it is being detected? Michael A. Leonetti As warm as green tea On 6/27/19 12:08 PM, Michael A. Leonetti wrote: > > Hello all, > > Long time user first time caller. Nice to meet you all! > > I'm trying to get pjsip to work on Windows. I've compiled pjsip into > my program that I'm writing in an msys2/mingw environment (64-bit). It > compiles fine. However, when I run it in my program I'm getting an > assertion > >> |// Line 49 of >> ../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)| > > Every time I run the program. > > When I do some digging people talk about increasing > PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function > before the asserts to see what the sizes are: > >> |// My PJ_FD_ZERO >> variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES: >> %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: >> %I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}| > The program will output something like this: > >> |10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized >> 10:27:43.507sip_endpoint.c .Creatingendpoint >> instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080| > > However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t > increases /as it should/ but! the sizeof(fd_set) also becomes slight > less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide > says that I cannot set the size of fd_set so I am very confused how > the size is getting set! I don't see anywhere in the pjsip code that > this is being set. > > So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle. > > How can I fix this so my code will stop asserting? > > *The bash script that I ran to configure pjsip* > >> |#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true CLEAN_BEFORE_BUILD=false >> TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am >> Makefile.in"whilegetopts ":pdj:o:c"opt;docase$opt >> inj)JOPT="$OPTARG";;c)echo "Clean before build is >> set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=', 'read -r -a >> BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption >> in"${BUILD_OPTS[@]}";do# Set individualcase$option >> inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option >> ${option}"exit esacdone;;\?)echo "Invalid option: -${OPTARG}">&2exit >> 1;;:)echo "Option -${OPTARG} requires an argument.">&2exit >> 1;;esacdone# Make the outmkdir out OUT_PREFIX="$( pwd )/out"export >> PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true >> ];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main >> directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd >> # pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true >> ]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure >> CFLAGS="${MAKEFLAGS} >> -I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\ >> --prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \ >> --disable-ffmpeg \ --enable-libsamplerate \ --disable-video \ >> --enable-shared \ --disable-static \ --disable-libyuv \ >> --with-external-speex \ --with-gnutls \ ||exit >> if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it >> breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j >> $JOPT ||exit # Note, had issue with writing to >> //c/.../pkgconfig/libproject.pcmake install ||exit fi| > > -- > Michael A. Leonetti > As warm as green tea > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
MA
Michael A. Leonetti
Fri, Jun 28, 2019 9:22 PM

Sort of fixed the issue.

Posted on stackoverflow. Linking here:
https://stackoverflow.com/questions/56793545/mingw64-pjsip-sizeoffd-set-always-double-sizeofpj-fd-set-t-causing-assertion

Michael A. Leonetti
As warm as green tea

On 6/28/19 11:44 AM, Michael A. Leonetti wrote:

All,

In tracking this bug it looks like on configure the flags for PJ_WIN32
are not being set for the build. The system isn't being detected as
mingw although it is provided in the target as seen below:
x86_64-w64-mingw32

checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
checking target system type... x86_64-w64-mingw32

For this reason, it seems that WIN64 is not being detected and
pj_sock_t is not being set to the proper value as shown below in
pjlib/include/pj/types.h:

/** Socket handle. */
#if defined(PJ_WIN64) && PJ_WIN64!=0
    typedef pj_int64_t pj_sock_t;
#else
    typedef long pj_sock_t;
#endif

And thus pj_fd_set_t is smaller than fd_set probably because fd_set
is using a bigger type for fd.

That's at least what I've come up with.

Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1
which it is being detected?

Michael A. Leonetti
As warm as green tea
On 6/27/19 12:08 PM, Michael A. Leonetti wrote:

Hello all,

Long time user first time caller. Nice to meet you all!

I'm trying to get pjsip to work on Windows. I've compiled pjsip into
my program that I'm writing in an msys2/mingw environment (64-bit).
It compiles fine. However, when I run it in my program I'm getting an
assertion

|// Line 49 of
../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)|

Every time I run the program.

When I do some digging people talk about increasing
PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function
before the asserts to see what the sizes are:

|// My PJ_FD_ZERO
variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES:
%d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set:
%I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}|

The program will output something like this:

|10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized
10:27:43.507sip_endpoint.c .Creatingendpoint
instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080|

However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t
increases /as it should/ but! the sizeof(fd_set) also becomes slight
less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide
says that I cannot set the size of fd_set so I am very confused how
the size is getting set! I don't see anywhere in the pjsip code that
this is being set.

So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle.

How can I fix this so my code will stop asserting?

The bash script that I ran to configure pjsip

|#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true
CLEAN_BEFORE_BUILD=false TOUCH_COMMAND="touch configure.ac
aclocal.m4 configure Makefile.am Makefile.in"whilegetopts
":pdj:o:c"opt;docase$opt inj)JOPT="$OPTARG";;c)echo "Clean before
build is set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=',
'read -r -a BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption
in"${BUILD_OPTS[@]}";do# Set individualcase$option
inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option
${option}"exit esacdone;;?)echo "Invalid option: -${OPTARG}">&2exit
1;;:)echo "Option -${OPTARG} requires an argument.">&2exit
1;;esacdone# Make the outmkdir out OUT_PREFIX="$( pwd )/out"export
PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true
];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main
directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd

pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true

]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure
CFLAGS="${MAKEFLAGS}
-I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\
--prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \
--disable-ffmpeg \ --enable-libsamplerate \ --disable-video \
--enable-shared \ --disable-static \ --disable-libyuv \
--with-external-speex \ --with-gnutls \ ||exit
if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it
breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j
$JOPT ||exit # Note, had issue with writing to
//c/.../pkgconfig/libproject.pcmake install ||exit fi|

--
Michael A. Leonetti
As warm as green tea


Visit our blog:http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Sort of fixed the issue. Posted on stackoverflow. Linking here: https://stackoverflow.com/questions/56793545/mingw64-pjsip-sizeoffd-set-always-double-sizeofpj-fd-set-t-causing-assertion Michael A. Leonetti As warm as green tea On 6/28/19 11:44 AM, Michael A. Leonetti wrote: > > All, > > In tracking this bug it looks like on configure the flags for PJ_WIN32 > are not being set for the build. The system isn't being detected as > mingw although it is provided in the target as seen below: > x86_64-w64-mingw32 > >> checking build system type... x86_64-w64-mingw32 >> checking host system type... x86_64-w64-mingw32 >> checking target system type... x86_64-w64-mingw32 > For this reason, it seems that WIN64 is not being detected and > pj_sock_t is not being set to the proper value as shown below in > pjlib/include/pj/types.h: > >> /** Socket handle. */ >> #if defined(PJ_WIN64) && PJ_WIN64!=0 >>     typedef pj_int64_t pj_sock_t; >> #else >>     typedef long pj_sock_t; >> #endif > And thus pj_fd_set_t is smaller than fd_set *probably* because fd_set > is using a bigger type for fd. > > That's at least what I've come up with. > > Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1 > which it is being detected? > > Michael A. Leonetti > As warm as green tea > On 6/27/19 12:08 PM, Michael A. Leonetti wrote: >> >> Hello all, >> >> Long time user first time caller. Nice to meet you all! >> >> I'm trying to get pjsip to work on Windows. I've compiled pjsip into >> my program that I'm writing in an msys2/mingw environment (64-bit). >> It compiles fine. However, when I run it in my program I'm getting an >> assertion >> >>> |// Line 49 of >>> ../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)| >> >> Every time I run the program. >> >> When I do some digging people talk about increasing >> PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function >> before the asserts to see what the sizes are: >> >>> |// My PJ_FD_ZERO >>> variantPJ_DEF(void)PJ_FD_ZERO(pj_fd_set_t*fdsetp){printf("PJ_IOQUEUE_MAX_HANDLES: >>> %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: >>> %I64d\n",PJ_IOQUEUE_MAX_HANDLES,sizeof(pj_fd_set_t),sizeof(pj_sock_t),sizeof(fd_set));PJ_CHECK_STACK();pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set));FD_ZERO(PART_FDSET(fdsetp));PART_COUNT(fdsetp)=0;}| >> The program will output something like this: >> >>> |10:27:43.477os_core_win32.c !pjlib 2.9forwin32 initialized >>> 10:27:43.507sip_endpoint.c .Creatingendpoint >>> instance...PJ_IOQUEUE_MAX_HANDLES:16384,pj_fd_set_t:65552,pj_sock_t:4,fd_set:131080| >> >> However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t >> increases /as it should/ but! the sizeof(fd_set) also becomes slight >> less than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide >> says that I cannot set the size of fd_set so I am very confused how >> the size is getting set! I don't see anywhere in the pjsip code that >> this is being set. >> >> So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle. >> >> How can I fix this so my code will stop asserting? >> >> *The bash script that I ran to configure pjsip* >> >>> |#!/bin/bashJOPT=1DEBUG=false BUILD_ALL=true >>> CLEAN_BEFORE_BUILD=false TOUCH_COMMAND="touch configure.ac >>> aclocal.m4 configure Makefile.am Makefile.in"whilegetopts >>> ":pdj:o:c"opt;docase$opt inj)JOPT="$OPTARG";;c)echo "Clean before >>> build is set."CLEAN_BEFORE_BUILD=true;;;d)DEBUG=true ;;o)IFS=', >>> 'read -r -a BUILD_OPTS <<<"${OPTARG}"BUILD_ALL=false foroption >>> in"${BUILD_OPTS[@]}";do# Set individualcase$option >>> inpjsip)BUILD_PJSIP=true;;;*)echo "Unknown build option >>> ${option}"exit esacdone;;\?)echo "Invalid option: -${OPTARG}">&2exit >>> 1;;:)echo "Option -${OPTARG} requires an argument.">&2exit >>> 1;;esacdone# Make the outmkdir out OUT_PREFIX="$( pwd )/out"export >>> PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"if["$DEBUG"=true >>> ];thenMAKEFLAGS="-g -O0"elseMAKEFLAGS="-O2"fi# Main >>> directoryLIB_DIRECTORY="$(pwd)/lib"# Descendcd "${LIB_DIRECTORY}"pwd >>> # pjsipcd "${LIB_DIRECTORY}/pjsip"if["${BUILD_ALL}"=true >>> ]||["${BUILD_PJSIP}"=true ];theneval$TOUCH_COMMAND ./configure >>> CFLAGS="${MAKEFLAGS} >>> -I${OUT_PREFIX}/include"CXXFLAGS="${MAKEFLAGS}"LDFLAGS="-L${OUT_PREFIX}/lib"\ >>> --prefix="${OUT_PREFIX}"\ --disable-openh264 \ --disable-v4l2 \ >>> --disable-ffmpeg \ --enable-libsamplerate \ --disable-video \ >>> --enable-shared \ --disable-static \ --disable-libyuv \ >>> --with-external-speex \ --with-gnutls \ ||exit >>> if["${CLEAN_BEFORE_BUILD}"=true ];thenmake clean fi# Without this it >>> breaks on msys2make -j $JOPT dep ||exit # Make the actualmake -j >>> $JOPT ||exit # Note, had issue with writing to >>> //c/.../pkgconfig/libproject.pcmake install ||exit fi| >> >> -- >> Michael A. Leonetti >> As warm as green tea >> >> _______________________________________________ >> Visit our blog:http://blog.pjsip.org >> >> pjsip mailing list >> pjsip@lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
NI
Nanang Izzuddin
Wed, Jul 3, 2019 11:00 AM

Hi Michael,

When target string is 'x86_64-w64-mingw32', PJ_WIN32 macro set should be
enabled automatically, you can confirm it by checking file
"pjlib\include\pj\compat\os_auto.h". Then I think you'd need to set
PJ_WIN64=1 manually, e.g: via user.mak file.

We don't officially support msys2, not sure if we have tried it either. But
on msys with mingw 64 bit, I think you can do this:

./configure --host=x86_64-w64-mingw32

Make sure target string is 'x86_64-w64-mingw32'. Then add
"CFLAGS+=-DPJ_WIN64=1" into user.mak file, then 'make' as usual.

BR,
nanang

On Sat, Jun 29, 2019 at 4:23 AM Michael A. Leonetti michael@theleonetti.com
wrote:

Sort of fixed the issue.

Posted on stackoverflow. Linking here:
https://stackoverflow.com/questions/56793545/mingw64-pjsip-sizeoffd-set-always-double-sizeofpj-fd-set-t-causing-assertion

Michael A. Leonetti
As warm as green tea

On 6/28/19 11:44 AM, Michael A. Leonetti wrote:

All,

In tracking this bug it looks like on configure the flags for PJ_WIN32 are
not being set for the build. The system isn't being detected as mingw
although it is provided in the target as seen below: x86_64-w64-mingw32

checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
checking target system type... x86_64-w64-mingw32

For this reason, it seems that WIN64 is not being detected and pj_sock_t
is not being set to the proper value as shown below in
pjlib/include/pj/types.h:

/** Socket handle. */
#if defined(PJ_WIN64) && PJ_WIN64!=0
typedef pj_int64_t pj_sock_t;
#else
typedef long pj_sock_t;
#endif

And thus pj_fd_set_t is smaller than fd_set probably because fd_set is
using a bigger type for fd.

That's at least what I've come up with.

Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1 which it
is being detected?

Michael A. Leonetti
As warm as green tea

On 6/27/19 12:08 PM, Michael A. Leonetti wrote:

Hello all,

Long time user first time caller. Nice to meet you all!

I'm trying to get pjsip to work on Windows. I've compiled pjsip into my
program that I'm writing in an msys2/mingw environment (64-bit). It
compiles fine. However, when I run it in my program I'm getting an assertion

// Line 49 of ../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set)

Every time I run the program.

When I do some digging people talk about increasing
PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function before
the asserts to see what the sizes are:

// My PJ_FD_ZERO variant
PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp){
printf( "PJ_IOQUEUE_MAX_HANDLES: %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: %I64d\n", PJ_IOQUEUE_MAX_HANDLES, sizeof(pj_fd_set_t), sizeof(pj_sock_t), sizeof(fd_set) );
PJ_CHECK_STACK();
pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set));

 FD_ZERO(PART_FDSET(fdsetp));
 PART_COUNT(fdsetp) = 0;}

The program will output something like this:

10:27:43.477        os_core_win32.c !pjlib 2.9 for win32 initialized10:27:43.507        sip_endpoint.c  .Creating endpoint instance...
PJ_IOQUEUE_MAX_HANDLES: 16384, pj_fd_set_t: 65552, pj_sock_t: 4, fd_set: 131080

However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t
increases as it should but! the sizeof(fd_set) also becomes slight less
than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide says that I
cannot set the size of fd_set so I am very confused how the size is getting
set! I don't see anywhere in the pjsip code that this is being set.

So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle.

How can I fix this so my code will stop asserting?

The bash script that I ran to configure pjsip

#!/bin/bash

JOPT=1
DEBUG=false
BUILD_ALL=true
CLEAN_BEFORE_BUILD=false

TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am Makefile.in"
while getopts ":pdj:o:c" opt; do
case $opt in
j)
JOPT="$OPTARG"
;;
c)
echo "Clean before build is set."
CLEAN_BEFORE_BUILD=true;
;;
d)
DEBUG=true
;;
o)
IFS=', ' read -r -a BUILD_OPTS <<< "${OPTARG}"
BUILD_ALL=false

                     for option in "${BUILD_OPTS[@]}" ; do
                             # Set individual
                             case $option in
                                     pjsip)
                                             BUILD_PJSIP=true;
                                             ;;
                                     *)
                                             echo "Unknown build option ${option}"
                                             exit
                             esac
                     done
                     ;;
             \?)
                     echo "Invalid option: -${OPTARG}" >&2
                     exit 1
                     ;;
             :)
                     echo "Option -${OPTARG} requires an argument." >&2
                     exit 1
                     ;;
     esacdone

Make the out

mkdir out
OUT_PREFIX="$( pwd )/out"
export PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}"
if [ "$DEBUG" = true ] ; then
MAKEFLAGS="-g -O0"else
MAKEFLAGS="-O2"fi

Main directory

LIB_DIRECTORY="$(pwd)/lib"

Descend

cd "${LIB_DIRECTORY}"

pwd

pjsip

cd "${LIB_DIRECTORY}/pjsip"if [ "${BUILD_ALL}" = true ] || [ "${BUILD_PJSIP}" = true ] ; then
eval $TOUCH_COMMAND

     ./configure CFLAGS="${MAKEFLAGS} -I${OUT_PREFIX}/include" CXXFLAGS="${MAKEFLAGS}" LDFLAGS="-L${OUT_PREFIX}/lib" \
             --prefix="${OUT_PREFIX}" \
             --disable-openh264 \
             --disable-v4l2 \
             --disable-ffmpeg \
             --enable-libsamplerate \
             --disable-video \
             --enable-shared \
             --disable-static \
             --disable-libyuv \
             --with-external-speex \
             --with-gnutls \
             || exit

     if [ "${CLEAN_BEFORE_BUILD}" = true ] ; then
             make clean
     fi

     # Without this it breaks on msys2
     make -j $JOPT dep || exit
     # Make the actual
     make -j $JOPT || exit
     # Note, had issue with writing to //c/.../pkgconfig/libproject.pc
     make install || exitfi

--
Michael A. Leonetti
As warm as green tea


Visit our blog: http://blog.pjsip.org

pjsip mailing listpjsip@lists.pjsip.orghttp://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Hi Michael, When target string is 'x86_64-w64-mingw32', PJ_WIN32 macro set should be enabled automatically, you can confirm it by checking file "pjlib\include\pj\compat\os_auto.h". Then I think you'd need to set PJ_WIN64=1 manually, e.g: via user.mak file. We don't officially support msys2, not sure if we have tried it either. But on msys with mingw 64 bit, I think you can do this: -- ./configure --host=x86_64-w64-mingw32 -- Make sure target string is 'x86_64-w64-mingw32'. Then add "CFLAGS+=-DPJ_WIN64=1" into user.mak file, then 'make' as usual. BR, nanang On Sat, Jun 29, 2019 at 4:23 AM Michael A. Leonetti <michael@theleonetti.com> wrote: > Sort of fixed the issue. > > Posted on stackoverflow. Linking here: > https://stackoverflow.com/questions/56793545/mingw64-pjsip-sizeoffd-set-always-double-sizeofpj-fd-set-t-causing-assertion > > Michael A. Leonetti > As warm as green tea > > On 6/28/19 11:44 AM, Michael A. Leonetti wrote: > > All, > > In tracking this bug it looks like on configure the flags for PJ_WIN32 are > not being set for the build. The system isn't being detected as mingw > although it is provided in the target as seen below: x86_64-w64-mingw32 > > checking build system type... x86_64-w64-mingw32 > checking host system type... x86_64-w64-mingw32 > checking target system type... x86_64-w64-mingw32 > > For this reason, it seems that WIN64 is not being detected and pj_sock_t > is not being set to the proper value as shown below in > pjlib/include/pj/types.h: > > /** Socket handle. */ > #if defined(PJ_WIN64) && PJ_WIN64!=0 > typedef pj_int64_t pj_sock_t; > #else > typedef long pj_sock_t; > #endif > > And thus pj_fd_set_t is smaller than fd_set *probably* because fd_set is > using a bigger type for fd. > > That's at least what I've come up with. > > Any way to force PJ_WIN32=1 in the build instead of PJ_AUTOCONF=1 which it > is being detected? > > Michael A. Leonetti > As warm as green tea > > On 6/27/19 12:08 PM, Michael A. Leonetti wrote: > > Hello all, > > Long time user first time caller. Nice to meet you all! > > I'm trying to get pjsip to work on Windows. I've compiled pjsip into my > program that I'm writing in an msys2/mingw environment (64-bit). It > compiles fine. However, when I run it in my program I'm getting an assertion > > // Line 49 of ../src/pj/sock_select.csizeof(pj_fd_set_t)-sizeof(pj_sock_t)>=sizeof(fd_set) > > > Every time I run the program. > > When I do some digging people talk about increasing > PJ_IOQUEUE_MAX_HANDLES. So I did, and I put a printf in the function before > the asserts to see what the sizes are: > > // My PJ_FD_ZERO variant > PJ_DEF(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp){ > printf( "PJ_IOQUEUE_MAX_HANDLES: %d, pj_fd_set_t: %I64d, pj_sock_t: %I64d, fd_set: %I64d\n", PJ_IOQUEUE_MAX_HANDLES, sizeof(pj_fd_set_t), sizeof(pj_sock_t), sizeof(fd_set) ); > PJ_CHECK_STACK(); > pj_assert(sizeof(pj_fd_set_t)-sizeof(pj_sock_t) >= sizeof(fd_set)); > > FD_ZERO(PART_FDSET(fdsetp)); > PART_COUNT(fdsetp) = 0;} > > The program will output something like this: > > 10:27:43.477 os_core_win32.c !pjlib 2.9 for win32 initialized10:27:43.507 sip_endpoint.c .Creating endpoint instance... > PJ_IOQUEUE_MAX_HANDLES: 16384, pj_fd_set_t: 65552, pj_sock_t: 4, fd_set: 131080 > > However, when I tweak PJ_IOQUEUE_MAX_HANDLES the size of pj_fd_set_t > increases *as it should* but! the sizeof(fd_set) also becomes slight less > than DOUBLE whatever sizeof(pj_fd_set_t) is! The winsock guide says that I > cannot set the size of fd_set so I am very confused how the size is getting > set! I don't see anywhere in the pjsip code that this is being set. > > So adjusting PJ_IOQUEUE_MAX_HANDLES is quite the losing battle. > > How can I fix this so my code will stop asserting? > > *The bash script that I ran to configure pjsip* > > #!/bin/bash > > JOPT=1 > DEBUG=false > BUILD_ALL=true > CLEAN_BEFORE_BUILD=false > > TOUCH_COMMAND="touch configure.ac aclocal.m4 configure Makefile.am Makefile.in" > while getopts ":pdj:o:c" opt; do > case $opt in > j) > JOPT="$OPTARG" > ;; > c) > echo "Clean before build is set." > CLEAN_BEFORE_BUILD=true; > ;; > d) > DEBUG=true > ;; > o) > IFS=', ' read -r -a BUILD_OPTS <<< "${OPTARG}" > BUILD_ALL=false > > for option in "${BUILD_OPTS[@]}" ; do > # Set individual > case $option in > pjsip) > BUILD_PJSIP=true; > ;; > *) > echo "Unknown build option ${option}" > exit > esac > done > ;; > \?) > echo "Invalid option: -${OPTARG}" >&2 > exit 1 > ;; > :) > echo "Option -${OPTARG} requires an argument." >&2 > exit 1 > ;; > esacdone > # Make the out > mkdir out > OUT_PREFIX="$( pwd )/out" > export PKG_CONFIG_PATH="${OUT_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}" > if [ "$DEBUG" = true ] ; then > MAKEFLAGS="-g -O0"else > MAKEFLAGS="-O2"fi > # Main directory > LIB_DIRECTORY="$(pwd)/lib" > # Descend > cd "${LIB_DIRECTORY}" > > pwd > # pjsip > cd "${LIB_DIRECTORY}/pjsip"if [ "${BUILD_ALL}" = true ] || [ "${BUILD_PJSIP}" = true ] ; then > eval $TOUCH_COMMAND > > ./configure CFLAGS="${MAKEFLAGS} -I${OUT_PREFIX}/include" CXXFLAGS="${MAKEFLAGS}" LDFLAGS="-L${OUT_PREFIX}/lib" \ > --prefix="${OUT_PREFIX}" \ > --disable-openh264 \ > --disable-v4l2 \ > --disable-ffmpeg \ > --enable-libsamplerate \ > --disable-video \ > --enable-shared \ > --disable-static \ > --disable-libyuv \ > --with-external-speex \ > --with-gnutls \ > || exit > > if [ "${CLEAN_BEFORE_BUILD}" = true ] ; then > make clean > fi > > # Without this it breaks on msys2 > make -j $JOPT dep || exit > # Make the actual > make -j $JOPT || exit > # Note, had issue with writing to //c/.../pkgconfig/libproject.pc > make install || exitfi > > > -- > Michael A. Leonetti > As warm as green tea > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing listpjsip@lists.pjsip.orghttp://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip@lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >