Click here to Skip to main content
15,915,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Showing an image to the use Pin
CPallini17-Mar-09 11:57
mveCPallini17-Mar-09 11:57 
AnswerRe: Showing an image to the use Pin
llp00na17-Mar-09 12:01
llp00na17-Mar-09 12:01 
AnswerRe: Showing an image to the use Pin
bulg17-Mar-09 12:04
bulg17-Mar-09 12:04 
GeneralRe: Showing an image to the use Pin
llp00na17-Mar-09 12:27
llp00na17-Mar-09 12:27 
GeneralRe: Showing an image to the use Pin
CPallini17-Mar-09 13:10
mveCPallini17-Mar-09 13:10 
GeneralRe: Showing an image to the use Pin
bulg17-Mar-09 13:32
bulg17-Mar-09 13:32 
GeneralRe: Showing an image to the use Pin
llp00na17-Mar-09 13:53
llp00na17-Mar-09 13:53 
QuestionBit for bit reproducible build in vc6. Pin
_aesthetic_17-Mar-09 11:19
_aesthetic_17-Mar-09 11:19 
Heya folks.

I've been pulled into a vc6 project at the last minute. My particular task is to make a relatively large build reproducible, bit for bit, as it will be subject to auditing. The reason I was tasked with it is because I did this for another project a few years ago using MSVS 2003, but I've hit a wall with vc6.

The tl;dr version is, has anyone successfully done this with vc6? Moving to a newer tool chain isn't an option, as it's not my project.

We're building in a VM to minimize any environment differences. In the VM, we always build from the same directory, so that makes any source filenames pulled in via __FILE__ the same. As a post process, we walk the PE headers to find all of the timestamps in the file and set them to midnight, 2000-Jan-01. In the previous project, this was all that was needed. In that VM, running on any of the machines that we tested on, all builds of a particular revision would match.

Doing that with the vc6 project will work sometimes, but sometimes not. To really isolate any local differences, we have 2 machines with the same hardware using a cloned drive. Neither machine is on a network, so they don't have any collisions with each other. Because the drives are cloned, the VMs and VM executables are identical. When we put our source archive on the machine, we copy it via usb drive (same drive into the same respective usb port), unpack it, and then reboot. After rebooting, we run vc6, select our build target, and rebuild all. Running the build in this manner on these machines will sometimes produce different output. It's intermittent, but it only affects one of our 3 binary outputs. We also build a pthreads dll and shell process, and both of those always match after our timestamp fixups.

After some investigation, I'm pretty sure that the first issue (of many) is that cin, cout, and cerr (or their static constructors) are off by 3000h in the different builds. That's a huge problem, and it sounds like linker order. This project has thousands of files. Is it possible to specify their build and link orders short of a .bat file? Would that even work?

Using a binary diff of the two files, there is an area of about 1600 bytes starting at 001E41C0h (1982912) with sparse differences. Usually 1 or 2 bytes differ, then there is a string of 8-32 identical bytes. An example of the first diff, from VBinDiff, is

vm1.exe
001E 41A0: 68 80 F8 5D 00 E8 82 BD 01 00 59 C3 90 90 90 90 hÇ°].Φé╜ ..Y├ÉÉÉÉ
001E 41B0: E8 0B 00 00 00 E9 16 00 00 00 90 90 90 90 90 90 Φ....Θ.. ..ÉÉÉÉÉÉ
001E 41C0: B9 51 5C 77 00 E9 4A 10 01 00 90 90 90 90 90 90 ╣Q\w.ΘJ. ..ÉÉÉÉÉÉ
001E 41D0: 68 E0 41 5E 00 E8 52 BD 01 00 59 C3 90 90 90 90 hαA^.ΦR╜ ..Y├ÉÉÉÉ
001E 41E0: B9 51 5C 77 00 E9 A9 11 01 00 90 90 90 90 90 90 ╣Q\w.Θ⌐. ..ÉÉÉÉÉÉ
001E 41F0: E8 0B 00 00 00 E9 16 00 00 00 90 90 90 90 90 90 Φ....Θ.. ..ÉÉÉÉÉÉ
001E 4200: B9 50 5C 77 00 E9 E5 14 01 00 90 90 90 90 90 90 ╣P\w.Θσ. ..ÉÉÉÉÉÉ
001E 4210: 68 20 42 5E 00 E8 12 BD 01 00 59 C3 90 90 90 90 h B^.Φ.╜ ..Y├ÉÉÉÉ
001E 4220: B9 50 5C 77 00 E9 46 16 01 00 90 90 90 90 90 90 ╣P\w.ΘF. ..ÉÉÉÉÉÉ

