<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17032</bug_id>
          
          <creation_ts>2008-01-27 12:04:02 -0800</creation_ts>
          <short_desc>No rand_s on Windows 2000 -&gt; crash</short_desc>
          <delta_ts>2012-09-06 17:30:26 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 2000</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P4</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>eu4bbt12phas4ek</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>barraclough</cc>
    
    <cc>hausmann</cc>
    
    <cc>jeisecke</cc>
    
    <cc>xhva.net</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>68371</commentid>
    <comment_count>0</comment_count>
    <who name="">eu4bbt12phas4ek</who>
    <bug_when>2008-01-27 12:04:02 -0800</bug_when>
    <thetext>There is no rand_s on Windows 2000.
Safari crashes with first html request.

Related files:
http://trac.webkit.org/projects/webkit/browser/trunk/JavaScriptCore/kjs/config.h
http://trac.webkit.org/projects/webkit/browser/trunk/JavaScriptCore/wtf/MathExtras.h</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68374</commentid>
    <comment_count>1</comment_count>
    <who name="">eu4bbt12phas4ek</who>
    <bug_when>2008-01-27 12:08:23 -0800</bug_when>
    <thetext>see also:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101607</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68398</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2008-01-27 18:02:29 -0800</bug_when>
    <thetext>http://www.apple.com/safari/download/ states that Safari is only supported on Windows XP and Vista.  Windows XP has been the minimum officially supported version since the initial beta release.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>68442</commentid>
    <comment_count>3</comment_count>
    <who name="Adam Roben (:aroben)">aroben</who>
    <bug_when>2008-01-28 08:50:04 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; http://www.apple.com/safari/download/ states that Safari is only supported on
&gt; Windows XP and Vista.  Windows XP has been the minimum officially supported
&gt; version since the initial beta release.

That&apos;s not to say this bug can&apos;t be fixed, though! We&apos;ll gladly accept a patch to fix this that doesn&apos;t regress other platforms.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69380</commentid>
    <comment_count>4</comment_count>
    <who name="">eu4bbt12phas4ek</who>
    <bug_when>2008-02-04 13:05:30 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; That&apos;s not to say this bug can&apos;t be fixed, though! We&apos;ll gladly accept a patch
&gt; to fix this that doesn&apos;t regress other platforms.

I&apos;ve found the bug through Qt&apos;s webkit integration, and I assume they wanna
support win2k. 

The solution is to not use rand_s on win2k. 
But to have only one binary excludes a macro solution.
It must be checked for rand_s at runtime:

somewhere in a cpp file:

#include &lt;windows.h&gt;

bool checkFor_rand_s()
{
	HMODULE dll = LoadLibrary(&quot;ADVAPI32.DLL&quot;);
	if (dll &amp;&amp; GetProcAddress(dll, &quot;RtlGenRandom&quot;) ) {
		FreeLibrary(dll);
		return true;
	}
	FreeLibrary(dll);
	return false;
}


And a dynamic switch in wtf_random_init/wtf_random,

static bool do_check = true;		
static bool rand_s_exists = false;
if (do_check) {
    rand_s_exists = checkFor_rand_s();
}
if (rand_s_exists) {
....
}


The only problem I see is that it is ugly and that it eventually
breaks the inlining of the rand functions.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69382</commentid>
    <comment_count>5</comment_count>
    <who name="">eu4bbt12phas4ek</who>
    <bug_when>2008-02-04 13:08:37 -0800</bug_when>
    <thetext>correction:

if (do_check) {
    do_check = false;
    rand_s_exists = checkFor_rand_s();
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76475</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2008-04-07 03:47:36 -0700</bug_when>
    <thetext>A more complete patch can also be found at

http://lists.trolltech.com/qt4-preview-feedback/2008-04/thread00028-0.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85975</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-07-15 15:10:22 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; http://lists.trolltech.com/qt4-preview-feedback/2008-04/thread00028-0.html

+void check_for_rand_s()
+{
+    if (!already_checked) {

There is no need for this check - check_for_rand_s() is called from wtf_random_init(), which is guaranteed to be called once.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274579</commentid>
    <comment_count>8</comment_count>
    <who name="Nils Jeisecke">jeisecke</who>
    <bug_when>2010-09-06 06:15:25 -0700</bug_when>
    <thetext>Nobody interested in Windows 2000 any more?

The code seems to have been moved to JavaScriptCore/wtf/RandomNumber.cpp but the idea of the patch should still solve the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>713899</commentid>
    <comment_count>9</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2012-09-06 17:30:26 -0700</bug_when>
    <thetext>We don&apos;t appear to call rand_s any more.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>