Bug 164637

Summary: [libc] Problem with vsnprintf in libc.so when compiled with clang
Product: Base System Reporter: Pierre-Luc Drouin <pldrouin>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: theraven
Priority: Normal    
Version: 9.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
hs_err_pid43502.log none

Description Pierre-Luc Drouin 2012-01-30 15:20:08 UTC
When FreeBSD world (and kernel) is built using clang, the resulting code generated for vsnprintf in the library libc.so does not work properly, causing a segmentation fault. The problem was discovered when attempting to use java on FreeBSD.

How-To-Repeat: Compile and run the following C code on FreeBSD 9.0-STABLE built with clang:

#include <stdio.h>
#include <string.h>

int main(int nargrs, const char* args[])
{
  const char* msg="Hello World!";
  int length=strlen(msg);
  printf("length is %i\n",length);
  char string0[256];
  char string[256];
  memset(string0,1,256);
  strcpy(string0,msg);
  vsnprintf(string+1,length,"%s",string0);
  printf("%s\n",string);

  return 0;
}

Alternatively, try launching java or javac from jdk16, diablo-jdk16 or openjdk6
Comment 1 David Chisnall freebsd_committer freebsd_triage 2014-06-02 09:01:11 UTC
The string0 argument is not a valid va_list, so this test case appears to be invalid.  Please reopen if you have a test case that does not rely on undefined behaviour.