From cf6e97119df5bf17b4a952b257d05d43b7d6ca26 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 21 Jan 2015 09:10:01 +0000 Subject: Don't crash on FreeBSD when computing stack limits On FreeBSD pthread_attr_t is a pointer and is dereferenced when calling pthread_attr_get_np() so if we don't initialize it will probably crash. This is not a problem on glibc systems since there pthread_attr_t is an opaque union an doesn't need to be allocated using malloc(). Change-Id: I227685ddf9981974ade08aee8917f7262c301787 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 74b262e86d..5bba745ae2 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -112,7 +112,8 @@ quintptr getStackLimit() void* stackBottom = 0; pthread_attr_t attr; #if HAVE(PTHREAD_NP_H) && OS(FREEBSD) - if (pthread_attr_get_np(pthread_self(), &attr) == 0) { + // on FreeBSD pthread_attr_init() must be called otherwise getting the attrs crashes + if (pthread_attr_init(&attr) == 0 && pthread_attr_get_np(pthread_self(), &attr) == 0) { #else if (pthread_getattr_np(pthread_self(), &attr) == 0) { #endif -- cgit v1.2.3