Looks like no one's replied in a while. To start the conversation again, simply ask a new question.
    
     

Q: Bug: NULL bytes being written to file on SMB volumes

This is a 100% reproducable bug.

 

When writing to files that are on a Samba (SMB) volume, if you are overwriting a file and making it smaller than it previously was, then OSX is writing NULL bytes to the end fo the file, which produce all sorts of problems, especially for software developers.

 

How to reproduce:

 

Open Terminal, navigate to a SMB volume and do the following:

 

# echo "test" > test.txt

 

# more test.txt

test

 

# echo "test test test test" > test.txt

 

# more test.txt

test test test test

 

# echo "test" > test.txt

 

# more test.txt

"test.txt" may be a binary file.  See it anyway?

test

^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@

 

 

 

This is 100% reproducable every time.  As you can see, when you overwrite a file with a larger version, the NULL bytes are not written to the file.  But when you overwrite with a smaller version, NULL bytes are written to the end of the file.

 

This problem is especially a problem for developers.  I came across this bug because I had a git repository on an SMB share/volume.  Whenever I would try to commit changes to the repository, if the git commit log file was shorter than it was in the previous commit, then git threw the error:

 

error: a NULL byte in commit log message not allowed.

fatal: failed to write commit object

 

You can see this issue being discussed and reported in several places:

http://stackoverflow.com/questions/20696643/how-do-i-keep-nul-bytes-from-appeari ng-throughout-my-git-repository-and-commit-m

http://stackoverflow.com/questions/19705825/error-a-nul-byte-in-commit-log-messa ge-not-allowed

https://netbeans.org/bugzilla/show_bug.cgi?id=237766

 

This bug was introduced in Mavericks.  Also, remounting the volume using cifs:// doesn't make a difference.

 

Does anyone have any solutions for this problem?  Has this been reported to Apple?  Does Apple know about this problem?

Posted on Jan 16, 2014 8:42 AM

  • Helpful answers
  • All replies
  • by Eric Root,

     Eric Root Jan 16, 2014 10:02 AM in response to Jakobud
    Level 10 Level 10 (119,899 points)
    expertise.itunes
    iTunes
    Jan 16, 2014 10:02 AM in response to Jakobud

    Apple doesn’t routinely monitor the discussions.

     

    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.

     

    Feedback

     

    Or you can use your Apple ID to register with this site and go the Apple BugReporter. Supposedly you will get an answer if you submit feedback.

     

    Feedback via Apple Developer

    Jan 16, 2014 10:02 AM

  • by Bob the Tomato,

     Bob the Tomato Jan 16, 2014 10:57 AM in response to Jakobud
    Level 1 Level 1 (55 points)
    Jan 16, 2014 10:57 AM in response to Jakobud

    Did that fix at the end of the StackOverflow link help you out? This one-> "#unix extensions = off"

    Jan 16, 2014 10:57 AM

  • by Jakobud,

     Jakobud Jan 16, 2014 12:30 PM in response to Bob the Tomato
    Level 1 Level 1 (0 points)
    Jan 16, 2014 12:30 PM in response to Bob the Tomato

    No that didn't seem to make a difference.

    Jan 16, 2014 12:30 PM

  • by LaughingElephant,

     LaughingElephant Feb 13, 2014 12:09 PM in response to Jakobud
    Level 1 Level 1 (0 points)
    Feb 13, 2014 12:09 PM in response to Jakobud

    I went ahead and submitted a bug through the developer portal for this, as well. Hopefully, they'll fix this soon because it's making developing using network shares a pain.

    Feb 13, 2014 12:09 PM

  • by Jakobud,

     Jakobud Feb 13, 2014 1:59 PM in response to LaughingElephant
    Level 1 Level 1 (0 points)
    Feb 13, 2014 1:59 PM in response to LaughingElephant

    I have also submitted a bug report however it was rejected because it was a clone of another bug report.  So someone had already submitted it apparently.  It referenced a link to the other bug on the developer bug reporting site, but when I clicked it I did not have access to view it.  So I have no way of knowing exactly what the status of the bug is etc. Hopefully its fixed in a Mavericks update soon.

    Feb 13, 2014 1:59 PM

  • by Dan.N,

     Dan.N Mar 6, 2014 7:12 PM in response to LaughingElephant
    Level 1 Level 1 (4 points)
    Mar 6, 2014 7:12 PM in response to LaughingElephant

    What is the bug number?

    Mar 6, 2014 7:12 PM

  • by farflame,

     farflame May 6, 2014 9:18 AM in response to Jakobud
    Level 1 Level 1 (0 points)
    May 6, 2014 9:18 AM in response to Jakobud

    I'm having the same problem. Using a git repository in an SMB share this is very annoying.

    What I've found trying the exampe is that the test.txt file is correctly written on the share, if I open it using an editor on the server there are no NULLs at the end, it's just the cached copy in memory that is corrupted.

    If I unmont and then remount the share the files are correct. Unmounting and remounting let me do some commits that were impossible to do.

    May 6, 2014 9:18 AM