Bug 164637 - [libc] Problem with vsnprintf in libc.so when compiled with clang
Summary: [libc] Problem with vsnprintf in libc.so when compiled with clang
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-30 15:20 UTC by Pierre-Luc Drouin
Modified: 2014-06-02 09:01 UTC (History)
1 user (show)

See Also:


Attachments
hs_err_pid43502.log (6.86 KB, application/octet-stream)
2012-01-30 16:20 UTC, Pierre-Luc Drouin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.