Log initialization errors in PyS2OPC
Description
Sometimes log cannot be initialized in S2OPC, raising the following error:
WARNING: log creation failed, no log will be recorded !
ERROR: S2OPC Logs initialization failed!
Traceback (most recent call last):
File "server.py", line 237, in <module>
with PyS2OPC.initialize(logPath=args.log_path):
File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/S2OPC/build/pys2opc_install/pys2opc/s2opc.py", line 461, in initialize
assert status == ReturnStatus.OK, 'Common initialization failed with status {}'.format(ReturnStatus.get_both_from_id(status))
Analysis
logConfiguration.logSysConfig.fileSystemLogConfig.logDirPath
is correctly set by the caller to SOPC_Common_Initialize
but it changes values unexpectedly.
Further analysis reveals that part of its supposedly allocated memory is in fact used by other mallocs.
This is du to incorrect use of ffi.new()
in s2opc.py
.