Segfault in fprintf in thread with minimal stack size

Bug #1231272 reported by larsch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

A thread started with a minimal stack size (PTHREAD_STACK_MIN from limits.h), can't even call fprintf(stderr, "%s", "") without segfaulting. Took me a good while to debug this one in our embedded software.

This program will segfault:

#include <pthread.h>
#include <stdio.h>
#include <limits.h>

static void* thread_function(void* arg)
{
   fprintf(stderr, "Hello, %s!", "World");
   return 0;
}

int main()
{
   pthread_attr_t attr;
   pthread_t thread;
   pthread_attr_init(&attr);
   pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
   pthread_create(&thread, &attr, &thread_function, 0);
   pthread_join(thread, 0);
   return 0;
}

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libc6-dev 2.15-0ubuntu10.4
ProcVersionSignature: Ubuntu 3.2.0-53.81-generic 3.2.50
Uname: Linux 3.2.0-53-generic i686
ApportVersion: 2.0.1-0ubuntu17.4
Architecture: i386
Date: Thu Sep 26 08:09:33 2013
InstallationMedia: Ubuntu-Server 12.04.3 LTS "Precise Pangolin" - Release i386 (20130820.2)
MarkForUpload: True
ProcEnviron:
 LANGUAGE=en_US:en
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
larsch (larsch) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.