Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# monolix2rx 0.0.7

* Document known `(int)strlen(gBuf)` cast in all 13 `trans_*` parser
entry-points. Inputs at or above `INT_MAX` bytes cause silent length
truncation in the `dparse()` call. A long-term fix will switch each
call site to `udparse()` once dparser-R ships that symbol to CRAN.

# monolix2rx 0.0.6

* Updated to add types for rstudio completion
Expand Down
4 changes: 4 additions & 0 deletions src/dataSettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ void trans_data_settings(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/equation.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ void trans_equation(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/longDef.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ void trans_longdef(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/longOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ void trans_longoutput(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranContent.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ void trans_content(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranFileinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ void trans_fileinfo(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranFit.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ void trans_fit(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranInd.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ void trans_individual(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranIndDefinition.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ void trans_indDef(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranOp.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ void trans_mlxtran_op(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranParameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ void trans_parameter(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/mlxtranTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ void trans_mlxtrantask(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/summaryData.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ void trans_summaryData(const char* parse){
errP = curP;
eBufLast = 0;
gBufFree=0;
/* TODO(long-term): switch to udparse() once dparser-R ships that symbol
* to CRAN. udparse() accepts an unsigned int for buf_len, eliminating
* the silent (int)strlen truncation on inputs >= INT_MAX bytes.
* Track at https://github.com/nlmixr2/dparser-R */
_pn= dparse(curP, gBuf, (int)strlen(gBuf));
if (!_pn || curP->syntax_errors) {
} else {
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-mem-dparse-int-cast.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_that("trans_* parsers handle normal-sized inputs without error", {
# Sanity check: regular Mlxtran fragments must parse cleanly.
# The (int)strlen(gBuf) cast in each trans_* entry-point is a known
# long-term issue: inputs >= INT_MAX bytes silently truncate the length
# passed to dparse(). The fix will arrive when dparser-R exports
# udparse() to CRAN; at that point each call site will switch from
# dparse(curP, gBuf, (int)strlen(gBuf))
# to
# udparse(curP, gBuf, (unsigned int)strlen(gBuf)).
expect_no_error(
tryCatch(
.Call(`_monolix2rx_trans_equation`,
"[LONGITUDINAL] EQUATION:\nf = exp(-k*t)\n",
"[LONGITUDINAL] EQUATION:"),
error = function(e) {
if (grepl("input too large", conditionMessage(e))) stop(e)
# Other parse errors from synthetic input are acceptable.
NULL
}
)
)
})

test_that("dparse int-cast known issue documented (skipped: requires ~2GB RAM)", {
skip("Requires ~2GB free RAM; fix pending dparser-R udparse() CRAN release")
# When input reaches INT_MAX bytes, (int)strlen silently truncates the
# length, causing dparse() to read from an incorrect position.
big <- strrep("a", 2147483647L)
expect_error(.Call(`_monolix2rx_trans_equation`, big, ""))
})
Loading