vm2.exe
001E 41A0: 68 80 F8 5D 00 E8 82 BD 01 00 59 C3 90 90 90 90 hÇ°].Φé╜ ..Y├ÉÉÉÉ
001E 41B0: E8 0B 00 00 00 E9 16 00 00 00 90 90 90 90 90 90 Φ....Θ.. ..ÉÉÉÉÉÉ
001E 41C0: B9 21 5C 77 00 E9 4A 10 01 00 90 90 90 90 90 90 ╣!\w.ΘJ. ..ÉÉÉÉÉÉ
001E 41D0: 68 E0 41 5E 00 E8 52 BD 01 00 59 C3 90 90 90 90 hαA^.ΦR╜ ..Y├ÉÉÉÉ
001E 41E0: B9 21 5C 77 00 E9 A9 11 01 00 90 90 90 90 90 90 ╣!\w.Θ⌐. ..ÉÉÉÉÉÉ
001E 41F0: E8 0B 00 00 00 E9 16 00 00 00 90 90 90 90 90 90 Φ....Θ.. ..ÉÉÉÉÉÉ
001E 4200: B9 20 5C 77 00 E9 E5 14 01 00 90 90 90 90 90 90 ╣ \w.Θσ. ..ÉÉÉÉÉÉ
001E 4210: 68 20 42 5E 00 E8 12 BD 01 00 59 C3 90 90 90 90 h B^.Φ.╜ ..Y├ÉÉÉÉ
001E 4220: B9 20 5C 77 00 E9 46 16 01 00 90 90 90 90 90 90 ╣ \w.ΘF. ..ÉÉÉÉÉÉ


The first 3 diffs are different by 30h. Interpreting the diffs as bytes in an aligned 4-byte words, the first one is 775C51B9h vs. 775C21B9h, which is off by 3000h.

I don't have the output in front of me, but when we looked this offset up in CFF Explorer, it looked to be a jump table of sorts. It was something like
mov cx, (constant)
jmp (another constant)

Of these two constants, one matched and the other was the same diff above (775C51B9h vs 775C21B9h). I don't remember which was which off the top of my head, but I do remember what was at the target of the jumps. Following the jumps, and comparing it to a .map of the build, it looks to be the global static constructor table ($E18 or $E24, iirc). The first offending entry is the static constructor that sets up cin. The other two are cout and cerr.

The identical build machines are using an embedded celeron processor with a gig of ram running XP Pro Sp2. The VM is VMWare player, the most recent version, running XP Pro Sp2 and MSVC++ Enterprise Edition.

Does anyone have any insight? Thanks!
AnswerRe: Bit for bit reproducible build in vc6. Pin
Garth J Lancaster17-Mar-09 12:03
professionalGarth J Lancaster17-Mar-09 12:03 
AnswerRe: Bit for bit reproducible build in vc6. Pin
bulg17-Mar-09 12:09
bulg17-Mar-09 12:09 
AnswerRe: Bit for bit reproducible build in vc6. Pin
Michael Schubert17-Mar-09 13:04
Michael Schubert17-Mar-09 13:04 
AnswerRe: Bit for bit reproducible build in vc6. Pin
Stuart Dootson17-Mar-09 13:18
professionalStuart Dootson17-Mar-09 13:18 
Questionexecuting code before WM_DISPLAYCHANGE ? Pin
rognorak17-Mar-09 10:06
rognorak17-Mar-09 10:06 
AnswerRe: executing code before WM_DISPLAYCHANGE ? Pin
Nishad S17-Mar-09 20:01
Nishad S17-Mar-09 20:01 
GeneralRe: executing code before WM_DISPLAYCHANGE ? Pin
rognorak18-Mar-09 3:38
rognorak18-Mar-09 3:38 
GeneralRe: executing code before WM_DISPLAYCHANGE ? Pin
Nishad S18-Mar-09 4:19
Nishad S18-Mar-09 4:19 
Questionconverting from binary number representation to floating-point representation Pin
steve_o17-Mar-09 9:50
steve_o17-Mar-09 9:50 
AnswerRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 10:09
mveCPallini17-Mar-09 10:09 
GeneralRe: converting from binary number representation to floating-point representation [modified] Pin
steve_o17-Mar-09 11:41
steve_o17-Mar-09 11:41 
GeneralRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 11:55
mveCPallini17-Mar-09 11:55 
GeneralRe: converting from binary number representation to floating-point representation Pin
Stuart Dootson17-Mar-09 13:36
professionalStuart Dootson17-Mar-09 13:36 
GeneralRe: converting from binary number representation to floating-point representation [modified] Pin
steve_o17-Mar-09 17:07
steve_o17-Mar-09 17:07 
QuestionRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 22:42
mveCPallini17-Mar-09 22:42 
GeneralRe: converting from binary number representation to floating-point representation Pin
Stuart Dootson17-Mar-09 23:12
professionalStuart Dootson17-Mar-09 23:12 
GeneralRe: converting from binary number representation to floating-point representation Pin
steve_o18-Mar-09 11:08
steve_o18-Mar-09 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.