Bug 844491 - tests fail to run: The procedure entry point sprintf_s could not be located in msvcrt.dll
tests fail to run: The procedure entry point sprintf_s could not be located i...
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: mingw-cppunit (Show other bugs)
17
Unspecified Windows
unspecified Severity unspecified
: ---
: ---
Assigned To: Nicolas Chauvet (kwizart)
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-30 18:05 EDT by Tim Mayberry
Modified: 2012-09-07 10:37 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-09-07 10:37:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to fix runtime issue on windows XP (580 bytes, patch)
2012-07-31 01:25 EDT, Tim Mayberry
no flags Details | Diff

  None (edit)
Description Tim Mayberry 2012-07-30 18:05:11 EDT
Description of problem:

We use Fedora to cross compile an application targetting windows using mingw packages. We also use cppunit to run a number of tests. After upgrading to Fedora 17 the tests fail to run giving the error "The procedure entry point sprintf_s could not be located in the dynamic link library msvcrt.dll

This is using Windows XP with service pack 3

Version-Release number of selected component (if applicable):

mingw32-cppunit-1.12.1-9.fc17.noarch

How reproducible:

Cross compile a test program linking to cppunit and try to run the resulting executable under Windows.

Additional info:

After a casual look into this issue it appears that Cppunit uses the sprintf_s function in TestAssert.h if __STDC_SECURE_LIB__ is defined, which it is in _mingw.h

It looks like the Suse mingw package has a patch for this issue:
https://build.opensuse.org/package/view_file?file=cppunit-1.12.1-windows.patch&package=mingw32-libcppunit&project=windows%3Amingw%3Awin32&rev=09faaad12ffc214b0c257378391a3121
Comment 1 Nicolas Chauvet (kwizart) 2012-07-30 18:39:28 EDT
Thx for your report.
Can you verify in which upstream version the patch was applied ?
Comment 2 Tim Mayberry 2012-07-31 01:24:45 EDT
(In reply to comment #1)
> Thx for your report.
> Can you verify in which upstream version the patch was applied ?

I don't believe the patch has been applied upstream. The sprintf_s function being used by cppunit was introduced in VS 2005(msvcrt80.dll) according to:

http://msdn.microsoft.com/en-us/library/ce3zzk1k%28v=vs.80%29.aspx#1

It may be exported in later versions of msvcrt.dll(vista,7) but at least on XP I get the above error.

I'll attach a patch(same as suse) which fixes the issue for me.
Comment 3 Tim Mayberry 2012-07-31 01:25:48 EDT
Created attachment 601428 [details]
Patch to fix runtime issue on windows XP
Comment 4 Nicolas Chauvet (kwizart) 2012-07-31 02:22:14 EDT
Ok I will reword.
Please forward this patch upstream for inclusion, I will backport once accepted
Comment 5 Nicolas Chauvet (kwizart) 2012-07-31 02:23:20 EDT
FYI:
http://fedoraproject.org/wiki/Staying_close_to_upstream_projects
Comment 6 Tim Mayberry 2012-08-01 07:20:36 EDT
(In reply to comment #4)
> Ok I will reword.
> Please forward this patch upstream for inclusion, I will backport once
> accepted

I don't believe the patch is appropriate for upstream inclusion.

Cppunit is using the "secure" version of the sprintf function because the mingw-64 headers make the secure API available. The problem is that the secure functions are only exported in versions of msvcrt.dll in Vista and above(or so the internet tells me) so if you use them you restrict what versions of Windows your executable will run on.

So the patch is really working around what seems to be a problem in mingw-64

There is a somewhat relevant thread on the mingw-64 mailing list:

http://sourceforge.net/mailarchive/forum.php?thread_name=CAEwic4amFD03iRVBnq6jXifi6AvSVBfTgb8efK60V5dLR0NFPQ%40mail.gmail.com&forum_name=mingw-w64-public
Comment 7 Nicolas Chauvet (kwizart) 2012-09-07 10:37:31 EDT
(In reply to comment #6)
> (In reply to comment #4)
> > Ok I will reword.
> > Please forward this patch upstream for inclusion, I will backport once
> > accepted
> 
> I don't believe the patch is appropriate for upstream inclusion.
So I cannot see how it would be appropriate for fedora either.
Vista and later x64 users should expect to use the secure version.

Anyway, I don't mean that this is to be discussed here, but upstream.

Note You need to log in before you can comment on or make changes to this bug.