signalwire / libks Goto Github PK
View Code? Open in Web Editor NEWFoundational support for signalwire C products
License: Other
Foundational support for signalwire C products
License: Other
To build use cmake (Minimum version 3.7.2): cmake . make To install: make install To un-install: make uninstall To build debug (no optimizations, symbols - this is the default): cmake . -DCMAKE_BUILD_TYPE=Debug make To build release (optimizations, symbols): cmake . -DCMAKE_BUILD_TYPE=Release make To build to a custom installation prefix (default is /usr): cmake . -DCMAKE_INSTALL_PREFIX:PATH=/usr make To build with openssl on non-standard location (e.g. on Mac): OPENSSL_ROOT_DIR=/usr/local/opt/openssl cmake . -DCMAKE_INSTALL_PREFIX:PATH=/usr/local To run tests: ctest . To build release package with build number 42: PACKAGE_RELEASE="42" cmake . -DCMAKE_BUILD_TYPE=Release && make package To buld CMAKE from source wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz tar -zxvf cmake-3.7.2.tar.gz cd cmake-3.7.2 ./bootstrap --prefix=/usr/local make make install /usr/local/bin/cmake --version Centos dependencies: - yum groupinstall "Development Tools" - yum install libuuid-devel libatomic openssl-devel
Hi,
Expected Behaviour
Start with a clean environment, check out latest tagged version and build it
What happened
Didn't build, since the cmake system tried to read out some tag informations to create a CHANGELOG file.
Related to #42.
--
Would be nice if you could produce the changelog file not on the fly for the tagged versions.
Remove or change any functions that depend on thread locals, such as ks_thr_sprintf which is not only unsafe but with thread locals can create all kinds of unintended side effects (as was seen in some libs like signalwire-c). Thread locals do not save CPU or memory in a tangible way given modern allocators.
Out-of-source (VPATH) installation fails with:
-- Up-to-date: /usr/include/libks/cmake/AddLibBacktrace.cmake
CMake Error at cmake_install.cmake:114 (file):
file INSTALL cannot find "/git/freeswitch/libks/build/copyright": No such
file or directory.
The file is not in the build directory, but in the source directory.
Trying to build the src files and getting this error
Checking for module 'uuid'
No package 'uuid' found
CMake Error at /usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:463 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPkgConfig.cmake:643 (_pkg_check_modules_internal)
cmake/FindUUID.cmake:15 (pkg_check_modules)
CMakeLists.txt:411 (include)
Configuring incomplete, errors occurred!
See also "/usr/src/libks/CMakeFiles/CMakeOutput.log".
executor failed running [/bin/sh -c cmake .]: exit code: 1
This is another duplicated issue of signalwire/homebrew-signalwire#21
Root Cause
The POSIX pthread_self
returns the pthread_t
, which is a struct, not a unsigned long int
alias. And gettid()
, which return the current thread id, is not available in mac os.
Solution
https://elliotth.blogspot.com/2012/04/gettid-on-mac-os.html
uint64_t tid;
pthread_threadid_np(NULL, &tid);
or
syscall(SYS_thread_selfid)
But syscall
is deprecated in macOS 10.12, there will be a warning. I suggest use pthread_threadid_np
.
'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported;
kws.c:393 - this error is a normal thing that can happen when a connection closes and should not be logged at an error level.
Where the function kws_read_frame() read a ping frame which the frame length is 6(2 header and 4 payload) and followed with a text frame. Then the code below will make the kws->datalen to be 9:
if ((kws->datalen = kws_string_read(kws, kws->buffer, 9 + 1, kws->block)) < 0)
This will trigger the error in below code because the need will be -3:
need = (kws->plen - (kws->datalen - need));
if (need < 0) {
/* invalid read - protocol err .. */
ks_log(KS_LOG_ERROR, "Read frame error because need = %ld\n", need);
*oc = WSOC_CLOSE;
return kws_close(kws, WS_NONE);
}
I have modify the code to:
if ((kws->datalen = kws_string_read(kws, kws->buffer, 6 + 1, kws->block)) < 0)
and it seems worked. But if the ping frame length is less than 6, the error is still exist. What about a perfect solution?
ks_json internally asserts, danger when parsing/using untrusted JSON.
KS_DECLARE(const char * const) ks_json_get_object_cstr(const ks_json_t * const object, const char * const key)
{
const ks_json_t *item = ks_json_get_object_item(object, key);
if (item) {
ks_assert(ks_json_type_is_string(item));
return item->valuestring;
}
return NULL;
}
KS_DECLARE(int) ks_json_get_object_number_int(const ks_json_t * const object, const char * const key)
{
const ks_json_t *item = ks_json_get_object_item(object, key);
ks_assert(ks_json_type_is_number(item));
return item->valueint;
}
basically you have to check the item type before use each of that function to avoid asserts.
Building this on FreeBSD 11.2 failed:
/root/src/libks-1.2.0/src/ks_thread.c:142:17: error: use of undeclared identifier 'SYS_gettid'; did you mean 'SSL_get_fd'?
return syscall(SYS_gettid);
^~~~~~~~~~
SSL_get_fd
/usr/local/include/openssl/ssl.h:2148:5: note: 'SSL_get_fd' declared here
int SSL_get_fd(const SSL *s);
^
/root/src/libks-1.2.0/src/ks_thread.c:237:21: error: use of undeclared identifier 'pthread_setname_np'
if (thread->tag && pthread_setname_np)
When I build the source codes on ubuntu 18.04 with command:
$ cmake .
I get below errors:
:~/src/libks$ cmake .
-- cotire 1.7.10 loaded.
Platform is linux
Build type: Debug CXX Flags:
Install prefix: /usr
LibKS Version 1.3
CMake Error at CMakeLists.txt:291 (string):
string sub-command REPLACE requires at least four arguments.
Found UUID setup target at imported location: /usr/lib/x86_64-linux-gnu/libuuid.so
Compiler supports visibility
-- Configuring incomplete, errors occurred!
ubuntu20.04
kws_connect_ex
gethostbyname("10.0.1.2")
ks_addr_set_raw
family==10
addr->family = AF_INET6;
libks v1.x
/Users/mike/src/libks/src/ks_handle.c:112:53: warning: result of comparison of constant 65536 with expression of type 'uint16_t' (aka 'unsigned short') is
always true [-Wtautological-constant-out-of-range-compare]
for (uint16_t slot_index = start_index; slot_index < KS_HANDLE_MAX_SLOTS; slot_index++) {
~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
/Users/mike/src/libks/src/ks_handle.c:216:18: warning: result of comparison of constant 65536 with expression of type 'uint16_t' (aka 'unsigned short') is
always false [-Wtautological-constant-out-of-range-compare]
if (*slot_index >= KS_HANDLE_MAX_SLOTS) {
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
2 warnings generated.
/Users/mike/src/libks/src/ks_json.c:686:15: warning: implicit conversion from enumeration type 'const cJSON_TYPES' to different enumeration type 'KS_JSON_TYPES'
[-Wenum-conversion]
return item->type;
~~~~~~ ~~~~~~^~~~
1 warning generated.
/Users/mike/src/libks/src/ks_log.c:210:65: warning: format specifies type 'int' but the argument has type 'ks_size_t' (aka 'unsigned long') [-Wformat]
used += snprintf(buf + used - 1, bufSize - used, "[LF:%d] ", g_wakeup_stdout_fails);
~~ ^~~~~~~~~~~~~~~~~~~~~
%zu
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro
'snprintf'
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), VA_ARGS)
^~~~~~~~~~~
/Users/mike/src/libks/src/ks_log.c:214:65: warning: format specifies type 'int' but the argument has type 'ks_size_t' (aka 'unsigned long') [-Wformat]
used += snprintf(buf + used - 1, bufSize - used, "[LS:%d] ", g_wakeup_stdout_successes);
~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
%zu
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro
'snprintf'
__builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), VA_ARGS)
^~~~~~~~~~~
2 warnings generated.
/Users/mike/src/libks/src/ks_thread.c:144:9: warning: incompatible pointer to integer conversion returning 'pthread_t _Nonnull'
(aka 'struct _opaque_pthread_t *') from a function with result type 'ks_pid_t' (aka 'int') [-Wint-conversion]
return pthread_self();
^~~~~~~~~~~~~~
/Users/mike/src/libks/src/ks_thread.c:234:21: warning: address of function 'pthread_setname_np' will always evaluate to 'true' [-Wpointer-bool-conversion]
if (thread->tag && pthread_setname_np)
~~ ^~~~~~~~~~~~~~~~~~
/Users/mike/src/libks/src/ks_thread.c:234:21: note: prefix with the address-of operator to silence this warning
if (thread->tag && pthread_setname_np)
^
&
2 warnings generated.
I can't compile FreeSWITCH after installing links from sources. Rocky Linux 9 My Steps:
cd /usr/src
git clone https://github.com/signalwire/libks.git
cd libks/
cmake .
make
make install
cd /usr/src
git clone -b v1.10 https://github.com/signalwire/freeswitch.git
cd freeswitch
./bootstrap.sh
./configure -C --enable-portable-binary
--prefix=/usr --localstatedir=/var --sysconfdir=/etc
--with-gnu-ld --with-python=/usr/bin/python3 --with-openssl
--enable-core-odbc-support --enable-zrtp
--enable-core-pgsql-support
--enable-static-v8 --disable-parallel-build-v8
checking for libks2 >= 2.0.0... checking for libks >= 1.8.2... configure: error: You need to either install libks2 or libks or disable mod_verto in modules.conf
Any hint?
Regards
Hi,
I just compile and installed on Fedora 34 64bits libks in default folder /usr/lib
but freeswitch compilation still complains to not find it.
any idea?
I'm trying to build libks with a Yocto recipe
DESCRIPTION = "Foundational support for signalwire C products"
HOMEPAGE = "https://github.com/signalwire/libks"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://copyright;md5=5419284e41fbb9983fe7986a879b8224"
SRC_URI = "git://github.com/signalwire/libks;protocol=https;branch=master"
PV = "1.8.0+git${SRCPV}"
SRCREV = "25723366532d2244c362988748c87512fcafde4a"
S = "${WORKDIR}/git"
DEPENDS = "openssl util-linux"
inherit cmake
EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release"
Basically the recipe has been create with recipetool create -V 1.8.0 https://github.com/signalwire/libks
.
When i run bitbake libks, i get the following error
CMake Error at cmake_install.cmake:109 (file):
| file INSTALL cannot find
| "/home/.../rpi64/build/tmp/work/aarch64-poky-linux/libks/1.8.0+gitAUTOINC+2572336653-r0/build/copyright":
| No such file or directory.
The ${WORKDIR}/git
does contain the copyright file, but it seems its not copied in build folder. Do i miss something in my recipe?
functions like ks_json_get_object_cstr
assert internally that makes it useless since you cannot make sure the item you access is valid before you access it.
The only valid way to use this function is to always check the key exists and has the right type ahead. but if you check ahead there's no reason to assert later.
The full implementation below:
KS_DECLARE(const char * const) ks_json_get_object_cstr(const ks_json_t * const object, const char * const key)
{
const ks_json_t *item = ks_json_get_object_item(object, key);
if (item) {
ks_assert(ks_json_type_is_string(item));
return item->valuestring;
}
return NULL;
}
We created ks_json_get_object_cstr_def
as a safer way of the above function. I would like to keep the function name ks_json_get_object_cstr
as a THIN wrapper to cJSON and remove the asserts internally, and the ks_json_get_object_cstr_def
version could be removed or build as a macro on top of ks_json_get_object_cstr
if it still useful.
There are other functions like this e.g.
Hello Everyone,
Can you please add, to allow library path flexibility.
Manually-specified variables were not used by the project:
CMAKE_INSTALL_LIBDIR
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libks.so.1" AND
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libks.so.1")
After installing libks
via Homebrew
brew install signalwire/signalwire/libks
as per https://github.com/signalwire/libstirshaken if I run pkg-config
it reports the incorrect path
$ pkg-config --cflags libks
-I/opt/homebrew/Cellar/libks/1.8.2/include/libks
As you can see the path reported is one dir too deep. Instead, it should report /opt/homebrew/Cellar/libks/1.8.2/include
.
This is consistent with other packages:
$ pkg-config --cflags libjwt
-I/opt/homebrew/Cellar/libjwt/1.15.2/include
This line needs to be changed
https://github.com/signalwire/libks/blob/master/libks.pc.in#L11
I use prefix=/usr/local. The installation process puts libks.pc under /usr/lib/pkgconfig/libks.pc
, which happens to be ignored by pkgconfig.
The destination shall be /usr/local/lib/pkgconfig/libks.pc
.
Starting in Chrome98 Beta (98.0.4758.54 (Official Build) beta (64-bit)), a verto login -- which uses the browser-native WebSocket constructor -- initially succeeds but then is repeatedly forced by commands from FS 1.10.7 to relogin.
Using DevTools / Network / WS reveals that after login, many non-control frames of length 1028 (displayed as #SPB
) are sent to FS. Then verto sends a non-control frame of length 4 (displayed as #SPE
) and that is shortly followed by a non-control frame like
{jsonrpc: "2.0", id: 7, method: "verto.clientReady", params: {reattached_sessions: []}}
id: 7
jsonrpc: "2.0"
method: "verto.clientReady"
params: {reattached_sessions: []}
and that is the last frame of the connection; it seems to force verto to relogin because DevTools shows a new connection and a login frame is one of the first to appear.
This was happening with a ws.c from this repo committed around Sept 21, 2021 to fix an iOS 15 issue. We found that you replaced that with libks, so we pulled the head of https://github.com/signalwire/freeswitch ‘s master branch onto Debian 10 and built it, then copied its mod_verto.so to our 1.10.7-release-19-883d2cb662~64bit server and then did ‘reload mod_verto’ in fs_cli. That resulted in repeated error logging like...
2022-01-13 19:24:57.826514 98.37% [INFO] mod_verto.c:606 WRITE 67.174.x.y:60384 [{"jsonrpc":"2.0","id":3,"result":{"message":"logged in","sessid":"6d59bad2-e365-40e1-8ae1-0cfa89fd4f5d"}}]
2022-01-13 19:25:08.146606 97.87% [ERR] kws.c:1156 Read frame error because kws_string_read returned -1
2022-01-13 19:25:08.146606 97.87% [WARNING] mod_verto.c:2032 67.174.172.111:60384 POLL ERROR
Then we tried changing the die
at https://github.com/signalwire/freeswitch/blob/f9bb8940c29f55c89fa1e0697e8e614b355bfff2/src/mod/endpoints/mod_verto/mod_verto.c#L2032 to merely a warning, but that resulted in an infinite iteration of the POLL ERROR at the same msec log time.
So now it appears that the assigning of state KS_SOCK_INVALID in https://github.com/signalwire/libks/blob/10b3445c92f17be3908a6c0e5597c0fe997ad637/src/ks_socket.c may be incorrect for these #SPE frames that seem to occur only in Chrome 98 Beta and not Chrome97 nor Firefox.
Currently the AddStringToObject is faulty, and appends instead of replacing. As a result, it is required to delete before adding in the ks_json_xxx wrapper.
The cJSON_ReplaceXXX functions are not wrapped, add wrappers to expose via ks_json_xxx.
The implementation of kws_raw_read is not... raw. It should leave any terminating and accounting for terminator space up to kws_read_frame, where it is working with a string only for the body and not the raw read of the header.
This is causing a buffer overrun which triggers memory corruption checks.
when use kws_connect_ex to connect ws server, than it crash。
but i can not find any nil。
libks version: v2.0
commit: 0226f34
pools is hard to track ownerships, and can create overhead even the json object owns it internally. and it makes it hard to decide when to use the correct version of functions, e.g., when you get an json object, how to figure out when to call ks_json_add_string_to_object
or when to call ks_json_padd_string_to_object
? what happens when you merge two json together when one has pool and the other has no pool? the only way to make sure it works is to never use the pool
version.
Current CMakeLists.txt depends on grabbing a git tag - so the tarball based build doesn't actually work since it tries to find a tag and can't, since there is no .git tree.
/usr/local/include/libks/ks_handle.h:92:18: error: redefinition of typedef 'ks_handle_t' is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef uint64_t ks_handle_t;
^
/usr/local/include/libks/ks_handle.h:60:18: note: previous definition is here
typedef uint64_t ks_handle_t;
^
In file included from mod_signalwire.c:28:
In file included from /usr/local/include/signalwire-client-c/client.h:25:
In file included from /usr/local/Cellar/libks/1.1.0/include/libks/ks.h:64:
/usr/local/include/libks/ks_hash.h:246:10: error: unused variable 'val' [-Werror,-Wunused-variable]
uuid_t val= (uuid_t)ky;
^
In file included from mod_signalwire.c:28:
In file included from /usr/local/include/signalwire-client-c/client.h:25:
In file included from /usr/local/Cellar/libks/1.1.0/include/libks/ks.h:84:
/usr/local/include/libks/ks_atomic.h:81:21: error: implicit declaration of function '__atomic_compare_exchange_4' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
{ return (ks_bool_t)__atomic_compare_exchange_4(destination, &comperand, swapped, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
^
/usr/local/include/libks/ks_atomic.h:84:21: error: implicit declaration of function '__atomic_compare_exchange_8' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
{ return (ks_bool_t)__atomic_compare_exchange_8(destination, &comperand, swapped, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
^
/usr/local/include/libks/ks_atomic.h:89:20: error: implicit declaration of function '__atomic_compare_exchange_8' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
return (ks_bool_t)__atomic_compare_exchange_8(destination, &comperand, swapped, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
^
/usr/local/include/libks/ks_atomic.h:98:20: error: implicit declaration of function '__atomic_compare_exchange_8' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
return (ks_bool_t)__atomic_compare_exchange_8(destination, &comperand, (uintptr_t)swapped, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
^
from v2.0 branch:
/Users/seven/workspace/freeswitch/libks/tests/testwebsock2.c:297:1: warning: non-void function does not return a value [-Wreturn-type]
}
^
/Users/seven/workspace/freeswitch/libks/tests/testwebsock2.c:330:39: warning: format specifies type 'int' but the argument has type 'ks_ssize_t' (aka 'long') [-Wformat]
printf("read bytes=%d oc=%d [%s]\n", bytes, oc, (char *)rdata);
~~ ^~~~~
%zd
/Users/seven/workspace/freeswitch/libks/tests/testwebsock2.c:334:40: warning: format specifies type 'int' but the argument has type 'ks_ssize_t' (aka 'long') [-Wformat]
printf("read bytes=%d oc=%d [%s]\n", bytes, oc, (char *)rdata);
~~ ^~~~~
%zd
3 warnings generated.
It will crash when I call ks_json_add_number_to_object function.
It crash on add_item_to_object fuction when try to free item->string. The variable is uninitialized and I never set this string.
0 0x00007f417d3d81dc in free () from /usr/lib/x86_64-linux-gnu/libjemalloc.so.1
#1 0x00007f415532a3c6 in add_item_to_object (object=0x7f416d5857c0, string=0x7f415c5fbf2e "op", item=0x7f416d5930c0, hooks=0x7f415558acd0 <global_hooks>, constant_key=0)
at /usr/src/libs/libks/src/include/cJSON/cJSON.c:1913
#2 0x00007f415532a6ac in cJSON_AddNumberToObject (object=0x7f416d5857c0, name=0x7f415c5fbf2e "op", number=2) at /usr/src/libs/libks/src/include/cJSON/cJSON.c:2004
#3 0x00007f41553522f1 in __ks_json_add_string_to_object (pool=0x0, file=0x7f415c5fc9e8 "discord_api.c", line=68, tag=0x7f415c5fce50 <__PRETTY_FUNCTION__.37413> "discord_gateway_handshake",
object=0x7f416d5857c0, name=0x7f415c5fbf2e "op", string=0x7f41739f9d18 "\300WXmA\177") at /usr/src/libs/libks/src/ks_json.c:344
#4 0x00007f415c5fa675 in discord_gateway_handshake () at discord_api.c:68
#5 discord_gateway_online () at discord_api.c:463
On a fresh dist lot of warning about OpenSSL deprecated function call.
iles/ks2.dir/src/ks_ssl.c.o -MF CMakeFiles/ks2.dir/src/ks_ssl.c.o.d -o CMakeFiles/ks2.dir/src/ks_ssl.c.o -c /tmp/libks/src/ks_ssl.c
/tmp/libks/src/ks_ssl.c: In function ‘mkcert’:
/tmp/libks/src/ks_ssl.c:211:5: warning: ‘RSA_new’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
211 | rsa = RSA_new();
| ^~~
In file included from /usr/include/openssl/x509.h:36,
from /usr/include/openssl/ssl.h:31,
from /tmp/libks/src/include/libks/ks_ssl.h:25,
from /tmp/libks/src/include/libks/ks.h:80,
from /tmp/libks/src/ks_ssl.c:23:
/usr/include/openssl/rsa.h:206:28: note: declared here
206 | OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
| ^~~~~~~
/tmp/libks/src/ks_ssl.c:220:9: warning: ‘RSA_generate_key_ex’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
220 | RSA_generate_key_ex(rsa, bits, BN_value_RSA_F4, NULL);
| ^~~~~~~~~~~~~~~~~~~
/usr/include/openssl/rsa.h:265:27: note: declared here
265 | OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e,
| ^~~~~~~~~~~~~~~~~~~
/tmp/libks/src/ks_ssl.c:227:9: warning: ‘EVP_PKEY_assign’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
227 | if (!EVP_PKEY_assign_RSA(pk, rsa)) {
| ^~
In file included from /usr/include/openssl/x509.h:29:
/usr/include/openssl/evp.h:1328:5: note: declared here
1328 | int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
| ^~~~~~~~~~~~~~~
pi@raspberrypi:~/projects/libks $ make
Scanning dependencies of target ks
[ 1%] Building C object CMakeFiles/ks.dir/src/ks.c.o
[ 2%] Building C object CMakeFiles/ks.dir/src/ks_acl.c.o
[ 3%] Building C object CMakeFiles/ks.dir/src/ks_base64.c.o
[ 4%] Building C object CMakeFiles/ks.dir/src/ks_buffer.c.o
[ 5%] Building C object CMakeFiles/ks.dir/src/ks_config.c.o
[ 7%] Building C object CMakeFiles/ks.dir/src/ks_debug.c.o
[ 8%] Building C object CMakeFiles/ks.dir/src/ks_dso.c.o
[ 9%] Building C object CMakeFiles/ks.dir/src/ks_env.c.o
[ 10%] Building C object CMakeFiles/ks.dir/src/ks_handle.c.o
[ 11%] Building C object CMakeFiles/ks.dir/src/ks_hash.c.o
[ 13%] Building C object CMakeFiles/ks.dir/src/ks_json.c.o
[ 14%] Building C object CMakeFiles/ks.dir/src/ks_json_check.c.o
[ 15%] Building C object CMakeFiles/ks.dir/src/ks_log.c.o
[ 16%] Building C object CMakeFiles/ks.dir/src/ks_metrics.c.o
[ 17%] Building C object CMakeFiles/ks.dir/src/ks_mutex.c.o
[ 19%] Building C object CMakeFiles/ks.dir/src/ks_pool.c.o
[ 20%] Building C object CMakeFiles/ks.dir/src/ks_printf.c.o
[ 21%] Building C object CMakeFiles/ks.dir/src/ks_q.c.o
[ 22%] Building C object CMakeFiles/ks.dir/src/ks_sb.c.o
[ 23%] Building C object CMakeFiles/ks.dir/src/ks_socket.c.o
[ 25%] Building C object CMakeFiles/ks.dir/src/ks_ssl.c.o
/home/pi/projects/libks/src/ks_ssl.c: In function ‘ks_gen_cert’:
/home/pi/projects/libks/src/ks_ssl.c:134:2: warning: implicit declaration of function ‘CRYPTO_mem_ctrl’ [-Wimplicit-function-declaration]
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
^~~~~~~~~~~~~~~
/home/pi/projects/libks/src/ks_ssl.c:134:18: error: ‘CRYPTO_MEM_CHECK_ON’ undeclared (first use in this function)
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
^~~~~~~~~~~~~~~~~~~
/home/pi/projects/libks/src/ks_ssl.c:134:18: note: each undeclared identifier is reported only once for each function it appears in
/home/pi/projects/libks/src/ks_ssl.c: In function ‘mkcert’:
/home/pi/projects/libks/src/ks_ssl.c:218:9: warning: ‘RSA_generate_key_ex’ is deprecated [-Wdeprecated-declarations]
RSA_generate_key_ex(rsa, bits, BN_value_RSA_F4, NULL);
^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/openssl/opensslv.h:109:0,
from /usr/local/include/openssl/macros.h:11,
from /usr/local/include/openssl/opensslconf.h:14,
from /usr/local/include/openssl/macros.h:10,
from /usr/local/include/openssl/ssl.h:16,
from /home/pi/projects/libks/src/include/libks/ks_ssl.h:25,
from /home/pi/projects/libks/src/include/libks/ks.h:73,
from /home/pi/projects/libks/src/ks_ssl.c:23:
/usr/local/include/openssl/rsa.h:249:1: note: declared here
DEPRECATEDIN_3_0(int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e,
^
CMakeFiles/ks.dir/build.make:590: recipe for target 'CMakeFiles/ks.dir/src/ks_ssl.c.o' failed
make[2]: *** [CMakeFiles/ks.dir/src/ks_ssl.c.o] Error 1
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/ks.dir/all' failed
make[1]: *** [CMakeFiles/ks.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Hi,
It worked until recently, now it does:
root@cda0d75c8eb4:/# git clone https://github.com/signalwire/libks.git --depth=1 Cloning into 'libks'...
remote: Enumerating objects: 142, done.
remote: Counting objects: 100% (142/142), done.
remote: Compressing objects: 100% (121/121), done.
remote: Total 142 (delta 28), reused 80 (delta 16), pack-reused 0
Receiving objects: 100% (142/142), 287.71 KiB | 3.16 MiB/s, done.
Resolving deltas: 100% (28/28), done.
root@cda0d75c8eb4:/# cd links
bash: cd: links: No such file or directory
root@cda0d75c8eb4:/# cd libks
root@cda0d75c8eb4:/libks# git clone https://github.com/signalwire/libks.git --depth=1^C
root@cda0d75c8eb4:/libks# git log
commit 940d659c583b255a96cac77e7e9fe62195c40e0b (grafted, HEAD -> master, origin/master, origin/HEAD)
Author: Anthony Minessale <[email protected]>
Date: Thu Nov 9 14:19:28 2023 -0600
Merge pull request #171 from signalwire/realloc_crash
maybe fix, at least doesn't crash
(reverse-i-search)`': ^C
root@cda0d75c8eb4:/libks# cd /libks && git clean -xfd; git reset --hard; PACKAGE_RELEASE="0" cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release && make package -j12 && mv *.deb /
HEAD is now at 940d659 Merge pull request #171 from signalwire/realloc_crash
Platform is linux
Build type: Release CXX Flags:
Install prefix: /usr
-- Found Git: /usr/bin/git (found version "2.30.2")
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
LibKS2 Version 2.0
Detecting last git tag to generate a Debian complian changelog.
fatal: No names found, cannot describe anything.
fatal: option '--count' must come before non-option arguments
Found last git tag:
Generating a changelog using commits since git tag:
CMake Error at CMakeLists.txt:315 (string):
string sub-command REPLACE requires at least four arguments.
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for clock_getres in rt
-- Looking for clock_getres in rt - found
-- Looking for clock_nanosleep in rt
-- Looking for clock_nanosleep in rt - found
-- Looking for strftime in rt
-- Looking for strftime in rt - found
-- Looking for sched_setscheduler in c
-- Looking for sched_setscheduler in c - found
-- Looking for malloc in c
-- Looking for malloc in c - found
-- Looking for usleep in c
-- Looking for usleep in c - found
-- Looking for pthread_attr_setschedparam
-- Looking for pthread_attr_setschedparam - found
-- Looking for memmem
-- Looking for memmem - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for sched.h
-- Looking for sched.h - found
-- Looking for byteswap.h
-- Looking for byteswap.h - found
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Found LibM: /usr/lib/x86_64-linux-gnu/libm.so
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'uuid'
-- Found uuid, version 2.36.1
Found UUID setup target at imported location: /usr/lib/x86_64-linux-gnu/libuuid.so
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1w")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1w") found components: Crypto SSL
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
Compiler supports visibility
-- Configuring incomplete, errors occurred!
See also "/libks/CMakeFiles/CMakeOutput.log".
See also "/libks/CMakeFiles/CMakeError.log".
It appears the git magic you are doing is a little birttle. There are other instances of these errors when doing a Google search, so I am not alone doing this. The fix is to do a full clone. Thankfully the library is quite small, but full clones slow down CI jobs.
Hi, when I'm trying to run cmake . to build my libks i get an error "CheckSymbolExists.c:(.text+0x1b): undefine reference to `pthread_create'". Can anyone tell me what should I change or update to obey this problem?
I am attempting to install freeswitch with mod_signalwire support on Ubuntu 22.04. When I go to build libks, I always fail.
Does this have to do with openssl version? If so, the cmake should have flagged the wrong version, I assume, which it did not.
========== Results from cmake . ===============
root@phoneNUC:$ cmake .
Platform is linux
Build type: Debug CXX Flags:
Install prefix: /usr
-- Found Git: /usr/bin/git (found version "2.34.1")
-- The C compiler identification is GNU 10.4.0
-- The CXX compiler identification is GNU 10.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
LibKS Version 1.8
Detecting last git tag to generate a Debian complian changelog.
Found last git tag: v1.8.2
Generating a changelog using commits since git tag: v1.8.2
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for clock_getres in rt
-- Looking for clock_getres in rt - found
-- Looking for clock_nanosleep in rt
-- Looking for clock_nanosleep in rt - found
-- Looking for strftime in rt
-- Looking for strftime in rt - found
-- Looking for sched_setscheduler in c
-- Looking for sched_setscheduler in c - found
-- Looking for malloc in c
-- Looking for malloc in c - found
-- Looking for usleep in c
-- Looking for usleep in c - found
-- Looking for pthread_setschedparam
-- Looking for pthread_setschedparam - found
-- Looking for memmem
-- Looking for memmem - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for sched.h
-- Looking for sched.h - found
-- Looking for byteswap.h
-- Looking for byteswap.h - found
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Found LibM: /usr/lib/x86_64-linux-gnu/libm.so
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Checking for module 'uuid'
-- Found uuid, version 2.37.2
Found UUID setup target at imported location: /usr/lib/x86_64-linux-gnu/libuuid.so
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.2")
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.2") found components: Crypto SSL
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
Compiler supports visibility
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/libks
========== Results from make ================
root@phoneNUC:$ make
[ 1%] Building C object CMakeFiles/ks.dir/src/include/cJSON/cJSON.c.o
[ 2%] Building C object CMakeFiles/ks.dir/src/include/cJSON/cJSON_Utils.c.o
[ 3%] Building C object CMakeFiles/ks.dir/src/ks.c.o
[ 4%] Building C object CMakeFiles/ks.dir/src/ks_acl.c.o
[ 5%] Building C object CMakeFiles/ks.dir/src/ks_base64.c.o
[ 7%] Building C object CMakeFiles/ks.dir/src/ks_buffer.c.o
[ 8%] Building C object CMakeFiles/ks.dir/src/ks_config.c.o
[ 9%] Building C object CMakeFiles/ks.dir/src/ks_debug.c.o
[ 10%] Building C object CMakeFiles/ks.dir/src/ks_dso.c.o
[ 11%] Building C object CMakeFiles/ks.dir/src/ks_env.c.o
[ 13%] Building C object CMakeFiles/ks.dir/src/ks_handle.c.o
[ 14%] Building C object CMakeFiles/ks.dir/src/ks_hash.c.o
[ 15%] Building C object CMakeFiles/ks.dir/src/ks_json.c.o
[ 16%] Building C object CMakeFiles/ks.dir/src/ks_json_check.c.o
[ 17%] Building C object CMakeFiles/ks.dir/src/ks_log.c.o
[ 19%] Building C object CMakeFiles/ks.dir/src/ks_metrics.c.o
[ 20%] Building C object CMakeFiles/ks.dir/src/ks_mutex.c.o
[ 21%] Building C object CMakeFiles/ks.dir/src/ks_pool.c.o
[ 22%] Building C object CMakeFiles/ks.dir/src/ks_printf.c.o
[ 23%] Building C object CMakeFiles/ks.dir/src/ks_q.c.o
[ 25%] Building C object CMakeFiles/ks.dir/src/ks_sb.c.o
[ 26%] Building C object CMakeFiles/ks.dir/src/ks_socket.c.o
[ 27%] Building C object CMakeFiles/ks.dir/src/ks_ssl.c.o
[ 28%] Building C object CMakeFiles/ks.dir/src/ks_string.c.o
[ 29%] Building C object CMakeFiles/ks.dir/src/ks_thread.c.o
[ 30%] Building C object CMakeFiles/ks.dir/src/ks_thread_pool.c.o
[ 32%] Building C object CMakeFiles/ks.dir/src/ks_throughput.c.o
[ 33%] Building C object CMakeFiles/ks.dir/src/ks_time.c.o
[ 34%] Building C object CMakeFiles/ks.dir/src/ks_utf8.c.o
[ 35%] Building C object CMakeFiles/ks.dir/src/ks_uuid.c.o
[ 36%] Building C object CMakeFiles/ks.dir/src/kws.c.o
[ 38%] Building C object CMakeFiles/ks.dir/src/simclist.c.o
/opt/libks/src/simclist.c: In function ‘ks_list_dump_filedescriptor’:
/opt/libks/src/simclist.c:95:57: warning: ‘write’ reading 8 bytes from a region of size 4 [-Wstringop-overflow=]
95 | if (write(fd, msgbuf, msglen) < 0) return -1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/libks/src/simclist.c:1357:6: note: in expansion of macro ‘WRITE_ERRCHECK’
1357 | WRITE_ERRCHECK(fd, &bufsize, sizeof(ks_size_t));
| ^~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/x86_64-linux-gnu/sys/signal.h:1,
from /opt/libks/src/include/libks/ks_platform.h:94,
from /opt/libks/src/include/libks/ks.h:38,
from /opt/libks/src/simclist.c:23:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘read_only (2, 3)’
378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
| ^~~~~
/opt/libks/src/simclist.c:95:57: warning: ‘write’ reading 8 bytes from a region of size 4 [-Wstringop-overflow=]
95 | if (write(fd, msgbuf, msglen) < 0) return -1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/libks/src/simclist.c:1382:6: note: in expansion of macro ‘WRITE_ERRCHECK’
1382 | WRITE_ERRCHECK(fd, &bufsize, sizeof(ks_size_t));
| ^~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /usr/include/x86_64-linux-gnu/sys/signal.h:1,
from /opt/libks/src/include/libks/ks_platform.h:94,
from /opt/libks/src/include/libks/ks.h:38,
from /opt/libks/src/simclist.c:23:
/usr/include/unistd.h:378:16: note: in a call to function ‘write’ declared with attribute ‘read_only (2, 3)’
378 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
| ^~~~~
[ 39%] Linking C shared library libks.so
[ 39%] Built target ks
[ 40%] Building C object tests/CMakeFiles/testpools.dir/testpools.c.o
[ 41%] Building C object tests/CMakeFiles/testpools.dir/tap.c.o
[ 42%] Linking C executable testpools
/usr/bin/ld: ../libks.so.1: undefined reference to CRYPTO_mem_ctrl' /usr/bin/ld: ../libks.so.1: undefined reference to
SSL_get_peer_certificate'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/testpools.dir/build.make:116: tests/testpools] Error 1
make[1]: *** [CMakeFiles/Makefile2:185: tests/CMakeFiles/testpools.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
I found an rpm package like this for CentOS 7:
https://files.freeswitch.org/repo/yum/centos-release/7/x86_64/libks-1.7.0-16.el7.centos.rpm
I would like to use a source package (libks-1.7.0-16.el7.centos.src.rpm) to build rpm for CentOS 8 from this.
Do any of you know if it is possible to download it and possibly from where (or the spec file itself).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.