question on msvcrt.dll versioning

R

rogerdpack

It appears from sites like
http://www.develer.com/oss/GccWinBinaries
at the bottom that at least this developer made an effort to link
against the same version of msvcrt.dll that the python exe was
compiled with [ex: vc2008 -> msvcr90.dll]. Is this pain necessary?
Are there known drawbacks to not doing this anyone can think of? [just
trying to plan releases for windows ruby shtuffs with similar
problems].
Thanks!
-=roger
 
M

Martin v. Löwis

rogerdpack said:
It appears from sites like
http://www.develer.com/oss/GccWinBinaries
at the bottom that at least this developer made an effort to link
against the same version of msvcrt.dll that the python exe was
compiled with [ex: vc2008 -> msvcr90.dll]. Is this pain necessary?

It depends on fine details of your extension module whether it is
necessary or not.
Are there known drawbacks to not doing this anyone can think of?

Sure. It might be that Python crashes if you use a different CRT.

More specifically, if you link several CRTs into a single operating
system process, they get each its own set of CRT global variables.
Modifying a global in one CRT doesn't affect the others; passing
pointers to such globals around may cause bad behavior.

Even more specifically, the following globals in the CRT are known
to be problematic:
- each CRT maintains its own heap. So memory allocated by malloc()
in one CRT, and released with free() in a different one won't
get back to the free list of the first CRT. As a consequence,
the memory will fragment, and you get memory leaks.
- each CRT has its own locale and time zone settings. Setting the locale
in one CRT won't have effect on the other CRTs.
- each CRT has its own set of struct FILE. As a consequence, passing
FILE* across CRT boundaries will crash the CRT, as the MT fields
of struct FILE won't be where the CRT expects them.

Yet more specifically: if the extension module or Python host opens
a file with fopen(), and passes it to PyRun_{Any|Simple}File[Ex][Flags],
Python will crash.

HTH,
Martin

P.S. There may be more cases in which you get crashes - the list above
includes just the known ones.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top