Bug 4979 - dirstate corruption causes appcrash
Summary: dirstate corruption causes appcrash
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 3.6.1
Hardware: PC Windows
: normal bug
Assignee: Yuya Nishihara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-02 08:03 UTC by kubelsmieci
Modified: 2015-12-15 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments
corrupted dirstate file (189.78 KB, application/octet-stream)
2015-12-02 08:03 UTC, kubelsmieci
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kubelsmieci 2015-12-02 08:03 UTC
Created attachment 1880 [details]
corrupted dirstate file

Somehow (probably failed restore from hibernated system) my 'dirstate' file was corrupted: 190kB with only 0x00 bytes in all file.

Any 'hg' command causes hg.exe to crash:
	========================
		Podpis problemu:
		  Nazwa zdarzenia problemu:	APPCRASH
		  Nazwa aplikacji:	hg.exe
		  Wersja aplikacji:	3.6.1.0
		  Sygnatura czasowa aplikacji:	4918017b
		  Nazwa modułu z błędem:	MSVCR90.dll
		  Wersja modułu z błędem:	9.0.30729.6161
		  Sygnatura czasowa modułu z błędem:	4dace4e7
		  Kod wyjątku:	c0000005
		  Przesunięcie wyjątku:	000000000001e51d
		  Wersja systemu operacyjnego:	6.1.7601.2.1.0.256.48
		  Identyfikator ustawień regionalnych:	1045
		  Dodatkowe informacje 1:	2ad9
		  Dodatkowe informacje 2:	2ad922288d1197cb0e39ebfca1c9763d
		  Dodatkowe informacje 3:	5787
		  Dodatkowe informacje 4:	5787facdad846807ec2517374d75d1a1
	========================
'hg debugrebuildstate -r tip' also causes appcrash.

Only 'hg clone' from outside of repo worked. Cloned repo worked.

Deleting 'dirstate' from broken repo - hg commands stopped crashed, but working directory is broken:
	========================
		λ hg sum
		parent: -1:000000000000  (no revision checked out)
		branch: sralgs
		commit: 2830 unknown (new branch)
		update: 6227 new changesets (update)
		phases: 1034 draft
	========================
(I understate this is expected)

After copied 'dirstate' from cloned repo to broken repo, working directory seems ok:
	========================
		λ hg sum
		parent: 6569:0b005c2a028c tip
		 my last commit message
		branch: sralgs
		commit: 1 modified
		update: (current)
		phases: 1034 draft
	========================
		λ hg verify -v                                    
		repository uses revlog format 1                   
		checking changesets                               
		checking manifests                                
		crosschecking files in changesets and manifests   
		checking files                                    
		8843 files, 6570 changesets, 28581 total revisions
	========================
Comment 1 Yuya Nishihara 2015-12-02 09:00 UTC
Confirmed. parse_dirstate() could read at most 17 bytes beyond the
boundary.
Comment 2 HG Bot 2015-12-07 19:15 UTC
Fixed by https://selenic.com/repo/hg/rev/f5e8cb813a4d
Yuya Nishihara <yuya@tcha.org>
parsers: fix parse_dirstate to check len before unpacking header (issue4979)

(please test the fix)
Comment 3 Bugzilla 2015-12-15 00:00 UTC
Bug was set to TESTING for 7 days, resolving