Opened 18 months ago

Closed 15 months ago

Last modified 15 months ago

#66153 closed defect (fixed)

cdparanoia: Assertion failed: (range.location + range.length <= dataLength), function __CFDataValidateRange, file CFData.c, line 235

Reported by: Jtaillan Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version:
Keywords: ventura Cc: chrstphrchvz (Christopher Chavez)
Port: cdparanoia

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Whatever the command I give, I always get the same error. For example :

$ cdparanoia -A
cdparanoia III release 10.2 (September 11, 2008)

Using cdda library version: 10.2
Using paranoia library version: 10.2
Assertion failed: (range.location + range.length <= dataLength), function __CFDataValidateRange, file CFData.c, line 235

I *think* this worked flawlessly on MacOS 12.X

Change History (12)

comment:1 Changed 18 months ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Keywords: ventura arm64 added
Owner: set to jeremyhu
Port: cdparanoia added
Status: newassigned
Summary: Error using cdparanoia on M1 Mac running 13.0cdparanoia: Assertion failed: (range.location + range.length <= dataLength), function __CFDataValidateRange, file CFData.c, line 235

comment:2 Changed 15 months ago by kencu (Ken)

no assertions for me on an arm64 Mac running 13.2:

% uname -a
Darwin Kens-MBP 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64
% cdparanoia -A
cdparanoia III release 10.2 (September 11, 2008)

Using cdda library version: 10.2
Using paranoia library version: 10.2

Unable to open disc.

comment:3 Changed 15 months ago by chrstphrchvz (Christopher Chavez)

The reporter replied via email https://lists.macports.org/pipermail/macports-dev/2023-January/044912.html:

I think you tested without a music CD in the drive…

Could you please retry the test with a music CD? I can confirm I still see the problem with Ventura 13.2

comment:4 Changed 15 months ago by chrstphrchvz (Christopher Chavez)

I have not reproduced this issue myself nor looked into it deeply, but from finding a similar error in another program (see https://github.com/xmrig/xmrig/issues/3185 and https://github.com/xmrig/xmrig/commit/770b71c), I suspect the bug is near https://github.com/macports/macports-ports/blob/d3272007c0ea/audio/cdparanoia/files/osx_interface.patch#L459-L468: CFGetDataBytes() is being called with a range of CFRangeMake(0, CFDataGetLength(data) + 1), whereas https://developer.apple.com/documentation/corefoundation/1541940-cfdatagetbytes?language=objc says that a range of CFRangeMake(0, CFDataGetLength(data)) should be used when retrieving all data.

comment:5 Changed 15 months ago by chrstphrchvz (Christopher Chavez)

Cc: chrstphrchvz added

comment:6 Changed 15 months ago by kencu (Ken)

I don't have a CD drive for the arm64 Mac, but the assertion does happen on an Intel Ventura system when a CD is in the drive. Let me see if Chris' find fixes it.

comment:7 Changed 15 months ago by kencu (Ken)

Yup, good find:

% uname -a
Darwin MacBookPro-2012 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64
% cdparanoia -A
cdparanoia III release 10.2 (September 11, 2008)

Using cdda library version: 10.2
Using paranoia library version: 10.2
track_num = 160 start sector 4350 msf: 1,0,0
track_num = 161 start sector 58350 msf: 13,0,0
track_num = 162 start sector 227540 msf: 50,35,65
track_num = 1 start sector 0 msf: 0,2,0
track_num = 2 start sector 13887 msf: 3,7,12
track_num = 3 start sector 27852 msf: 6,13,27
track_num = 4 start sector 48390 msf: 10,47,15
track_num = 5 start sector 70827 msf: 15,46,27
track_num = 6 start sector 86352 msf: 19,13,27
track_num = 7 start sector 102900 msf: 22,54,0
track_num = 8 start sector 117642 msf: 26,10,42
track_num = 9 start sector 136590 msf: 30,23,15
track_num = 10 start sector 152585 msf: 33,56,35
track_num = 11 start sector 165180 msf: 36,44,30
track_num = 12 start sector 185457 msf: 41,14,57
track_num = 13 start sector 204627 msf: 45,30,27

Attempting to set cdrom to full speed... 
	drive returned OK.

I changed just one line in osx_interface.patch, from:

+  buf_len = CFDataGetLength(data) + 1;

to

+  buf_len = CFDataGetLength(data);

I suppose we should test that on at least one or two older systems, but it seems a simple, solid fix so should be no problems. Presumably Ventura is increasingly strict about buffer overruns.

comment:8 Changed 15 months ago by kencu (Ken)

Keywords: arm64 removed

comment:9 Changed 15 months ago by kencu (Ken)

yes, works fine with the new buffer length on Lion, including extracting audio files. LGTM.

Last edited 15 months ago by kencu (Ken) (previous) (diff)

comment:10 Changed 15 months ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In c8e15973bc3c1e1ab371bc0ee2de14209e639f17/macports-ports (master):

cdparanoia: fix buffer overrun on Ventura

this minor error has been in the patch forever, but
was flagged on Ventura.

kudos to @chrstphrchvz

closes: #66153

comment:11 Changed 15 months ago by Jtaillan

Sorry but this doesn't fix the problem here :

chaconne$ uname -a
Darwin chaconne.local 22.3.0 Darwin Kernel Version 22.3.0: Thu Jan  5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000 arm64
chaconne$ cdparanoia -B -r
cdparanoia III release 10.2 (September 11, 2008)

Assertion failed: (range.location + range.length <= dataLength), function __CFDataValidateRange, file CFData.c, line 235.
zsh: abort      cdparanoia -B -r

comment:12 Changed 15 months ago by Jtaillan

My mistake. I somehow mixed the old and the new version during my tests.

Th new version is indeed working great. Thanks for the fix!

Note: See TracTickets for help on using tickets.