On 2010-12-19 00:56 PDT, Marsh Ray wrote: > On 12/19/2010 02:27 AM, Nelson Bolyard wrote: >> Yes, Mozilla builds its own CRT, which is a modified version of the MSVC >> CRT, whose sources come only with the pay (not free) versions of MSVC. >> They do this in order to replace MSVC's normal heap code (malloc) with >> their own "JEmalloc". >> >> Mozilla's source repository doesn't include ANY of the MSVC source code, >> but only includes a ed script that patches that source without including >> any of it. Sadly, this means that people with the free MSVC cannot build >> MOZCRT19, because they lack the sources to be patched. IMO, this is a >> flaw for an open source project, but ... :( > > Can you build it against the compiler's CRT if you want to?
Not that I'm aware. But I've never tried. >> Well, I think the big question is: why does the heap allocation fail? >> >>> You need to track down where the first error occurs. >> My first wild guess is that Matej's PKCS#11 module is doing something bad >> to the heap. > > Like if Matej's module were linked to some other CRT and an interface > passed memory that way. Historically, having multiple CRTs in the same > process has been a recipe for disaster on Windows. I was thinking of allocating a buffer of size N and then writing past the end of it. That's the most common problem, IMO. >> My second one is that NSS or PSM is trying to free to the >> MOZCRT17 heap something that was allocated from another heap. > > Or perhaps vice versa, but wouldn't that likely have thrown at the point > of the bad free or delete? Not clear. The "debug CRT" would catch such thing at free/delete time, but not clear that any other CRT would do so. Actually, in retrospect, I think it's doubtful that this second guess is the problem, because the PKCS#11 API doesn't ever pass allocated memory from one side of the API to the other, for the receiving side to deallocate. Generally, the process using the module allocates all memory, and frees what it allocated. It asks the PKCS#11 module to take data from, or put data into, the memory it supplies, but the module should never free memory passed in to it, and never outputs the addresses of memory that it has allocated. -- /Nelson Bolyard -- dev-tech-crypto mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-crypto

