onetrueawk / awk

One true awk
Other
1.99k stars 160 forks source link

error using `--csv`, realloc of unallocated pointer #235

Closed nickdgardner closed 3 months ago

nickdgardner commented 4 months ago

I ran into the error below using the --csv option. I'm new to awk and C so not sure what could be causing this. It's not preventing awk from giving the desired output, there's just a subsequent error message. The csv file PAA.csv contains utf-8 Ancient Greek characters and field internal commas. I'm not sure what else might be relevant, but happy to provide further information.

I'm on an Apple M2 pro and otawk is this repo's awk (with bison as parser).


$ otawk --csv 'NR <= 3 { print NR, $2, $1, $3 }' PAA.csv
1 nam num idt
2 -ΗΣ ΑΓΚΥΛΕΥΣ (ΑΙΓΕ*) 011220 citizen sailor (nautes astos) in naval catalogue, pa a 400?a (-405 to -400). Status: A.
3 -ΛΛΙΟΣ ΑΓΝΟΥΣΙΟΣ? (ΑΤΤΑ*) 011420 bouleutes, 191/2-209/10?p (191 to 210). Status: A.
otawk(17683,0x1e8343ac0) malloc: *** error for object 0x14e00a600: pointer being realloc'd was not allocated
otawk(17683,0x1e8343ac0) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    17683 abort      otawk --csv 'NR <= 3 { print NR, $2, $1, $3 }' PAA.csv
plan9 commented 4 months ago

thanks for the report, will investigate.

plan9 commented 4 months ago

@nickdgardner please include a minimal input file that reproduces this problem.

plan9 commented 3 months ago

i have not been able to reproduce this.