{"record":{"id":"9f12777661634252","repo":"DrKLO/Telegram","slug":"s-can-t-read-icc-profile-from-s-n","errorCode":null,"errorMessage":"%s: can't read ICC profile from %s\\n","messagePattern":"(.+?): can't read ICC profile from (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/djpeg.c","lineNumber":786,"sourceCode":"#ifdef PROGRESS_REPORT\n  /* Hack: count final pass as done in case finish_output does an extra pass.\n   * The library won't have updated completed_passes.\n   */\n  progress.pub.completed_passes = progress.pub.total_passes;\n#endif\n\n  if (icc_filename != NULL) {\n    FILE *icc_file;\n    JOCTET *icc_profile;\n    unsigned int icc_len;\n\n    if ((icc_file = fopen(icc_filename, WRITE_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, icc_filename);\n      exit(EXIT_FAILURE);\n    }\n    if (jpeg_read_icc_profile(&cinfo, &icc_profile, &icc_len)) {\n      if (fwrite(icc_profile, icc_len, 1, icc_file) < 1) {\n        fprintf(stderr, \"%s: can't read ICC profile from %s\\n\", progname,\n                icc_filename);\n        free(icc_profile);\n        fclose(icc_file);\n        exit(EXIT_FAILURE);\n      }\n      free(icc_profile);\n      fclose(icc_file);\n    } else if (cinfo.err->msg_code != JWRN_BOGUS_ICC)\n      fprintf(stderr, \"%s: no ICC profile data in JPEG file\\n\", progname);\n  }\n\n  /* Finish decompression and release memory.\n   * I must do it in this order because output module has allocated memory\n   * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.\n   */\n  (*dest_mgr->finish_output) (&cinfo, dest_mgr);\n  (void)jpeg_finish_decompress(&cinfo);\n  jpeg_destroy_decompress(&cinfo);","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/djpeg.c#L768-L804","documentation":"MISLEADING MESSAGE: the text says 'can't read ICC profile' but the actual failing call is fwrite(icc_profile, icc_len, 1, icc_file) < 1, i.e. a WRITE failure to the ICC output file. jpeg_read_icc_profile succeeded and returned data, but writing that data to disk failed (e.g. disk full, write error). Fatal.","triggerScenarios":"ICC profile was successfully extracted from the JPEG, but fwrite to icc_file could not write icc_len bytes. Commonly disk full, quota exceeded, or a write I/O error on the target device. The message incorrectly blames reading.","commonSituations":"Full disk or quota when writing the ICC blob, target on a failing/unmounting storage medium, or a filesystem with a per-file size limit. Developers waste time looking at the input JPEG because the message says 'read'.","solutions":["Free space on the target volume / raise quota, then retry.","Point -icc at stable local storage rather than a flaky mount.","Treat the message as a WRITE failure: check df and write perms on the ICC path.","Verify disk health if write errors recur on known-good free space."],"exampleFix":"// before: writes ICC to a full volume\n./djpeg in.jpg -icc /full/profile.icc > out.ppm\n// after: free space / use a writable volume\ndf -h /tmp\n./djpeg in.jpg -icc /tmp/profile.icc > out.ppm","handlingStrategy":"validation","validationCode":"#include <sys/statvfs.h>\nint has_space_for(const char *dirpath, size_t need) {\n  struct statvfs v;\n  if (statvfs(dirpath, &v) != 0) return 0;\n  return (size_t)(v.f_bavail * v.f_bsize) >= need;\n}\n/* call on dirname(icc_filename) before djpeg; profile is typically < 1 MB */","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember this is a WRITE error despite the 'read' wording.","Check free space and quota on the ICC target volume.","Prefer local storage over flaky mounts for ICC output."],"tags":["file-io","djpeg","icc","write-error","mozjpeg","misleading-message"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}