Hello UA Company,
I see a segmentation fault which is simple to reproduce with the evaluation version of the UA SDK C++.
Namely with this code:
#include <uaplatformlayer.h>
#include <uabase.h>
#include <uaarraytemplates.h>
int main ()
{
UaPlatformLayer::init();
UaDoubleArray ua;
ua.create( 1000000000 );
}
it segfaults here:
(gdb) bt
#0 0x00007ffff728181d in __memset_sse2 () from /lib64/libc.so.6
#1 0x0000000000453116 in UaDoubleArray::create(unsigned int) ()
#2 0x000000000044a7b8 in main ()
FYI: With the size of 500M it is still fine - however my friend mentions that in his case, 500M is enough to segfault.
I understand that there are limits of memory allocation, but a segfault is not a good indicator that we're out of limits ;-) Could an exception be thrown?
Segmentation fault by creating an array of relatively big si
Moderator: uasdkcpp
-
- Sr. Member
- Posts: 10
- Joined: 04 Jul 2013, 14:01
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re: Segmentation fault by creating an array of relatively bi
Hello schlenk,
the method UaDoubleArray::create() does not explicitly handle out of memory situation.
A double has a size of 8 Bytes so allocating an array of 1000000000 doubles would require to allocate a block of around 7,5 Gb of memory.
the method UaDoubleArray::create() does not explicitly handle out of memory situation.
A double has a size of 8 Bytes so allocating an array of 1000000000 doubles would require to allocate a block of around 7,5 Gb of memory.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Sr. Member
- Posts: 10
- Joined: 04 Jul 2013, 14:01
Re: Segmentation fault by creating an array of relatively bi
Hello,
My main point is that a segfault is a bad thing, and it should not happen when someone considers given OPC-UA SDK for a 24/7 critical production software.
So the question is: could the SDK be fixed in this aspect either
(a) by throwing a C++ exception, or
(b) by returning an UaStatus code
rather than crashing?
PS. 7,5 GB of memory is not particularly exotic those days... one commonly sees 16GB of RAM in desktop machines, plus swap space etc ...
My main point is that a segfault is a bad thing, and it should not happen when someone considers given OPC-UA SDK for a 24/7 critical production software.
So the question is: could the SDK be fixed in this aspect either
(a) by throwing a C++ exception, or
(b) by returning an UaStatus code
rather than crashing?
PS. 7,5 GB of memory is not particularly exotic those days... one commonly sees 16GB of RAM in desktop machines, plus swap space etc ...
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re: Segmentation fault by creating an array of relatively bi
Hello schlenk,
I understood your point and I agree that a segfault is not the desired behaviour in this case.
However the C++ SDK can not handle this kind of out-of-memory situation gracefully. We do not use exceptions in the SDK.
There's not really a quick fix for that problem that works for all scenarios.
I understood your point and I agree that a segfault is not the desired behaviour in this case.
However the C++ SDK can not handle this kind of out-of-memory situation gracefully. We do not use exceptions in the SDK.
There's not really a quick fix for that problem that works for all scenarios.
Best regards
Unified Automation Support Team
Unified Automation Support Team