Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#3607 closed defect (fixed)

Assertion failure in start_writing_to_file

Reported by: Morbid Owned by: rransom
Priority: High Milestone: Tor: 0.2.2.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-client
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Jul 17 22:04:30.422 [Error] start_writing_to_file(): Bug: util.c:1802: start_writing_to_file: Assertion (open_flags & (O_BINARY|O_TEXT)) != 0 failed; aborting.

Child Tickets

Attachments (1)

0001-Specify-text-or-binary-mode-in-every-start_writing_t.patch (4.8 KB) - added by rransom 8 years ago.
patch

Download all attachments as: .zip

Change History (13)

comment:1 Changed 8 years ago by rransom

Component: VidaliaTor Client
Milestone: Vidalia-0.3.X
Owner: changed from chiiph to nickm
Priority: normalcritical
Status: newassigned
Summary: Vadalia ErrorAssertion failure in start_writing_to_file

This shouldn't happen.

comment:2 Changed 8 years ago by rransom

O_BINARY and O_TEXT are both undefined on FreeBSD, and are thus defined to 0 in src/common/util.h.

comment:3 in reply to:  2 Changed 8 years ago by rransom

Replying to rransom:

O_BINARY and O_TEXT are both undefined on FreeBSD, and are thus defined to 0 in src/common/util.h.

But that assertion is disabled by an #ifdef when both flags are undefined.

comment:4 Changed 8 years ago by rransom

Milestone: Tor: 0.2.2.x-final
Owner: changed from nickm to rransom

In src/or/geoip.c, in geoip_dirreq_stats_write (on maint-0.2.2):

  out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
                                    0600, &open_file);

There seem to be others.

comment:5 Changed 8 years ago by arma

Did we figure out what Tor version this was, and what platform (operating system) it was?

comment:6 in reply to:  5 Changed 8 years ago by rransom

Priority: criticalmajor

Replying to arma:

Did we figure out what Tor version this was, and what platform (operating system) it was?

This bug can only appear on Windows, because the Unixoids (including MacOS 10) don't distinguish text mode from binary mode (and thus probably don't define O_TEXT or O_BINARY, so the assertion that failed here gets #ifdef-ed out).

I suspect the 0.2.3.1-alpha test bundles, because I remember hearing that the dirreq-stats feature was turned on by default in 0.2.3.x, and any Windows user who would have known how to fiddle with Tor's configuration on 0.2.2.x in a way that would trigger this bug would have submitted a more detailed bug report.

comment:7 Changed 8 years ago by rransom

Status: assignedneeds_review

comment:8 Changed 8 years ago by nickm

I've made a "bug3607" branch and tweaked the changes file a little bit so that it doesn't have a huge list between "write several files" and "in text mode".

I was a little worried in some places that we might be write something in text mode and then later read it in binary mode, but I think we're in the clear: when we read the client-keys file, we do so in text mode. We never read the files written in geoip.c, or the hostname file, or the buffer-stats file.

One thing, though: is it right to make the stuff in tor-gencert in text mode? I think that when we load and parse certificates, we assume that they're stored in LF mode. Better check this. (This doesn't matter too much, since there is no way we're having an authority op who makes signing keys on windows, but it would be nice to get it right for testing.)

comment:9 in reply to:  8 Changed 8 years ago by rransom

Replying to nickm:

I've made a "bug3607" branch and tweaked the changes file a little bit so that it doesn't have a huge list between "write several files" and "in text mode".

Looks good!

I was a little worried in some places that we might be write something in text mode and then later read it in binary mode, but I think we're in the clear: when we read the client-keys file, we do so in text mode. We never read the files written in geoip.c, or the hostname file, or the buffer-stats file.

One thing, though: is it right to make the stuff in tor-gencert in text mode? I think that when we load and parse certificates, we assume that they're stored in LF mode. Better check this. (This doesn't matter too much, since there is no way we're having an authority op who makes signing keys on windows, but it would be nice to get it right for testing.)

Keys are read using init_key_from_file, which calls crypto_pk_read_private_key_from_filename, which calls read_file_to_str without the RFTS_BIN flag; thus, keys are read in text mode. Whether this text mode expects CRLF or LF line endings is OS-dependent.

comment:10 Changed 8 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Sounds fine to me; merging.

comment:11 Changed 7 years ago by nickm

Keywords: tor-client added

comment:12 Changed 7 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.